Esempio n. 1
0
        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);
        }
Esempio n. 4
0
        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"));
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        public Result Add(Coupon coupon)
        {
            var result = new Result();

            IsCouponValid(coupon);

            try
            {
                result = _couponRepository.Add(coupon);
            }
            catch (Exception ex)
            {
                _logger.Log(ex);
            }

            return(result);
        }
Esempio n. 7
0
        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)));
        }
Esempio n. 8
0
 public void CreateCoupon(Coupon Coupon)
 {
     CouponsRepository.Add(Coupon);
     SaveCoupon();
 }