コード例 #1
0
        public void Insert(SettingVIewModel model)
        {
            var entity = new Setting()
            {
                Id    = model.Id,
                Type  = model.Type,
                Value = model.Value
            };

            Repository.Insert(entity);
            UnitOfWork.Save();
        }
コード例 #2
0
 public ActionResult Edit(SettingVIewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _settingService.Update(model);
             return(RedirectToAction("Index"));
         }
         catch (Exception)
         {
         }
     }
     return(View(model));
 }
コード例 #3
0
        public void Update(SettingVIewModel model)
        {
            if (string.IsNullOrEmpty(model.Id))
            {
                throw new Exception("Setting key is null");
            }
            var entity = Repository.Get(model.Id);

            if (entity == null)
            {
                throw new Exception("Setting key is not found");
            }
            //entity.Id = model.Id;
            entity.Type  = model.Type;
            entity.Value = model.Value;
            Repository.Update(entity);
            UnitOfWork.Save();
        }
コード例 #4
0
        public ActionResult Edit(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Index"));
            }
            var entity = _settingService.FindById(id);

            if (entity == null)
            {
                return(RedirectToAction("Index"));
            }
            var model = new SettingVIewModel()
            {
                Id    = entity.Id,
                Value = entity.Value,
                Type  = entity.Type
            };

            return(View(model));
        }