//Hotel's actions private void doHotel() { Model.Hotel mAirport = new Model.Hotel(); Controller.Hotel cAirport = new Controller.Hotel(); if (cmbHotelAction.SelectedIndex == 0)//insert { MessageBox.Show("Please, choose an action!"); } else if (cmbHotelAction.SelectedIndex == 1)//insert { saveHotel(); } else if (cmbHotelAction.SelectedIndex == 2)//delete { int select = dgvAirport.CurrentCell.RowIndex; mAirport.id = Convert.ToInt32(dgvHotel.Rows[select].Cells["cHotelId"].Value.ToString()); cAirport = new Controller.Hotel(mAirport); cAirport.delete(); refreshHotel(); } else if (cmbHotelAction.SelectedIndex == 3)//update { dgvHotel.Enabled = true; saveHotel(); } else if (cmbHotelAction.SelectedIndex == 4)//refresh { refreshHotel(); } }
public PaquetePageMVVM(Model.Destino item, Model.Hotel Hitem, Model.PickerList Pick, string Precio, bool CheckTransfer, bool CkAsistencia, bool CkBolso, bool CkTrasladoCasa, bool CkValija, DateTime Salida, DateTime Llegada, Model.PickerList Cia, Model.PickerList Escala, Model.PickerList Shs, Model.PickerList ShsV, Model.PickerList Lhs , Model.PickerList LhsV, Model.PickerList Smin, Model.PickerList SminV, Model.PickerList Lmin, Model.PickerList LminV) { _item = item; _itemH = Hitem; _pick = Pick; _precio = Precio; _checktransfer = CheckTransfer; _ckasistencia = CkAsistencia; _ckbolso = CkBolso; _ckvalija = CkValija; _cktrasladocasa = CkTrasladoCasa; _salida = Salida; _llegada = Llegada; _cia = Cia; _escala = Escala; _shs = Shs; _shsv = ShsV; _lhs = Lhs; _lhsv = LhsV; _smin = Smin; _sminv = SminV; _lmin = Lmin; _lminv = LminV; }
//saves an hotel private void saveHotel() { try { if (!cmbHotelByLocation.Enabled) { Model.Hotel mAirport = new Model.Hotel(); int select = dgvAirport.CurrentCell.RowIndex; mAirport.name = dgvHotel.Rows[select].Cells["cHotelName"].Value.ToString(); mAirport.roomAmount = Convert.ToInt32(dgvHotel.Rows[select].Cells["cHotelRooms"].Value.ToString()); mAirport.id = Convert.ToInt32(dgvHotel.Rows[select].Cells["cHotelId"].Value.ToString()); mAirport.idPlace = Convert.ToInt32(dgvHotel.Rows[select].Cells["cHotelPlace"].Value.ToString()); Controller.Hotel cAirport = new Controller.Hotel(mAirport); cAirport.insert(); refreshHotel(); return; } else { Model.Hotel mAirport = new Model.Hotel(); mAirport.name = dgvHotel.Rows[dgvHotel.Rows.Count - 1].Cells["cHotelName"].Value.ToString(); mAirport.roomAmount = Convert.ToInt32(dgvHotel.Rows[dgvHotel.Rows.Count - 1].Cells["cHotelRooms"].Value.ToString()); mAirport.idPlace = Convert.ToInt32(cmbHotelByLocation.SelectedValue);; Controller.Hotel cAirport = new Controller.Hotel(mAirport); cAirport.insert(); } refreshHotel(); } catch { } }
private Model.Hotel FillImageUri(Model.Hotel model) { foreach (var item in model.Images) { item.URI = "https://hotelmanagementsystem.blob.core.windows.net/images/" + ImageExtension.GenerateURI(1, item.HotelImageId, item.Name); } return(model); }
public BuscarHabitacion(Reserva reserva, Model.Hotel hotel, DateTime desde, DateTime hasta) { InitializeComponent(); _hotel = hotel; _desde = desde; _hasta = hasta; _reserva = reserva; InitValues(); }
//Get Hotel list public List <Model.Hotel> GetAllHotel() { var entities = _dbContext.Hotels.ToList(); List <Model.Hotel> list = new List <Model.Hotel>(); if (entities != null) { foreach (var item in entities) { Model.Hotel hotel = new Model.Hotel(); hotel.Id = item.Id; hotel.Name = item.Name; hotel.Address = item.Address; hotel.City = item.City; hotel.Pincode = item.Pincode; hotel.ContactNumber = item.ContactNumber; hotel.ContactPerson = item.ContactPerson; hotel.IsActive = item.IsActive; hotel.CreatedDate = item.CreatedDate; hotel.CreatedBy = item.CreatedBy; hotel.Rooms = new List <Model.Room>(); foreach (var room in item.Rooms) { Model.Room hotelroom = new Model.Room(); hotelroom.Id = room.Id; hotelroom.HotelId = room.HotelId; hotelroom.Name = room.Name; hotelroom.Price = room.Price; hotelroom.IsActive = room.IsActive; hotelroom.CreatedBy = room.CreatedBy; hotelroom.CreatedDate = room.CreatedDate; hotelroom.CategoryId = room.CategoryId; hotelroom.Bookings = new List <Model.Booking>(); foreach (var booking in room.Bookings) { Model.Booking hotelroombooking = new Model.Booking(); hotelroombooking.Id = booking.Id; hotelroombooking.RoomId = booking.RoomId; hotelroombooking.Id = booking.Id; hotelroombooking.BookingDate = booking.BookingDate; hotelroombooking.BookingStatusId = booking.BookingStatusId; hotelroom.Bookings.Add(hotelroombooking); } hotel.Rooms.Add(hotelroom); } list.Add(hotel); } } List <Model.Hotel> SortedList = list.OrderBy(o => o.Name).ToList(); return(SortedList); }
private Model.Hotel MapFormDataToModel(Dictionary <string, string> formValues) { Model.Hotel model = new Model.Hotel(); model.Name = formValues["name"]; model.Description = formValues["description"]; model.Address = formValues["address"]; model.Country = formValues["country"]; model.City = formValues["city"]; model.Status = Convert.ToBoolean(formValues["status"]); model.Stars = Convert.ToInt16(formValues["stars"]); model.IsFeatured = Convert.ToBoolean(formValues["isFeatured"]); model.FeaturedFrom = string.IsNullOrWhiteSpace(formValues["featuredFrom"]) && model.IsFeatured == false ? DateTime.MinValue : Extensions.Extensions.ConvertStringToDateTime(formValues["featuredFrom"]); model.FeaturedTo = string.IsNullOrWhiteSpace(formValues["featuredTo"]) && model.IsFeatured == false ? DateTime.MinValue : Extensions.Extensions.ConvertStringToDateTime(formValues["featuredTo"]); return(model); }
public async Task <ActionResult <Model.Hotel> > PostHotel() { //** store request in variable var _request = Request; var _formValues = _request.Form.ToDictionary(x => x.Key, x => x.Value.ToString()); Model.Hotel model = MapFormDataToModel(_formValues); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _repo.Insert(model); //** Save Image entries in Database and upload.... var files = _request.Form.Files; if (files != null && files.Count > 0) { IEnumerable <Images> imagesList = MapImagesFormDataToModelAndSave(files, model); await _repo.SaveAll(); try { await _imageService.Upload(imagesList); } catch (Exception ex) { _repo.Delete(model); _imagesRepo.DeleteRange(imagesList); await _repo.SaveAll(); return(BadRequest(ex.Message)); } } else { await _repo.SaveAll(); } return(Ok()); }
public async Task <ActionResult <Model.Hotel> > PutHotel([FromBody] Model.Hotel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var hotel = await _repo.Get(model.Id); if (hotel == null) { return(NotFound($"Hotel with id {model.Id} not found.")); } if (model.IsFeatured) { model.FeaturedFrom = Extensions.Extensions.ConvertStringToDateTime(model.FeaturedFrom.ToString()); model.FeaturedTo = Extensions.Extensions.ConvertStringToDateTime(model.FeaturedTo.ToString()); } else { model.FeaturedFrom = DateTime.MinValue; model.FeaturedTo = DateTime.MinValue; } _repo.Update(model); try { await _repo.SaveAll(); }catch (Exception ex) { throw ex; } return(model); //return CreatedAtAction(nameof(Hotel), new { id = hotel.Id }, null); }
private bool NoExisteHotelEnUsuario(Model.Hotel hotel) { return(_editObject == null || !_editObject.HotelesAsignados.Exists(r => r.Id == hotel.Id)); }
private IEnumerable <Images> MapImagesFormDataToModelAndSave(IFormFileCollection files, Model.Hotel model) { List <Images> _imageList = new List <Images>(); foreach (var file in files) { Images image = new Images(); image.Name = file.FileName; image.Size = (Math.Round(((decimal)file.Length / (1024 * 1024)), 8)); image.Extension = Path.GetExtension(file.FileName); image.Hotel = model; image.ImageType = (int)ImageType.HotelImage; image.Image = file; _imageList.Add(image); _imagesRepo.Insert(image); } return(_imageList); }
public Hotel(Model.Hotel hotel) { this.hotel = hotel; }
public Hotel() { this.hotel = new Model.Hotel(); }
//Add a hotel public string CreateHotel(Model.Hotel hotel) { try { if (hotel != null) { Database.Hotel hoteldb = new Database.Hotel(); //hoteldb.Id = hotel.Id; hoteldb.Name = hotel.Name; hoteldb.Address = hotel.Address; hoteldb.City = hotel.City; hoteldb.Pincode = hotel.Pincode; hoteldb.ContactNumber = hotel.ContactNumber; hoteldb.ContactPerson = hotel.ContactPerson; hoteldb.IsActive = hotel.IsActive; hoteldb.CreatedDate = hotel.CreatedDate; hoteldb.CreatedBy = hotel.CreatedBy; List <Database.Room> hotelrooms = new List <Database.Room>(); foreach (var room in hotel.Rooms) { Database.Room hotelroom = new Database.Room(); //hotelroom.Id = room.Id; hotelroom.HotelId = room.HotelId; hotelroom.Name = room.Name; hotelroom.Price = room.Price; hotelroom.IsActive = room.IsActive; hotelroom.CreatedBy = room.CreatedBy; hotelroom.CreatedDate = room.CreatedDate; hotelroom.CategoryId = room.CategoryId; //hotelroom.Bookings = new List<Model.Booking>(); List <Database.Booking> hotelroombookings = new List <Database.Booking>(); foreach (var booking in room.Bookings) { Database.Booking hotelroombooking = new Database.Booking(); //hotelroombooking.Id = booking.Id; hotelroombooking.RoomId = booking.RoomId; hotelroombooking.Id = booking.Id; hotelroombooking.BookingDate = booking.BookingDate; hotelroombooking.BookingStatusId = booking.BookingStatusId; hotelroombookings.Add(hotelroombooking); } hotelroom.Bookings = hotelroombookings; hotelrooms.Add(hotelroom); } hoteldb.Rooms = hotelrooms; _dbContext.Hotels.Add(hoteldb); _dbContext.SaveChanges(); return("Successfully added!"); } return("Model is not added!"); } catch (Exception ex) { return(ex.Message); } throw new NotImplementedException(); }