Ejemplo n.º 1
0
        public ActionResult Delete(int Id)
        {
            var model     = _service.GetBookingById(Id);
            var viewModel = new BookingCreateModel(model);

            return(PartialView("_Delete", viewModel));
        }
Ejemplo n.º 2
0
        public ActionResult Detail(int ID)
        {
            var booking   = _service.GetBookingById(ID);
            var viewModel = new BookingCreateModel(booking);

            return(PartialView("_Detail", viewModel));
        }
Ejemplo n.º 3
0
        public JsonResult Edit(int ID)
        {
            var json    = new JsonResult();
            var user    = "******";
            var role    = RoleManager.Roles.Where(r => r.Name.ToLower().Contains(user.ToLower())).Single();
            var users   = UserManager.Users.Where(u => u.Roles.Any(r => r.RoleId.Contains(role.Id))).ToList();
            var booking = _service.GetBookingById(ID);

            if (booking == null)
            {
                json.Data = new { Success = false, Message = "No such booking found" };
            }
            else
            {
                var viewModel = new BookingCreateModel(booking)
                {
                    AccomodationPackages = _serviceAccomodationPackage.GetAllAccomodationPackages(),
                    ApplicationUsers     = users,
                    FromDate             = DateTime.Now.Date,
                    ToDate = DateTime.Now.Date.AddDays(3),
                };
                var view = PartialView("_Action", viewModel);
                json.Data = new { Success = true, View = view };
                json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            }
            return(json);
        }
Ejemplo n.º 4
0
        public ActionResult CheckAvailability(BookingViewModel model)
        {
            //get accomodationPackageID
            var accomodationPackageID = model.AccomodationPackageID.Value;
            //us k against accomodations lena jin ki booking dates formulae pe ho
            //var accomodations = _serviceAccomodation.GetAllAccomodations().Where(x => x.AccomodationPackageID == accomodationPackageID && !x.Bookings.Any(r => r.ToDate >= model.FromDate && r.FromDate <= model.ToDate)).ToList();
            //accomodations ko list mein save krna krwana..
            var viewModel = new BookingCreateModel();

            return(PartialView("_Detail", viewModel));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> PostAsync(BookingCreateModel value)
        {
            try
            {
                await bookingService.AddBookingAsync(value);

                return(Ok());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 6
0
        public ActionResult Create()
        {
            var user      = "******";
            var role      = RoleManager.Roles.Where(r => r.Name.ToLower().Contains(user.ToLower())).Single();
            var users     = UserManager.Users.Where(u => u.Roles.Any(r => r.RoleId.Contains(role.Id))).ToList();
            var viewModel = new BookingCreateModel()
            {
                AccomodationPackages = _serviceAccomodationPackage.GetAllAccomodationPackages(),
                ApplicationUsers     = users
            };

            return(PartialView("_Action", viewModel));
        }
        public IHttpActionResult CreateBooking(BookingCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                Cad.CreateBooking(User.Identity.GetUserId(), model.FacilityId, model.StartTime, model.EndTime);
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(GetResponse());
        }
        public CreateBookingTests()
        {
            facade = new Mock <IFacade>();

            var username          = "******";
            var identity          = new GenericIdentity(username, "");
            var nameIdentityClaim = new Claim(ClaimTypes.NameIdentifier, username);

            identity.AddClaim(nameIdentityClaim);

            var principal = new Mock <IPrincipal>();

            principal.Setup(p => p.Identity).Returns(identity);
            principal.Setup(p => p.IsInRole("Tenant")).Returns(true);

            model = new BookingCreateModel()
            {
                EndTime = new DateTime(2016, 12, 25, 23, 59, 00), FacilityId = 3, StartTime = new DateTime(2016, 12, 25, 20, 00, 00)
            };

            controllerContext = new HttpControllerContext {
                RequestContext = { Principal = principal.Object }
            };
        }
Ejemplo n.º 9
0
        public JsonResult Save(BookingCreateModel model)
        {
            var         json    = new JsonResult();
            var         error   = "";
            var         result  = false;
            List <long> roomIds = !string.IsNullOrEmpty(model.RoomIds) ? model.RoomIds.Split(',').Select(x => long.Parse(x)).ToList() : new List <long>();
            var         rooms   = _serviceAccomodation.GetAccomodationsbyId(roomIds);
            Bookings    booking;

            if (model.ID == 0)
            {
                booking = new Bookings();
                booking.NumberOfAdults   = model.NumberOfAdults.Value;
                booking.NumberOfChildren = model.NumberOfChildren.Value;
                booking.ToDate           = model.ToDate;
                booking.FromDate         = model.FromDate;
                booking.BookingStatusID  = 0;
                booking.BookingNumber    = GetBookingNumber();
                booking.BookingDate      = DateTime.Now;
                booking.UserID           = model.UserID;
                booking.Duration         = model.Duration.Value;
                booking.BookedRooms      = new List <BookedRooms>();
                booking.BookedRooms.AddRange(rooms.Select(x => new BookedRooms()
                {
                    AccomodationID = x.ID
                }));
            }
            else
            {
                booking                  = _service.GetBookingById(model.ID.Value);
                booking.ID               = model.ID.Value;
                booking.NumberOfAdults   = model.NumberOfAdults.Value;
                booking.NumberOfChildren = model.NumberOfChildren.Value;
                booking.ToDate           = model.ToDate;
                booking.FromDate         = model.FromDate;
                booking.BookingStatusID  = model.BookingStatusID.Value;
                booking.UserID           = model.UserID;
                booking.Duration         = model.Duration.Value;
                booking.BookedRooms.Clear();
                booking.BookedRooms.AddRange(rooms.Select(x => new BookedRooms()
                {
                    AccomodationID = x.ID, BookingID = booking.ID
                }));
            }
            try
            {
                result = _service.SaveBookings(booking);
            }
            catch (Exception exp)
            {
                error = exp.Message.ToString() + " " + exp.InnerException.InnerException.Message.ToString();
            }
            if (result)
            {
                json.Data = new { Success = true, Link = Url.Action("Listing", "Booking"), Message = Status.Successfull };
            }
            else
            {
                json.Data = new { Success = false, Link = Url.Action("Listing", "Booking"), Message = Status.Failed + " " + error };
            }
            return(json);
        }