private void addHostelButton_Click(object sender, EventArgs e) { if (hostelTypeComboBox.SelectedIndex >= 0) { Hostel hostel = new Hostel(); hostel.HostelName = hostelNameTextBox.Text; hostel.HostelAddress = hostelAddressTextBox.Text; hostel.HostelType = hostelTypeComboBox.Text; hostel.HostelCapacity = hostelCapacityTextBox.Text; hostel.AdminId = admin.AdminId; if (new HostelDataAccess().CreateHostel(hostel)) { MessageBox.Show("Hostel Added Successfully!", "Success"); hostelsDataGridView.DataSource = new HostelDataAccess().GetHostels(admin.AdminId); } else { MessageBox.Show("Could Not Add Hostel!", "Failed"); } } else { MessageBox.Show("Please Select Hostel Type!", "Failed"); } }
// GET: Orders/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order order = db.Orders.Find(id); if (order == null) { return(HttpNotFound()); } Tour tour = db.Tours.FirstOrDefault(t => t.TourID == order.TourID.Value); StatusOrder statusOrder = db.StatusOrders.FirstOrDefault(s => s.StatusOrderID == order.StatusOrderID.Value); Hostel hostel = db.Hostels.FirstOrDefault(h => h.HostelID == tour.HostelID.Value); dynamic model = new ExpandoObject(); model.Order = order; model.Tour = tour; model.Status = statusOrder.StatusOrderName; model.Hostel = hostel; return(View(model)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tour tour = db.Tours.Find(id); if (tour == null) { return(HttpNotFound()); } TypeTour typeTour = db.TypeTours.Where(t => t.TypeTourID == tour.TypeTourID).FirstOrDefault(); Hostel hostel = db.Hostels.Where(h => h.HostelID == tour.HostelID).FirstOrDefault(); List <ResponseTour> responses = db.ResponseTours.Include(u => u.ApplicationUser).Where(t => t.TourID == id).ToList(); var userId = User.Identity.GetUserId(); dynamic model = new ExpandoObject(); model.tour = tour; model.typeTour = typeTour.TypeTourName; model.hostel = hostel; model.Responses = responses; model.Id = userId; return(View(model)); }
private void CreateUsers() { try { Hostel hostel = new Hostel { LastName = LastNameTextBox.Text.Trim(), FirstName = FirstNameTextBox.Text.Trim(), Patronymic = PatronymicTextBox.Text.Trim(), Group = GroupTextBox.Text.Trim(), AverageMark = double.Parse(AverageMarkTextBox.Text), Income = decimal.Parse(IncomeTextBox.Text), Activities = ActivitiesCheckBox.Checked }; HostelRepository.CreateHostels(hostel); MessageBox.Show("Данные сохранены успешно!"); LoadGridData(); ClearData(); } catch { MessageBox.Show("Пожалуйста, заполните все поля"); } }
// GET: Orders/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order order = db.Orders.Find(id); if (order == null) { return(HttpNotFound()); } Tour tour = db.Tours.FirstOrDefault(t => t.TourID == order.TourID.Value); StatusOrder statusOrder = db.StatusOrders.FirstOrDefault(s => s.StatusOrderID == order.StatusOrderID.Value); Hostel hostel = db.Hostels.FirstOrDefault(h => h.HostelID == tour.HostelID.Value); var userId = User.Identity.GetUserId(); ApplicationUser user = db.Users.FirstOrDefault(u => u.Id == order.UserId); dynamic model = new ExpandoObject(); model.Order = order; model.Tour = tour; model.Status = statusOrder.StatusOrderName; model.Hostel = hostel; model.UserName = user.FirstName + " " + user.LastName; return(View(model)); }
public ActionResult MAddHostels(HostelViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); Hostel hostel = new Hostel(); hostel.Name = collection.HostelName; hostel.Location = collection.HostelLocation; hostel.Details = collection.HostelDetails; hostel.Rent = collection.HostelRent; if (collection.Image != null) { string filename = Path.GetFileNameWithoutExtension(collection.Image.FileName); string ext = Path.GetExtension(collection.Image.FileName); filename = filename + DateTime.Now.Millisecond.ToString(); filename = filename + ext; string filetodb = "/img/Hostels/" + filename; filename = Path.Combine(Server.MapPath("~/img/Hostels"), filename); collection.Image.SaveAs(filename); collection.ImagePath = filetodb; } else { collection.ImagePath = "/img/Hostels/MumtazHall.jpg"; } hostel.ImagePath = collection.ImagePath; db.Hostels.Add(hostel); db.SaveChanges(); return(View()); }
// загрузка объекта Room и данных по Hostel public static Room LoadRoom(int roomId) { using (var context = new HostelModelContainer()) { Room room = context.RoomSet.Single(r => r.Id == roomId); Hostel hostel = room.Hostel; // предзагрузка данных про общежитиеы return(room); } }
/// <summary> /// Deletes the specified hostel. /// </summary> /// <param name="hostel">The hostel.</param> /// <returns> /// the task /// </returns> public async Task Delete(Hostel hostel) { hostel.Deleted = true; await this.hostelRepository.UpdateAsync(hostel); await this.publisher.EntityDeleted(hostel); }
public ActionResult DeleteConfirmed(int id) { Hostel hostel = db.Hostels.Find(id); db.Hostels.Remove(hostel); db.SaveChanges(); return(RedirectToAction("Index")); }
private static void ContextDetached(Hostel hostel) { Hostel local = _context.Set <Hostel>().Local.FirstOrDefault(c => c.Id == hostel.Id); if (local != null) { _context.Entry(local).State = EntityState.Detached; } }
public IHttpActionResult RemoveOldHostel(Hostel oldhosteltoremove) { Hostel gethosteltoremove = unitOfWork.hostels.Get(oldhosteltoremove.Id); gethosteltoremove.IsTerminated = true; unitOfWork.hostels.Update(p => p.Id == gethosteltoremove.Id, gethosteltoremove); unitOfWork.Complete(); return(Ok("Hostel removed Successfully")); }
public ActionResult Create(Hostel h) { if (ModelState.IsValid) { db.Hostels.Add(h); db.SaveChanges(); return(RedirectToAction("Index", "Hostel")); } return(View()); }
public ActionResult Edit([Bind(Include = "ID,Name,Location,OwnerName,Email,Phone")] Hostel hostel) { if (ModelState.IsValid) { db.Entry(hostel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hostel)); }
public ActionResult Rooms_Hostel(int id = 0) ///Команаты выбираемого общежития!!! { Hostel hostel = db.Hostels.Include(s => s.LivingRooms).FirstOrDefault(s => s.Id == id); if (hostel == null) { return(HttpNotFound()); } return(View(hostel)); }
public ActionResult UnApplyForHostel(int id, int idd, Hostel model) { var student = db.Students.Where(c => c.StudentId == idd).FirstOrDefault(); var hostel = db.Hostels.Where(c => c.HostelId == id).SingleOrDefault(); var HostelRel = db.StudentHostelRelations.Where(c => c.HostelId == hostel.HostelId && c.StudentId == student.StudentId).SingleOrDefault(); db.StudentHostelRelations.Remove(HostelRel); db.SaveChanges(); return(RedirectToAction("StudentsList2")); }
public ActionResult Edit([Bind(Include = "HostelID,HostelName,HostelMark,Website")] Hostel hostel) { if (ModelState.IsValid) { db.Entry(hostel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hostel)); }
// // GET: /Hostel/Edit/5 public ActionResult Edit(string id) { Hostel hs = hostels.GetPlace(id); if (hs == null) { return(HttpNotFound()); } return(View(hs)); }
public ActionResult Edit(Hostel h) { if (ModelState.IsValid) { db.Entry(h).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Hostel")); } return(View()); }
public ActionResult Create([Bind(Include = "HostelID,HostelName,HostelMark,Website")] Hostel hostel) { if (ModelState.IsValid) { db.Hostels.Add(hostel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hostel)); }
public ActionResult Create([Bind(Include = "ID,Name,Location,OwnerName,Email,Phone")] Hostel hostel) { if (ModelState.IsValid) { db.Hostels.Add(hostel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hostel)); }
public ActionResult UnApplyForHostel(int id, Hostel model) { var user = UserManager.FindById(User.Identity.GetUserId()); var student = db.Students.Where(c => c.UserId == user.Id).SingleOrDefault(); var hostel = db.Hostels.Where(c => c.HostelId == id).SingleOrDefault(); var HostelRel = db.StudentHostelRelations.Where(c => c.HostelId == id && c.StudentId == student.StudentId).SingleOrDefault(); db.StudentHostelRelations.Remove(HostelRel); db.SaveChanges(); return(RedirectToAction("AppliedHostel")); }
public ActionResult EditConfirmed(Hostel hs) { try { // TODO: Add update logic here hostels.UpdatePlace(hs); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(Hostel hs) { try { // TODO: Add insert logic here hostels.InsertPlace(hs); return(RedirectToAction("Index")); } catch { return(View()); } }
public string AddHostel(Hostel hostel) { try { _context.Hostels.Add(hostel); _context.SaveChanges(); return("SUCCESS ADDED HOSTEL"); } catch (Exception ex) { ModelState.Clear(); return(ex.Message); } }
/// <summary> /// To the model. /// </summary> /// <param name="entity">The entity.</param> /// <returns>the model</returns> public static HostelModel ToModel(this Hostel entity) { return(new HostelModel { Id = entity.Id, Address = entity.Address, Name = entity.Name, CreationDateUtc = entity.CreationDateUtc, Currency = entity.Currency?.ToModel(), Location = entity.Location?.ToModel(), Email = entity.Email, PhoneNumber = entity.PhoneNumber }); }
// GET: Hostels/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Hostel hostel = db.Hostels.Find(id); if (hostel == null) { return(HttpNotFound()); } return(View(hostel)); }
public ActionResult ApplyForHostel(int id, int idd, Hostel model) { var student = db.Students.Where(c => c.StudentId == idd).SingleOrDefault(); var collection = db.Hostels.Where(c => c.HostelId == id).SingleOrDefault(); var HostelRel = new StudentHostelRelation { HostelId = id, StudentId = student.StudentId, }; db.StudentHostelRelations.Add(HostelRel); db.SaveChanges(); return(RedirectToAction("StudentsList3")); }
public ActionResult Nearest5Places(string id) { try { Hostel p = hostels.GetPlace(id); var result = HelpFunctions.LocateHelper <Hostel> .GetNearestFivePlaces(hostels, p); return(View(result)); } catch { return(View()); } }
public ActionResult Create(int id) { Hostel hostel = db.Hostels.FirstOrDefault(h => h.HostelID == id); ResponseHostel response = new ResponseHostel { HostelID = id, UserId = User.Identity.GetUserId(), DateTime = DateTime.Now, Mark = 1, ResponseName = "" }; return(View(response)); }
public ActionResult EditHostel(Hostel hostel) { var findh = _context.Hostels.Find(hostel.HostelId); if (findh != null) { findh.HostelName = hostel.HostelName; findh.Location = hostel.Location; findh.TotalRooms = hostel.TotalStudents; findh.TotalStudents = hostel.TotalStudents; return(RedirectToAction("Index")); } return(View()); }