Esempio n. 1
0
 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");
     }
 }
Esempio n. 2
0
        // 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));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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("Пожалуйста, заполните все поля");
            }
        }
Esempio n. 5
0
        // 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());
        }
Esempio n. 7
0
 // загрузка объекта 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);
     }
 }
Esempio n. 8
0
        /// <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);
        }
Esempio n. 9
0
        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"));
        }
Esempio n. 12
0
 public ActionResult Create(Hostel h)
 {
     if (ModelState.IsValid)
     {
         db.Hostels.Add(h);
         db.SaveChanges();
         return(RedirectToAction("Index", "Hostel"));
     }
     return(View());
 }
Esempio n. 13
0
 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));
 }
Esempio n. 14
0
        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"));
        }
Esempio n. 16
0
 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));
 }
Esempio n. 17
0
        //
        // GET: /Hostel/Edit/5

        public ActionResult Edit(string id)
        {
            Hostel hs = hostels.GetPlace(id);

            if (hs == null)
            {
                return(HttpNotFound());
            }
            return(View(hs));
        }
Esempio n. 18
0
        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());
        }
Esempio n. 19
0
        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));
        }
Esempio n. 20
0
        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"));
        }
Esempio n. 22
0
 public ActionResult EditConfirmed(Hostel hs)
 {
     try
     {
         // TODO: Add update logic here
         hostels.UpdatePlace(hs);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 23
0
 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);
     }
 }
Esempio n. 25
0
 /// <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
     });
 }
Esempio n. 26
0
        // 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"));
        }
Esempio n. 28
0
        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());
            }
        }
Esempio n. 29
0
        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());
        }