public async Task <IActionResult> Create([Bind("CurrencyId,CurrencyCode,CurrencyName,IsActive")] Currency currency)
        {
            if (ModelState.IsValid)
            {
                _context.Add(currency);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(currency));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("RoomAmenitiesId,RoomId,AmenitiesId")] RoomAmenities roomAmenities)
        {
            if (ModelState.IsValid)
            {
                _context.Add(roomAmenities);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(roomAmenities));
        }
        public async Task <IActionResult> Create([Bind("AmenitiesId,AmenitiesName,IsActive")] Amenities amenities)
        {
            if (ModelState.IsValid)
            {
                _context.Add(amenities);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(amenities));
        }
        public async Task <IActionResult> Create([Bind("HotelId,HotelName,Address,Latitude,Longitude,CommissionRate")] Hotel hotel,
                                                 string[] RoomId
                                                 )
        {
            if (ModelState.IsValid)
            {
                _context.Add(hotel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hotel));
        }
Exemple #5
0
        // public async Task<IActionResult> Create([Bind("BookingRoomId,BookingCode,ClientId,RoomId,CheckInDate,CheckOutDate,UniqueCode")] BookingRoom bookingRoom)
        public async Task <IActionResult> Create(BookingRoom p_oBookingRoom)
        {
            bool bIsSuccess = false;

            #region Validation
            if (p_oBookingRoom.CheckOutDate <= p_oBookingRoom.CheckInDate)
            {
                ModelState.AddModelError("CheckOutDate", "Check out date must more bigger than check in date");
            }
            #endregion

            if (ModelState.IsValid)
            {
                // _context.Add(p_oBookingRoom);
                // await _context.SaveChangesAsync();
                // return RedirectToAction(nameof(Index));
                using (var oTrans = _context.Database.BeginTransaction())
                {
                    try
                    {
                        p_oBookingRoom.BookingCode = DateTime.Now.ToString("yyyyMMddhhmmssfff");
                        p_oBookingRoom.UniqueCode  = RandomString(7, false);

                        _context.Add(p_oBookingRoom);
                        await _context.SaveChangesAsync();

                        bIsSuccess = true;
                    }
                    catch (Exception Ex)
                    {
                        oTrans.Rollback();
                    }
                    finally
                    {
                        if (bIsSuccess)
                        {
                            oTrans.Commit();
                        }
                    }
                }
            }
            if (bIsSuccess)
            {
                return(RedirectToAction(nameof(Index)));
            }
            return(View(p_oBookingRoom));
        }
Exemple #6
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            bool bIsSuccess = false;

            using (var oTrans = _context.Database.BeginTransaction())
            {
                try
                {
                    List <RoomAmenities> oRoomAmenitiesDeletedList =
                        await _context.RoomAmenities.Where(w => w.RoomId == id).ToListAsync();

                    _context.RoomAmenities.RemoveRange(oRoomAmenitiesDeletedList);
                    await _context.SaveChangesAsync();

                    Room oRoomDeleted = await _context.Room.FindAsync(id);

                    _context.Room.Remove(oRoomDeleted);
                    _context.SaveChangesAsync();

                    bIsSuccess = true;
                }
                catch (Exception Ex)
                {
                    oTrans.Rollback();
                }
                finally
                {
                    if (bIsSuccess)
                    {
                        oTrans.Commit();
                    }
                }
            }

            return(RedirectToAction(nameof(Index)));
        }