public bool EditDicItem(DicItemModel model) { using (DataProvider dp = new DataProvider()) { System_DicItem entity = dp.System_DicItem.FirstOrDefault(m => m.Id == model.Id); if (entity == null) { return(false); } entity.ItemDesc = model.ItemDesc; entity.Sort = model.Sort; entity.IsEnabled = model.IsEnabled; entity.UpdateTime = DateTime.Now; entity.UpdateUser = model.UpdateUser; try { dp.SaveChanges(); return(true); } catch { return(false); } } }
public bool AddDicItem(DicItemModel model) { System_DicItem entity = Mapper.Map <System_DicItem>(model); using (DataProvider dp = new DataProvider()) { entity.Id = Guid.NewGuid(); entity.CreateTime = DateTime.Now; entity.IsDel = false; dp.System_DicItem.Add(entity); try { dp.SaveChanges(); return(true); } catch { return(false); } } }