public ActionResult <Response> EditCupon(Guid id, CouponModel model) { var couponToEdit = _couponRepository.GetById(id); if (couponToEdit == null) { return(BadRequest(ResponseHelper.CreateResponse("Cupom não encontrado", model.Code))); } if (!couponToEdit.ChangeInfo(model.Code, model.Percentage, model.ExpiryDate)) { return(BadRequest(ResponseHelper.CreateResponse("Não foi possível alterar o cupom", couponToEdit.Notifications))); } if (_couponRepository.Exist(couponToEdit)) { return(BadRequest(ResponseHelper.CreateResponse("Este cupom já se encontra cadastrado", couponToEdit.Id))); } _couponRepository.Edit(couponToEdit); return(Ok(ResponseHelper.CreateResponse("Cupom alterado com sucesso"))); }
public bool EditCoupon(CouponDto couponDto) { var entity = _dtoMapper.Map(couponDto); return(_couponRepository.Edit(entity)); }