Пример #1
0
 public virtual void Delete(SysSettingViewModel sys, ModelStateDictionary modelState)
 {
     var entity = sys.ToEntity();
     db.SysSettings.Attach(entity);
     db.SysSettings.Remove(entity);
     db.SaveChanges();
 }
Пример #2
0
 private SysSettingViewModel ConvertToViewModel(FormCollection collection)
 {
     SysSettingViewModel model = new SysSettingViewModel();
     model.KeyName = Convert.ToString(collection.GetValues("KeyName")[0]);
     model.ValueType = Convert.ToString(collection.GetValues("ValueType")[0]);
     model.Value = Convert.ToString(collection.GetValues("Value")[0]);
     model.KeyGroup = Convert.ToString(collection.GetValues("KeyGroup")[0]);
     model.Description = HttpUtility.HtmlDecode(collection.GetValues("Description")[0]);
     return model;
 }
Пример #3
0
        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();
            }
        }
Пример #4
0
 private bool ValidateModel(SysSettingViewModel sys, ModelStateDictionary modelState)
 {
     return true;
 }
Пример #5
0
        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;
            }
        }