public TipServiceChargeModels GetDetail(string id, string StoreID) { try { TipServiceChargeModels model = _factory.GetListTipServiceCharge(StoreID, id)[0]; return(model); } catch (Exception ex) { _logger.Error("TipServiceCharge_Detail: " + ex); return(null); } }
public bool InsertOrUpdateTipServiceCharge(TipServiceChargeModels model, ref string msg) { try { TipServiceChargeApiModels paraBody = new TipServiceChargeApiModels(); paraBody.AppKey = Commons.AppKey; paraBody.AppSecret = Commons.AppSecret; paraBody.CreatedUser = Commons.CreateUser; paraBody.RegisterToken = new RegisterTokenModels(); paraBody.ID = model.ID; paraBody.StoreID = model.StoreID; paraBody.IsApplyForEatIn = model.IsApplyForEatIn; paraBody.IsApplyForTakeAway = model.IsApplyForTakeAway; paraBody.IsIncludedOnBill = model.IsIncludedOnBill; paraBody.IsAllowTip = model.IsAllowTip; paraBody.IsCurrency = model.IsCurrency; paraBody.Value = model.Value; //==================== var result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.UpdateServiceCharge, null, paraBody); if (result != null) { if (result.Success) { return(true); } else { msg = result.Message; _logger.Error(result.Message); return(false); } } else { _logger.Error(result); return(false); } } catch (Exception e) { _logger.Error("TipServiceCharge_InsertOrUpdate: " + e); return(false); } }
public ActionResult Edit(TipServiceChargeModels model) { try { if (string.IsNullOrEmpty(model.StoreID)) { ModelState.AddModelError("StoreID", CurrentUser.GetLanguageTextFromKey("Please choose Store")); } if (!model.IsCurrency) { if (model.Value < 0 || model.Value > 100) { ModelState.AddModelError("Value", CurrentUser.GetLanguageTextFromKey("Please input default price greater than 0 and Maximum service charge is 100%")); } } if (!ModelState.IsValid) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("_Edit", model)); } //==================== string msg = ""; var result = _factory.InsertOrUpdateTipServiceCharge(model, ref msg); if (result) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("Name", msg); return(PartialView("_Edit", model)); } } catch (Exception ex) { _logger.Error("TipServiceCharge_Edit: " + ex); return(new HttpStatusCodeResult(400, ex.Message)); } }
public ActionResult Create(TipServiceChargeModels model) { try { if (string.IsNullOrEmpty(model.Value.ToString())) { ModelState.AddModelError("Value", "Value field is required"); } if (!model.IsCurrency) { if (model.Value < 0 || model.Value > 100) { ModelState.AddModelError("Value", "Please input default price greater than 0 and Maximum service charge is 100%"); } } if (!ModelState.IsValid) { return(View(model)); } string msg = ""; bool result = _factory.InsertOrUpdateTipServiceCharge(model, ref msg); if (result) { return(RedirectToAction("Index")); } else { return(RedirectToAction("Create")); } } catch (Exception ex) { _logger.Error("TipServiceCharge_Create: " + ex); return(new HttpStatusCodeResult(400, ex.Message)); } }
public ActionResult Create() { TipServiceChargeModels model = new TipServiceChargeModels(); return(View(model)); }
public new PartialViewResult View(string StoreID, string id) { TipServiceChargeModels model = GetDetail(id, StoreID); return(PartialView("_View", model)); }