public async Task <IActionResult> Edit(int id, [Bind("CurrencyId,CurrencyCode,CurrencyName,IsActive")] Currency currency)
        {
            if (id != currency.CurrencyId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(currency);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CurrencyExists(currency.CurrencyId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(currency));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("BookingRoomId,BookingCode,ClientId,RoomId,CheckInDate,CheckOutDate,UniqueCode")] BookingRoom bookingRoom)
        {
            if (id != bookingRoom.BookingRoomId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bookingRoom);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookingRoomExists(bookingRoom.BookingRoomId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoomId"] = new SelectList(_context.Set <Room>(), "RoomId", "RoomName", bookingRoom.RoomId);
            return(View(bookingRoom));
        }
        public void Put(int id, [FromBody] Amenities p_oAmenities)
        {
            bool bIsSuccess = false;

            using (var oTrans = db.Database.BeginTransaction())
            {
                try
                {
                    Amenities oAmenitiesUpdate = db.Amenities.Find(id);

                    oAmenitiesUpdate.AmenitiesName = p_oAmenities.AmenitiesName;
                    oAmenitiesUpdate.IsActive      = p_oAmenities.IsActive;

                    db.Update(oAmenitiesUpdate);
                    bIsSuccess = db.SaveChanges() > 0 ? true : false;
                }
                catch (Exception Ex)
                {
                    oTrans.Rollback();
                }
                finally
                {
                    if (bIsSuccess)
                    {
                        oTrans.Commit();
                    }
                }
            }
        }
예제 #4
0
        public void Put(int id, [FromBody] BookingRoom p_oBookingRoom)
        {
            bool bIsSuccess = false;

            using (var oTrans = db.Database.BeginTransaction())
            {
                try
                {
                    BookingRoom oBookingRoomUpdate = db.BookingRoom.Find(id);

                    oBookingRoomUpdate.BookingCode  = p_oBookingRoom.BookingCode;
                    oBookingRoomUpdate.ClientId     = p_oBookingRoom.ClientId;
                    oBookingRoomUpdate.RoomId       = p_oBookingRoom.RoomId;
                    oBookingRoomUpdate.CheckInDate  = p_oBookingRoom.CheckInDate;
                    oBookingRoomUpdate.CheckOutDate = p_oBookingRoom.CheckOutDate;
                    oBookingRoomUpdate.UniqueCode   = p_oBookingRoom.UniqueCode;

                    db.Update(oBookingRoomUpdate);
                    bIsSuccess = db.SaveChanges() > 0 ? true : false;
                }
                catch (Exception Ex)
                {
                    oTrans.Rollback();
                }
                finally
                {
                    if (bIsSuccess)
                    {
                        oTrans.Commit();
                    }
                }
            }
        }
        public void Put(int id, [FromBody] Hotel p_oHotel)
        {
            bool bIsSuccess = false;

            using (var oTrans = db.Database.BeginTransaction())
            {
                try
                {
                    Hotel oHotelUpdate = db.Hotel.Find(id);

                    oHotelUpdate.HotelName      = p_oHotel.HotelName;
                    oHotelUpdate.Address        = p_oHotel.Address;
                    oHotelUpdate.Latitude       = p_oHotel.Latitude;
                    oHotelUpdate.Longitude      = p_oHotel.Longitude;
                    oHotelUpdate.CommissionRate = p_oHotel.CommissionRate;

                    db.Update(oHotelUpdate);
                    bIsSuccess = db.SaveChanges() > 0 ? true : false;
                }
                catch (Exception Ex)
                {
                    oTrans.Rollback();
                }
                finally
                {
                    if (bIsSuccess)
                    {
                        oTrans.Commit();
                    }
                }
            }
        }
        public void Put(int id, [FromBody] Room p_oRoom)
        {
            bool bIsSuccess = false;

            using (var oTrans = db.Database.BeginTransaction())
            {
                try
                {
                    Room oRoomUpdate = db.Room.Find(id);

                    oRoomUpdate.RoomName     = p_oRoom.RoomName;
                    oRoomUpdate.HotelId      = p_oRoom.HotelId;
                    oRoomUpdate.MaxOccupancy = p_oRoom.MaxOccupancy;
                    oRoomUpdate.NetRate      = p_oRoom.NetRate;
                    oRoomUpdate.SellRate     = p_oRoom.SellRate;
                    oRoomUpdate.CurrencyId   = p_oRoom.CurrencyId;

                    db.Update(oRoomUpdate);
                    bIsSuccess = db.SaveChanges() > 0 ? true : false;
                }
                catch (Exception Ex)
                {
                    oTrans.Rollback();
                }
                finally
                {
                    if (bIsSuccess)
                    {
                        oTrans.Commit();
                    }
                }
            }
        }
예제 #7
0
        public async Task <IActionResult> Edit(int id, [Bind("RoomAmenitiesId,RoomId,AmenitiesId")] RoomAmenities roomAmenities)
        {
            if (id != roomAmenities.RoomAmenitiesId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(roomAmenities);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RoomAmenitiesExists(roomAmenities.RoomAmenitiesId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(roomAmenities));
        }
예제 #8
0
        public void Put(int id, [FromBody] Currency p_oCurrency)
        {
            bool bIsSuccess = false;

            using (var oTrans = db.Database.BeginTransaction())
            {
                try
                {
                    Currency oCurrencyUpdate = db.Currency.Find(id);

                    oCurrencyUpdate.CurrencyCode = p_oCurrency.CurrencyCode;
                    oCurrencyUpdate.CurrencyName = p_oCurrency.CurrencyName;
                    oCurrencyUpdate.IsActive     = p_oCurrency.IsActive;

                    db.Update(oCurrencyUpdate);
                    bIsSuccess = db.SaveChanges() > 0 ? true : false;
                }
                catch (Exception Ex)
                {
                    oTrans.Rollback();
                }
                finally
                {
                    if (bIsSuccess)
                    {
                        oTrans.Commit();
                    }
                }
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("HotelId,HotelName,Address,Latitude,Longitude,CommissionRate")] Hotel hotel)
        {
            if (id != hotel.HotelId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hotel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HotelExists(hotel.HotelId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hotel));
        }
예제 #10
0
        public IActionResult Edit(int id,
                                  vmRoom ovmRoom,
                                  string[] amenitiesChecked
                                  )
        {
            bool bIsSuccess = false;

            int[] iArrAmenitiesIdChecked = new int[amenitiesChecked.Length];

            if (id != ovmRoom.oRoom.RoomId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                using (var oTrans = _context.Database.BeginTransaction())
                {
                    try
                    {
                        _context.Update(ovmRoom.oRoom);
                        _context.SaveChanges();

                        for (int i = 0; i < amenitiesChecked.Length; i++)
                        {
                            iArrAmenitiesIdChecked[i] = Convert.ToInt32(amenitiesChecked[i]);
                        }

                        List <RoomAmenities> oRoomAmenitiesListExisting =
                            _context.RoomAmenities.Where(w => w.RoomId == id).AsNoTracking().ToList();

                        #region Existing Check
                        foreach (RoomAmenities i_oRoomAmenities in oRoomAmenitiesListExisting)
                        {
                            if (!iArrAmenitiesIdChecked.Contains(i_oRoomAmenities.AmenitiesId))
                            {
                                //delete existing
                                int iRoomAmenitiesId = _context.RoomAmenities
                                                       .Where(w => w.RoomId == id && w.AmenitiesId == i_oRoomAmenities.AmenitiesId)
                                                       .Select(s => s.RoomAmenitiesId).FirstOrDefault();

                                RoomAmenities oRoomAmenitiesDeleted = _context.RoomAmenities.Find(iRoomAmenitiesId);
                                _context.RoomAmenities.Remove(oRoomAmenitiesDeleted);
                                _context.SaveChanges();
                            }
                        }
                        #endregion

                        #region Insert New
                        foreach (int i_iAmenitiesId in iArrAmenitiesIdChecked)
                        {
                            RoomAmenities oRoomAmenitiesCheck = _context.RoomAmenities
                                                                .Where(w => w.RoomId == id && w.AmenitiesId == i_iAmenitiesId).FirstOrDefault();
                            if (oRoomAmenitiesCheck == null)
                            {
                                //Add
                                RoomAmenities oRoomAmenitiesAdd = new RoomAmenities();

                                oRoomAmenitiesAdd.RoomId      = id;
                                oRoomAmenitiesAdd.AmenitiesId = i_iAmenitiesId;

                                _context.Add(oRoomAmenitiesAdd);
                                _context.SaveChanges();
                            }
                        }
                        #endregion

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

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