public virtual void Delete(SysSettingViewModel sys, ModelStateDictionary modelState) { var entity = sys.ToEntity(); db.SysSettings.Attach(entity); db.SysSettings.Remove(entity); db.SaveChanges(); }
public virtual void Update(SysSettingViewModel sys, ModelStateDictionary modelState) { if (ValidateModel(sys, modelState)) { if (string.IsNullOrEmpty(sys.Description)) { sys.Description = ""; } var entity = sys.ToEntity(); db.SysSettings.Attach(entity); db.Entry(entity).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public virtual void Insert(SysSettingViewModel sys, ModelStateDictionary modelState) { if (ValidateModel(sys, modelState)) { if (string.IsNullOrEmpty(sys.Description)) { sys.Description = ""; } var entity = sys.ToEntity(); db.SysSettings.Add(entity); db.SaveChanges(); sys.ID = entity.ID; } }