public ActionResult Add(GoodsUnitModel model) { if (ModelState.IsValid) { GoodsUnit goodsUnit = model.MapTo <GoodsUnitModel, GoodsUnit>(); _goodsUnitService.Insert(goodsUnit); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Edit(GoodsUnitModel model) { if (ModelState.IsValid) { GoodsUnit goodsUnit = model.MapTo <GoodsUnitModel, GoodsUnit>(); _goodsUnitService.Update(goodsUnit); SuccessNotification($"{_localizationService.GetResource("UpdateSuccess") }"); return(RedirectToAction("Index")); } return(View(model)); }
public void Update(GoodsUnit GoodsUnit) { var sql = $@"update GoodsUnit set Name=@Name where ID=@ID"; _context.Execute(sql, new { ID = GoodsUnit.ID, Name = GoodsUnit.Name }); }
public void Insert(GoodsUnit GoodsUnit) { var sql = $@"insert into GoodsUnit( Name) VALUES ( @Name)"; _context.Execute(sql, new { Name = GoodsUnit.Name }); }
public JsonResult Edit(GoodsUnit model) { var apiResult = new APIResult(); try { GoodsUnitBll.AddOrUpdate(model, UserContext.CurrentUser.HotelId); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }