public async Task <ActionResult <CouponReturnModels.Coupon> > Create([FromBody] CouponRequestModels.Create req) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var couponId = await _couponService.CreateAsync(req); var coupon = await _couponService.GetCouponByIdAsync(couponId); return(coupon); }
public async Task <ActionResult> Create(CouponViewModel couponViewModel) { try { if (ModelState.IsValid) { var coupon = Mapper.Map <Coupon>(couponViewModel); coupon.Status = CommonStatus.Active; await _couponService.CreateAsync(coupon, true); return(RedirectToAction("Index")); } } catch { } return(View()); }
public async Task <IActionResult> Put([FromBody] CouponDto coupon) { return(Success(await _couponService.CreateAsync(coupon))); }