public async Task <Booking> Get(int id) { var booking = await bookingRepository.Get(id); var bookingServiceDetails = (await bookingServiceDetailsRepository.Get(booking.BookingId)).ToList(); var bookingRoomDetails = (await bookingRoomDetailsRepository.Display(booking.BookingId)).ToList(); var customer = await customerRepository.Get(booking.CustomerId); var coupon = await couponRepository.GetById(booking.CouponId.GetValueOrDefault()); var data = new Booking() { BookingId = booking.BookingId, CreateDate = booking.CreateDate, CheckinDate = booking.CheckinDate, CheckoutDate = booking.CheckoutDate, NumberofAdults = booking.NumberofAdults, NumberofChildren = booking.NumberofChildren, IsCanceled = booking.IsCanceled, CustomerId = customer.CustomerId, BookingCustomer = customer, CouponId = booking.CouponId, BookingCoupon = coupon, bookingRoomDetails = bookingRoomDetails, bookingServiceDetails = bookingServiceDetails, RoomAmount = booking.RoomAmount, ServiceAmount = booking.ServiceAmount, }; return(data); }
public ActionResult Edit(CouponsDTO entity) { Coupons c = couponRepository.GetById(entity.CouponID); Mapper.Map <CouponsDTO, Coupons>(entity, c); couponRepository.Update(c); couponRepository.Save(); return(Json(entity, JsonRequestBehavior.AllowGet)); }
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 async Task <Coupon> GetById(int id) { return(await couponRepository.GetById(id)); }
public Coupon GetCoupon(int id) { var Coupon = CouponsRepository.GetById(id); return(Coupon); }