public HallViewModel GetHallDetails(int id) { try { Halls halls = _context.Halls .Where(x => x.HallId == id) .Include(x => x.Student) .FirstOrDefault(); HallViewModel model = new HallViewModel { HallID = halls.HallId, HallName = halls.HallName, KeyReturned = halls.KeyReturned, IsOwing = halls.IsOwing, StudentID = halls.StudentId, FullName = halls.Student.FullName, StudentIndexList = new SelectList(_studentService.GetStudents(), "StudentID", "FullName", halls.HallId), // StudentDepartList = new SelectList(_studentService.GetStudents(), "StudentID", "StudentId", fees.FeeId) }; return(model); } catch (Exception) { throw; } }
public ActionResult ChangeSeatsNumber() { HallViewModel vm = new HallViewModel(); vm.Hall = new Hall(); HallDal dal = new HallDal(); string HallNameValue = Request.Form["txtHallName"]; int _SeatsNumber = 0; if (Request.Form["HallSeatsNumber"] != null) { _SeatsNumber = int.Parse(Request.Form["HallSeatsNumber"]); } if (HallNameValue != null) { Hall addHall = dal.Halls.First(h => h.HallName == HallNameValue); addHall.SeatsNumber = _SeatsNumber; dal.SaveChanges(); vm.Halls = dal.Halls.ToList <Hall>(); return(View(vm)); } vm.Halls = dal.Halls.ToList <Hall>(); return(View(vm)); }
public async Task RemoveAsync(HallViewModel hallIn) { if (hallIn.Photo?.Id != null) { await _gridFS.DeleteAsync(ObjectId.Parse(hallIn.Photo.Id)); } foreach (var stand in hallIn.Stands) { if (stand.Photo?.Id != null) { await _gridFS.DeleteAsync(ObjectId.Parse(stand.Photo.Id)); } foreach (var exhibit in stand.Exhibits) { if (exhibit.Photos != null && exhibit.Photos?.Count != 0) { foreach (var photo in exhibit.Photos) { if (photo?.Id != null) { await _gridFS.DeleteAsync(ObjectId.Parse(photo.Id)); } } } } } await _halls.DeleteOneAsync(hall => hall.Id.Equals(hallIn.Id)); }
public ActionResult SubmitHall() { HallViewModel vm = new HallViewModel(); Hall MyHall = new Hall() { ID = Request.Form["Hall.ID"], HallName = Request.Form["Hall.HallName"], SeatsNumber = int.Parse(Request.Form["Hall.SeatsNumber"]) }; HallDal dal = new HallDal(); if (ModelState.IsValid) { dal.Halls.Add(MyHall); dal.SaveChanges(); vm.Hall = new Hall(); } else { vm.Hall = MyHall; } vm.Halls = dal.Halls.ToList <Hall>(); return(View("AddHall", vm)); }
public ActionResult CreateHall(HallViewModel hallView, HttpPostedFileBase Image) { if (ModelState.IsValid & Image != null) { byte[] imageData = null; using (var binaryReader = new BinaryReader(Image.InputStream)) { imageData = binaryReader.ReadBytes(Image.ContentLength); } var hall = new BanquetingHall { Id = Guid.NewGuid().ToString(), CountPlace = int.Parse(hallView.CountPlace), Price = hallView.Price, Name = hallView.Name, Hotel = db.Hotels.Find(hallView.HotelId), ImageData = imageData, Status = hallView.Status, Description = hallView.Description }; db.BanquetingHall.Add(hall); db.SaveChanges(); TempData["Message"] = "Зал успешно добавлен."; return(RedirectToAction("Index", "Admin")); } TempData["Message"] = "Ошибка добавления."; return(RedirectToAction("Index", "Admin")); }
public ActionResult EditHall() { HallViewModel hvm = new HallViewModel(); HallsDal dal = new HallsDal(); hvm.Halls = dal.Halls.ToList <Hall>(); return(View("ShowDetails", hvm)); }
public ActionResult EditHall(string Id) { var model = new HallViewModel(); model.Hall = HallService.GetHallById(Id); return(PartialView(model)); }
public ActionResult CreateHall([FromBody] HallViewModel model) { // model.Purpose=m var hallmanager = new Hallmanager(uow); hallmanager.CreateHall(model); return(Ok()); }
public HallViewModel Create() { HallViewModel model = new HallViewModel(); model.StudentIndexList = new SelectList(_studentService.GetStudents(), "StudentID", "FullName"); return(model); }
public async Task <string> Create(HallViewModel hall, IFormFile file) { if (file != null) { await _formFileToByteConverterService.ConvertAsync(file, hall); } hall.Stands = new List <StandViewModel>(); return(await _hallsRepository.CreateAsync(hall)); }
public ActionResult HallGallery(MovieViewModel model) { HallDal Halldal = new HallDal(); HallViewModel mvm = new HallViewModel(); List <Hall> HALLS = Halldal.Halls.ToList(); mvm.Hall = new Hall(); mvm.Halls = HALLS; return(View(mvm)); }
public ActionResult AddHall() { HallDal dal = new HallDal(); HallViewModel vm = new HallViewModel(); List <Hall> Halls = dal.Halls.ToList <Hall>(); vm.Hall = new Hall(); vm.Halls = Halls; return(View(vm)); }
public ActionResult Edit([Bind(Include = "Id,Name,RowAmount,ColumnAmoun,CinemaId")] HallViewModel hallViewModel) { if (!ModelState.IsValid) { return(View(hallViewModel)); } HallDomainModel hallDomainModel = Mapper.Map <HallViewModel, HallDomainModel>(hallViewModel); _hallService.Update(hallDomainModel); return(RedirectToAction("Index")); }
public ActionResult Create([FromJson] HallViewModel hallViewModel) { if (!ModelState.IsValid) { return(View(hallViewModel)); } HallDomainModel hallDomainModel = Mapper.Map <HallViewModel, HallDomainModel>(hallViewModel); _hallService.Add(hallDomainModel); return(RedirectToAction("Details", "Cinema", new { id = hallDomainModel.CinemaId })); }
public async Task ConvertAsync(IFormFile file, HallViewModel hall) { using (var memoryStream = new MemoryStream()) { await file.CopyToAsync(memoryStream); if (hall.Photo == null) { hall.Photo = new PhotoInfo(); } hall.Photo.Photo = memoryStream.ToArray(); } }
public async Task <string> CreateAsync(HallViewModel hall) { if (hall.Photo?.Photo != null) { ObjectId id = await _gridFS.UploadFromBytesAsync(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fffffff"), hall.Photo.Photo); hall.Photo.Id = id.ToString(); hall.Photo.Photo = null; } hall.Id = ObjectId.GenerateNewId().ToString(); await _halls.InsertOneAsync(hall); return(hall.Id); }
public ViewResult Hall(int playId) { HallDTO hallDTO = theatreService.GetHall(playId); var mapperHall = new MapperConfiguration(cfg => cfg.CreateMap <HallDTO, HallViewModel>()).CreateMapper(); HallViewModel hallVM = mapperHall.Map <HallDTO, HallViewModel>(hallDTO); IEnumerable <PlaceDTO> placeDTOs = orderService.GetPlaces(hallDTO.HallId); var mapperPlace = new MapperConfiguration(cfg => cfg.CreateMap <PlaceDTO, PlaceViewModel>()).CreateMapper(); List <PlaceViewModel> placesVM = mapperPlace.Map <IEnumerable <PlaceDTO>, List <PlaceViewModel> >(placeDTOs); placesVM.Sort(new PlaceComparator()); return(View((hallVM, placesVM as IEnumerable <PlaceViewModel>))); }
public ActionResult ShowDetails(string hallName) { HallsDal dal = new HallsDal(); HallViewModel hvm = new HallViewModel(); hvm.Hall = dal.Halls.Find(hallName); hvm.Halls = dal.Halls.ToList <Hall>(); //Hall editHall = dal.Halls.Find(hallName); if (Request.Form["HallName"] == null) { return(RedirectToAction("MyPage", "Home")); } return(View(hvm)); }
public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HallDomainModel hallDomainModel = _hallService.ReadById(id); if (hallDomainModel == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } HallViewModel hallViewModel = Mapper.Map <HallDomainModel, HallViewModel>(hallDomainModel); return(View(hallViewModel)); }
public ActionResult Create(HallViewModel model) { try { bool result = _hallService.AddHalls(model); if (result) { return(RedirectToAction(nameof(Index))); } throw new Exception(); } catch { ModelState.AddModelError(string.Empty, "Ooops! Something went wrong!"); return(View()); } }
public static HallViewModel GetHallByScheduleId(int id) { var hall = new HallViewModel(); var sqlExpression = string.Format("SELECT id, count_row FROM halls WHERE id = (SELECT id_hall FROM schedule WHERE id_schedule = {0})", id); void addValues(NpgsqlDataReader reader) { var hallId = (int)reader.GetValue(0); var rowCount = Convert.ToInt16(reader.GetValue(1)); hall.HallNumber = hallId; hall.RowCount = rowCount; } DAOFactory.ToHandleRequest(sqlExpression, addValues); hall.SeatsRowCount = GetSeatsRowCountByHallId(hall.HallNumber, hall.RowCount); return(hall); }
public ActionResult Delete(int id, HallViewModel model) { try { bool result = _hallsClear.DeleteHalls(id); if (result) { return(RedirectToAction(nameof(Index))); } throw new Exception(); } catch { ModelState.AddModelError(string.Empty, "Ooops! Something went wrong!"); return(View()); } }
public async Task UpdateAsync(string id, HallViewModel hallIn) { hallIn.Id = id; if (!string.IsNullOrEmpty(hallIn.Photo?.Id)) { await _gridFS.DeleteAsync(ObjectId.Parse(hallIn.Photo.Id)); } if (hallIn.Photo?.Photo != null) { ObjectId photoId = await _gridFS.UploadFromBytesAsync(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fffffff"), hallIn.Photo.Photo); hallIn.Photo.Id = photoId.ToString(); hallIn.Photo.Photo = null; } else { hallIn.Photo = null; } await _halls.ReplaceOneAsync(hall => hall.Id.Equals(id), hallIn); }
public ViewResult NewHall(HallViewModel model) { if (!this.ModelState.IsValid) { return(this.View("NewHall", model)); } var hall = new Hall { Color = model.Color, Name = model.Name }; // TODO: process google entries this.hallsRepository.Add(hall); this.hallsRepository.Save(); var response = new NewHallSuccess { }; return(this.View("NewHallSuccess", response)); }
public async Task Edit(HallViewModel hall, byte[] photo, IFormFile file) { var initialHall = await _hallsRepository.GetAsync(hall.Id); hall.Stands = initialHall.Stands; if (initialHall.Photo != null) { hall.Photo = initialHall.Photo; if (photo == null) { hall.Photo.Photo = null; } } if (file != null) { await _formFileToByteConverterService.ConvertAsync(file, hall); } await _hallsRepository.UpdateAsync(hall.Id, hall); }
public void CreateHall(HallViewModel model) { var hall = uow.Halls.FindByName(model.Hallname); if (hall != null) { throw new Exception("Hall with this name already exist"); } var entity = model.Create(); //context.Halls.AddOrUpdate(entity); //context.SaveChanges(); uow.Halls.Add(entity); uow.commit(); //var deptId = result.Result; //var result1 = _db.SaveChanges(); //if (result1.Succeeded == false) //{ // throw new Exception(result1.Message); //} }
public bool UpdateHalls(HallViewModel model) { try { Halls halls = _context.Halls.Where(x => x.HallId == model.HallID).FirstOrDefault(); halls.HallId = model.HallID; halls.HallName = model.HallName; halls.KeyReturned = model.KeyReturned; halls.IsOwing = model.IsOwing; halls.StudentId = model.StudentID; _context.Halls.Update(halls); _context.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool AddHalls(HallViewModel model) { try { Halls halls = new Halls { HallId = model.HallID, HallName = model.HallName, KeyReturned = model.KeyReturned, IsOwing = model.IsOwing, StudentId = model.StudentID }; _context.Halls.Add(halls); _context.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public HallViewModel GetSeats(int MovieId) { MovieDal temp = new MovieDal(); Movie movie = (from x in temp.Movies where x.id.Equals(MovieId) select x).ToList <Movie>()[0]; HallDal halldal = new HallDal(); string num = (from x in halldal.Halls where x.HallId.Equals(movie.HallId) select x.NumSeats).ToList <string>()[0]; TicketDal dal = new TicketDal(); HallViewModel cvm = new HallViewModel(); List <string> halls = (from x in dal.Tickets where x.HallId.Equals(movie.HallId) && x.date.Equals(movie.date) && x.time.Equals(movie.time) select x.seat).ToList <string>(); cvm.halls = halls; Session["MovieName"] = movie.MovieName; TempData["date"] = movie.date; TempData["time"] = movie.time; TempData["HallId"] = movie.HallId; TempData["price"] = movie.price; TempData["MovieId"] = movie.id; TempData["NumSeats"] = num; return(cvm); }
public ActionResult Platform(int id) { using (var db = new EventeamContext()) { var platform = db.Platforms.FirstOrDefault(p => p.PlatformID == id); if (platform != null) { var photos = _imagesService.GetPlatformPhotos(platform.FolderName, platform.Name); var mainPhoto = _imagesService.FilterPlatformMainPhoto(photos); var platformPhotos = _imagesService.FilterPlatformPhotos(photos); var content = new PlatformViewModel { PlatformId = platform.PlatformID, Name = platform.Name, CityName = platform.City.Name, LevelName = platform.Level.Name, LocationName = platform.Location.Name, Geography = platform.Geography, Address = platform.Address, Subway = platform.Subway, DistanceRailwayStation = platform.DistanceRailwayStation, DistanceAirportBorispil = platform.DistanceAirportBorispil, DistanceAirportZhulyany = platform.DistanceAirportZhulyany, Site = platform.Site, HallsCount = platform.HallsCount, HallCapacity = platform.HallCapacity, RestaurantsCount = platform.RestaurantsCount, BanquetCapacity = platform.BanquetCapacity, BuffetCapacity = platform.BuffetCapacity, MainPhoto = mainPhoto, PlatformPhotos = platformPhotos, }; var hotel = db.Hotels.FirstOrDefault(h => h.PlatformID == id); if (hotel != null) { content.Hotel = new HotelViewModel { HotelId = hotel.HotelID, CategoryName = hotel.HotelCategory.Name, Name = hotel.Name, Site = hotel.Site, RoomCount = hotel.RoomCount, Capacity = hotel.Capacity, Entertainment = hotel.Entertainment, Rehabilitation = hotel.Rehabilitation, Parking = hotel.Parking, Internet = hotel.Internet, Other = hotel.Other }; if (hotel.Rooms.Any()) { content.Hotel.Rooms = new List <RoomViewModel>(); foreach (var r in hotel.Rooms) { var c = new RoomViewModel { RoomId = r.RoomID, Name = r.Name, RoomCategoryName = r.RoomCategory.Name, RoomTypeName = r.RoomType.Name, Quantity = r.Quantity }; content.Hotel.Rooms.Add(c); } } } var restaurants = db.Restaurants.Where(p => p.PlatformID == id); if (restaurants.Any()) { content.Restaurants = new List <RestaurantViewModel>(); foreach (var r in restaurants) { var c = new RestaurantViewModel { RestaurantId = r.RestaurantID, Name = r.Name, Type = r.RestaurantType.Name, ClassificationName = r.Classification.Name, KitchenName = r.Kitchen.Name, Banquet = r.Banquet, Buffet = r.Buffet, TotalSquare = r.TotalSquare, Seating = r.Seating }; content.Restaurants.Add(c); } } var halls = db.Halls.Where(p => p.PlatformID == id); if (halls.Any()) { content.Halls = new List <HallViewModel>(); foreach (var h in halls) { var c = new HallViewModel { HallId = h.HallID, Name = h.Name, TotalSquare = h.TotalSquare, Theater = h.Theater, Class = h.Class, PPlanting = h.PPlanting, MeetingRoom = h.MeetingRoom, Banquet = h.Banquet, Buffet = h.Buffet, Equipment = h.Equipment }; content.Halls.Add(c); } } return(View(content)); } return(HttpNotFound()); } }