public async Task <IActionResult> PutVisitor(int id, Visitor visitor)
        {
            if (id != visitor.VisitorId)
            {
                return(BadRequest());
            }

            _context.Entry(visitor).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VisitorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutLogin(int id, Login login)
        {
            if (id != login.LoginId)
            {
                return(BadRequest());
            }

            _context.Entry(login).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LoginExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Create(ReservationViewModel reservationVM)
        {
            if (reservationVM.VisitorId == 0)
            {
                var visitors = _dbContext.Visitor.ToList();
                visitors.Insert(0, new Visitor {
                    VisitorId = 0, VisitorName = "Select VIsitorName"
                });
                ViewBag.Visitor = visitors;
                ModelState.AddModelError("VisitorId", "Select Visitor Name");
                return(View(reservationVM));
            }
            if (reservationVM.RoomId == 0)
            {
                var rooms = _dbContext.Room.ToList();
                rooms.Insert(0, new Room {
                    RoomId = 0, RoomNo = "Select RoomNo"
                });
                ViewBag.Room = rooms;
                ModelState.AddModelError("RoomId", "Select Room No");
                return(View(reservationVM));
            }
            if (reservationVM.BillingId == 0)
            {
                var billings = _dbContext.Billing.ToList();
                billings.Insert(0, new Billing {
                    BillingId = 0, BillingType = "Select Billing Type"
                });
                ViewBag.Billings = billings;
                ModelState.AddModelError("BillingId", "Select Billing Type");
                return(View(reservationVM));
            }
            if (ModelState.IsValid)
            {
                if (reservationVM.CheckInDate <= reservationVM.CheckOutDate)
                {
                    var reservation = new Reservation
                    {
                        CheckInDate            = reservationVM.CheckInDate,
                        CheckOutDate           = reservationVM.CheckOutDate,
                        GrandTotal             = reservationVM.GrandTotal,
                        RoomBooked             = reservationVM.RoomBooked,
                        BillingId              = reservationVM.BillingId,
                        RoomId                 = reservationVM.RoomId,
                        VisitorId              = reservationVM.VisitorId,
                        MiscellaneousBillingId = reservationVM.MiscellaneousBillingId
                    };

                    _dbContext.Add(reservation);
                    await _dbContext.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    return(BadRequest("Check Out date must be greater than Checkin date "));
                }
            }
            return(View(reservationVM));
        }
        public async Task <IActionResult> Create([Bind("VisitorName, VisitorAddress, VisitorPhoneNo, VisitorEmail")] Visitor visitor)
        {
            if (ModelState.IsValid)
            {
                _dbContext.Add(visitor);
                await _dbContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(visitor));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,Description")] AccomodationType accomodationType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accomodationType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(accomodationType));
        }
Beispiel #6
0
        public async Task <IActionResult> Create([Bind("RoomNo, RoomType, RoomRate")] Room room)
        {
            if (ModelState.IsValid)
            {
                _dbContext.Add(room);
                await _dbContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(room));
        }
Beispiel #7
0
        public async Task <IActionResult> Create([Bind("LoginId,Username,Password,Usertype")] Login login)
        {
            if (ModelState.IsValid)
            {
                _context.Add(login);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(login));
        }
Beispiel #8
0
        public async Task <IActionResult> Create([Bind("BillingType, BillingDate, BillingAmount, VisitorId")] Billing billing)
        {
            if (ModelState.IsValid)
            {
                _dbContext.Add(billing);
                await _dbContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(billing));
        }
        public async Task <IActionResult> Create([Bind("ID,AccomodationPackageID,FromDate,Duration,NoOfAdults,NoOfChildren,Name,Email,Notes")] Booking booking)
        {
            if (ModelState.IsValid)
            {
                _context.Add(booking);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccomodationPackageID"] = new SelectList(_context.AccomodationPackages, "ID", "Name", booking.AccomodationPackageID);
            return(View(booking));
        }
Beispiel #10
0
        public async Task <IActionResult> Create([Bind("ID,AccomodationPackageID,Name,Description")] Accomodation accomodation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accomodation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccomodationPackageID"] = new SelectList(_context.AccomodationPackages, "ID", "Name", accomodation.AccomodationPackageID);
            return(View(accomodation));
        }
        public async Task <IActionResult> Create([Bind("MiscellaneousBillingId, Food, FoodRate, RoomServiceCharge, ServiceTax, TotalAmount, VisitorId")] MiscellaneousBilling miscellaneousbilling)
        {
            if (miscellaneousbilling.VisitorId == 0)
            {
                var visitors = _dbContext.Visitor.ToList();
                visitors.Insert(0, new Visitor {
                    VisitorId = 0, VisitorName = "Select"
                });
                ViewBag.Visitors = visitors;
                ModelState.AddModelError("VisitorId", "Please select the Visitor Name");
                return(View(miscellaneousbilling));
            }
            if (ModelState.IsValid)
            {
                _dbContext.Add(miscellaneousbilling);
                await _dbContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(miscellaneousbilling));
        }
 public IActionResult Create(AccomodationPackageViewModel model)
 {
     if (!ModelState.IsValid)
     {
         AccomodationPackage newAccomo = new AccomodationPackage
         {
             AccomodationTypeID = model.AccomodationTypeID,
             IMGPackage         = ProcessUploadedFile(model),
             FeePerNight        = model.FeePerNight,
             NoOfRoom           = model.NoOfRoom,
             Name = model.Name,
         };
         _context.AccomodationPackages.Add(newAccomo);
         _context.SaveChangesAsync();
         return(RedirectToAction(nameof(Index)));
     }
     return(View());
 }