public ActionResult CreateCoupon(CouponModel model, bool continueEditing) { if (ModelState.IsValid) { var entity = model.MapTo <Coupon>(); entity.DiscountCode = CommonHelper.GenerateCouponCode(); entity.Id = _couponService.InsertCoupon(entity); return(continueEditing ? RedirectToAction("EditCoupon", new { id = entity.Id }) : RedirectToAction("List")); } return(View(model)); }
public ActionResult EditCoupon(CouponModel model, bool continueEditing) { if (ModelState.IsValid) { var entity = model.MapTo <Coupon>(); if (String.IsNullOrWhiteSpace(entity.DiscountCode)) { entity.DiscountCode = CommonHelper.GenerateCouponCode(); } _couponService.UpdateCoupon(entity); return(continueEditing ? RedirectToAction("Edit", new { id = model.Id }) : RedirectToAction("List")); } return(View(model)); }