Esempio n. 1
0
 public virtual void Delete(SysSettingViewModel sys, ModelStateDictionary modelState)
 {
     var entity = sys.ToEntity();
     db.SysSettings.Attach(entity);
     db.SysSettings.Remove(entity);
     db.SaveChanges();
 }
Esempio n. 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;
 }
Esempio n. 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();
            }
        }
Esempio n. 4
0
 private bool ValidateModel(SysSettingViewModel sys, ModelStateDictionary modelState)
 {
     return true;
 }
Esempio n. 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;
            }
        }