Abhilash J A

Abhilash J A

  • 530
  • 2.4k
  • 599k

How can I add each loop values in model class c#?

May 26 2016 12:17 AM
Hello Sir,
 
I don't know what to do.
Here, how can i add list of 'Cids' each value in viewmodel class. In this situation, I can not use List in class because the class using other areas without using List?
 
Please have a look at the attached file.
 
string clientIds = "";
ViewModel.ClientContract clientContract = new ViewModel.ClientContract(); 
foreach (var item in frm.AllKeys)
{
if (item.Contains("cb_"))
{
Mapper.CreateMap<ViewModel.ClientContract, ClientContract>();
var ids = item.Split(new[] { "cb_" }, StringSplitOptions.RemoveEmptyEntries);
// clientContract.ProductDetailsId = Convert.ToInt32(ids[0]);
clientContract.ManageClientDetailsId = manageproduct[0].Id;
clientIds = clientIds + Convert.ToInt32(ids[0]) + ',';
}
}

var Cids = clientIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

foreach (var id in Cids)
{
clientContract.ProductDetailsId = Convert.ToInt32(id); /*Here, how can i add list of 'Cids' each value in viewmodel class. In this situation, I can not use List in class because the class using other areas without using List?*/
}
service.clientContract = Mapper.Map<ViewModel.ClientContract, ClientContract>(clientContract);
service.AddClientContract();

Attachment: doubt.zip

Answers (1)