public Task <int> InsertAsync(IPWidthTypeModel model) { model.FlagForCreate(_identityProvider.Username, UserAgent); _iPWidthTypeDbSet.Add(model); return(_dbContext.SaveChangesAsync()); }
/// <summary> /// Used For dbModelto viewmodel /// </summary> private IPWidthTypeViewModel MappingViewModel(IPWidthTypeModel modelDb) { return(new IPWidthTypeViewModel { Id = modelDb.Id, Code = modelDb.Code, WidthType = modelDb.WidthType }); }
/// <summary> /// Used for dbmodel to viewmodel(indexViewModel) /// </summary> private IndexViewModel MappingIndexViewModel(IPWidthTypeModel modelDb) { return(new IndexViewModel { Id = modelDb.Id, Code = modelDb.Code, WidthType = modelDb.WidthType, }); }
public Task <int> UpdateAsync(int id, IPWidthTypeModel newModel) { var modelToUpdate = _iPWidthTypeDbSet.Where(s => s.Id == id); foreach (var model in modelToUpdate) { model.SetCode(newModel.Code, _identityProvider.Username, UserAgent); model.SetWidthType(newModel.WidthType, _identityProvider.Username, UserAgent); _iPWidthTypeDbSet.Update(model); } return(_dbContext.SaveChangesAsync()); }