handling multiple select values in ASP.net MVC with a service layer -
i have many multiple select dropdowns in asp.net mvc application , wondering best way handle transferring values viewmodel model saved database using ef6 (im using db first way create entities). 1 of viewmodels looks this
public class someviewmodel{ public string[] selectedids public ienumerable<selectlistitem> selectvalues //other properties }
i decided create partial model class , add selectedids like
public partial class somemodel{ public string[] selectedids //other properties }
my model passed service layer
public class someservicelayer{ public int insertsomething(somemodel model){ //do stuff if (model.selectedids.length != 0){ model.selectvalues = _context.selectvalues .where(b => model.selectedids.contains(b.id.tostring())).tolist(); } } }
it feels wrong have add custom property in partial class model. there better way of handling this? interested know
Comments
Post a Comment