public ActionResult Add(CouponsDTO entity) { Coupons c = Mapper.Map <CouponsDTO, Coupons>(entity); couponRepository.Add(c); couponRepository.Save(); return(Json(entity, JsonRequestBehavior.AllowGet)); }
protected override Task Handle(CreateCouponCommand request, CancellationToken cancellationToken) { var coupon = new Coupon(request.ID, request.MinimumCartAmount, request.Type, request.Rate); repository.Add(coupon); return(Task.CompletedTask); }
public void AddCoupon(Coupon coupon) { var categories = GetCoupons(); if (categories.Find(x => x.Id == coupon.Id) != null) { throw new Exception("Coupon already exists!"); } _couponRepository.Add(coupon.Id, coupon); }
public async Task <ActionResult> CreateCoupon([FromBody] CouponDTO coupon) { var couponRepo = _mapper.Map <Coupon>(coupon); _repo.Add(couponRepo); if (await _repo.SaveAll()) { return(Ok(coupon)); } return(BadRequest("Adding category error")); }
public async Task <Guid> CreateAsync(CouponRequestModels.Create request) { var coupon = new Coupon() { Name = request.Name, Description = request.Description, StartDate = request.StartDate, EndDate = request.EndDate, MinPrice = request.MinPrice, Value = request.Value }; _couponRepo.Add(coupon); await _couponRepo.UnitOfWork.SaveChangesAsync(); return(coupon.Id); }
public Result Add(Coupon coupon) { var result = new Result(); IsCouponValid(coupon); try { result = _couponRepository.Add(coupon); } catch (Exception ex) { _logger.Log(ex); } return(result); }
public ActionResult <Response> CreateCoupon(CouponModel model) { var newCoupon = (Coupon)model; if (newCoupon.Invalid) { return(BadRequest(ResponseHelper.CreateResponse("Cupom inválido", newCoupon.Notifications))); } if (_couponRepository.Exist(newCoupon)) { return(BadRequest(ResponseHelper.CreateResponse("Este cupom ja está cadastrado", newCoupon.Code))); } _couponRepository.Add(newCoupon); return(Ok(ResponseHelper.CreateResponse("Cupon criado com sucesso", newCoupon.Id))); }
public void CreateCoupon(Coupon Coupon) { CouponsRepository.Add(Coupon); SaveCoupon(); }