public async Task <HttpResponseMessage> CreateBooking(CreateBookingNoteDto booking, int customerID, int outletID)
        {
            var messege = CreateMessageData($"booking/{customerID}/{outletID}",
                                            new KeyValuePair <string, string>[] {
                new KeyValuePair <string, string>("customerID", customerID.ToString()),
                new KeyValuePair <string, string>("outletID", outletID.ToString())
            });

            if (!ModelState.IsValid || customerID <= 0 || outletID <= 0)
            {
                return(CreateValidationErrorResponse(messege, new ValidationResult(Validation.InvalidParameters)));
            }

            var customer = await _customerService.GetCustomerById(customerID);

            if (!customer.IsSuccess)
            {
                return(CreateValidationErrorResponse(messege, new ValidationResult(customer.message)));
            }

            var outlet = await _outletService.GetOutletById(outletID);

            if (!outlet.IsSuccess)
            {
                return(CreateValidationErrorResponse(messege, new ValidationResult(outlet.message)));
            }

            var bookingResult = await _appointmentService.CreateBooking(booking.createBookingDtos, customerID, outletID, booking.note);

            if (!bookingResult.IsSuccess)
            {
                return(CreateValidationErrorResponse(messege, new ValidationResult(bookingResult.message)));
            }
            if (bookingResult.Result.Count() != booking.createBookingDtos.Count())
            {
                return(CreateResponse(HttpStatusCode.OK, new ErrorResponseModel()
                {
                    Message = Validation.SomeBookingSoldOut,
                    StatusCode = (int)HttpStatusCode.OK,
                    StatusDescription = HttpStatusCode.OK.ToString()
                }, messege, bookingResult.Result));
            }
            return(CreateOkResponse(messege, bookingResult.Result));
        }
        public async Task <HttpResponseMessage> GetOutletByID(int id)
        {
            var message = CreateMessageData($"Outlet/{id}", new KeyValuePair <string, string>("outletID", id.ToString()));
            var outlet  = await _outletService.GetOutletById(id);

            if (!outlet.IsSuccess)
            {
                return(CreateValidationErrorResponse(message, new ValidationResult(outlet.message)));
            }
            if (outlet.Result == null)
            {
                return(CreateNotFoundResponse(message, Validation.FileNotFound));
            }
            return(CreateOkResponse(message, outlet.Result));
        }
Пример #3
0
        public ActionResult Outlet(int?id)
        {
            OutletModel outletModel = new OutletModel();

            if (UserRolePermissionForPage.Add == true || UserRolePermissionForPage.Edit == true)
            {
                if (id > 0)
                {
                    int outletId = Convert.ToInt32(id);
                    outletModel = _iOutletService.GetOutletById(outletId);
                    outletModel.OriginalStoreId = outletModel.StoreId;
                }
                outletModel.StoreList = _iDropDownService.GetStoreList();

                return(View(outletModel));
            }
            else
            {
                return(RedirectToAction("NotFound", "Error"));
            }
        }