Esempio n. 1
0
        public ActionResult Delete(int id)
        {
            try
            {
                TourDao tourDao = new TourDao();
                Tour    tour    = tourDao.GetById(id);

                //System.IO.File.Delete(Server.MapPath("~/uploads/book/" + tour.ImageName));

                /*******POTREBA SMAZAT REZERVACE******/
                ReservationDao      reservationDao = new  ReservationDao();
                IList <Reservation> reservations   = reservationDao.GetAll();

                foreach (Reservation reservation in reservations)
                {
                    if (reservation.Tour.Id == id)
                    {
                        reservationDao.Delete(reservation);
                    }
                }

                tourDao.Delete(tour);

                TempData["message-success"] = "Zajezd " + tour.Name + " byl smazan";
            }
            catch (Exception e)
            {
                throw;
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult Delete(int id)
        {
            try
            {
                TermDao tDao = new TermDao();
                Term    t    = tDao.GetById(id);

                //je treba smazat i vsechny rezervace daneho terminu
                ReservationDao      resDao       = new ReservationDao();
                IList <Reservation> reservations = resDao.GetAllReservationsByTerm(t);
                foreach (Reservation res in reservations)
                {
                    resDao.Delete(res);
                }

                tDao.Delete(t);
                TempData["succes"] = "Termín i jeho rezervace jsou úspěšně smazány.";
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        public static void CapacityCheck(Room r)
        {
            TermDao        tDao   = new TermDao();
            ReservationDao resDao = new ReservationDao();
            IList <Term>   terms  = tDao.GetTermsByRoom(r);

            foreach (Term t in terms)
            {
                //pokud je u nektereho terminu nastavena vetsi kapacita nez je nova maximalni kapacita mistnosti, zmen kapacitu terminu na max.kapacitu mistnosti
                if (r.MaxCapacity < t.Capacity && t.EndTerm > DateTime.Now)
                {
                    int uCount = r.MaxCapacity - (t.Capacity - tDao.GetActualCapacity(t));
                    //pokud je prihlaseno vice lidi nez nova max.kapacita mistnosti, odstran rezervace poslednich prihlasenych
                    if (uCount > 0)
                    {
                        IList <Reservation> reservations = resDao.GetLastReservationByTerm(t, uCount);
                        foreach (Reservation res in reservations)
                        {
                            resDao.Delete(res);
                        }
                    }
                    t.Capacity = r.MaxCapacity;
                    tDao.Update(t);
                }
            }
        }
Esempio n. 4
0
        //pridat upozorneni pro vypsane teminy
        public ActionResult Delete(int id)
        {
            try
            {
                RoomDao rDao = new RoomDao();
                Room    r    = rDao.GetById(id);

                //je zapotřebí smazat nejdrive vsechny terminy v teto mistnosti, a take rezervace na tyto terminy
                TermDao        tDao   = new TermDao();
                ReservationDao resDao = new ReservationDao();
                IList <Term>   terms  = tDao.GetTermsByRoom(r);
                foreach (Term t in terms)
                {
                    IList <Reservation> reservations = resDao.GetAllReservationsByTerm(t);
                    foreach (Reservation res in reservations)
                    {
                        resDao.Delete(res);
                    }
                    tDao.Delete(t);
                }

                rDao.Delete(r);
                TempData["succes"] = "Místnost " + r.Name +
                                     " byla odstraněna, stejně tak i všechny termíny v této místnosti.";
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
        public ActionResult Delete(int id)
        {
            try
            {
                UserDao     uDao        = new UserDao();
                AddressDao  aDao        = new AddressDao();
                FitnessUser fitnessUser = uDao.GetById(id);
                Address     address     = new Address();
                address = fitnessUser.Address;

                //pokud se jedná o trenéra, je třeba smazat jeho termíny, které vede
                if (fitnessUser.Role.Name == "Trenér")
                {
                    TermDao      tDao  = new TermDao();
                    IList <Term> terms = tDao.GetTermsByTrainer(fitnessUser);

                    foreach (Term t in terms)
                    {
                        tDao.Delete(t);
                    }
                }//pokud se jedna o zakaznika, je treba smazat rezervace, na ktere je zapsan
                else if (fitnessUser.Role.Name == "Zákazník")
                {
                    ReservationDao      rDao         = new ReservationDao();
                    IList <Reservation> reservations = rDao.GetAllReservationsByUser(fitnessUser);

                    foreach (Reservation r in reservations)
                    {
                        rDao.Delete(r);
                    }
                }

                if (fitnessUser.SmallImageName != null)
                {
                    System.IO.File.Delete(Server.MapPath("~/Uploads/FitnessUser/" + fitnessUser.SmallImageName));
                }
                if (fitnessUser.BigImageName != null)
                {
                    System.IO.File.Delete(Server.MapPath("~/Uploads/FitnessUser/" + fitnessUser.BigImageName));
                }

                uDao.Delete(fitnessUser);
                aDao.Delete(address);


                TempData["succes"] = "Uživatelský účet byl odstraněn.";

                if (fitnessUser.Login == User.Identity.Name)
                {
                    return(RedirectToAction("Logout", "Home"));
                }
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        public ActionResult Delete(int id)
        {
            try
            {
                ReservationDao rDao = new ReservationDao();

                rDao.Delete(rDao.GetById(id));
                TempData["succes"] = "Rezervace na termín úspěšně zrušena.";
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
        public ActionResult DeleteReservation(int id)
        {
            Reservation existingReservation = _reservationDao.Get(id);

            if (existingReservation == null)
            {
                return(NotFound("Reservation does not exist"));
            }

            bool result = _reservationDao.Delete(id);

            if (result)
            {
                return(NoContent());
            }
            return(StatusCode(500)); //in case DAO has an error in deleting
        }
Esempio n. 8
0
        public ActionResult Cancel(int id)
        {
            try
            {
                // Získání instance vybrané rezervace pro zrušení.
                ReservationDao reservationDao = new ReservationDao();
                Reservation    reservation    = reservationDao.GetById(id);

                // Píše chybu v dvojité session
                //reservation.Client.Credit += reservation.Lesson.ActivityType.Price;
                //FitnessCentreUserDao fitnessCentreUserDao = new FitnessCentreUserDao();
                //fitnessCentreUserDao.Update(reservation.Client);

                //reservation.Lesson.Capacity += 1;
                //LessonDao lessonDao = new LessonDao();
                //lessonDao.Update(reservation.Lesson);

                // Přičtení ceny aktivity zpět ke kreditu klienta a uvolnění 1 místa v kapacitě lekce. Zápis změn do databáze.
                reservation.Client.Credit += reservation.Lesson.ActivityType.Price;
                FitnessCentreUserDao fitnessCentreUserDao = new FitnessCentreUserDao();
                FitnessCentreUser    client = fitnessCentreUserDao.GetByLogin(reservation.Client.Login);
                fitnessCentreUserDao.Update(client);

                reservation.Lesson.ActualCapacity += 1;
                LessonDao lessonDao = new LessonDao();
                Lesson    lesson    = lessonDao.GetById(reservation.Lesson.Id);
                lessonDao.Update(lesson);

                TempData["message-success"] = "Rezervace aktivity " + reservation.Lesson.ActivityType.Name + " byla úspěšně zrušena.";

                // Smazání rezervace z databáze.
                reservationDao.Delete(reservation);
            }
            catch (Exception)
            {
                // mechanismus zachytávání výjimek doporučuje dobře si nastudovat
                throw;
            }

            return(RedirectToAction("Index", new { isActive = true }));
        }
Esempio n. 9
0
        public ActionResult Delete(int id)
        {
            try
            {
                ActivityDao aDao = new ActivityDao();
                Activity    a    = aDao.GetById(id);

                if (a.SmallImageName != null)
                {
                    System.IO.File.Delete(Server.MapPath("~/Uploads/Activity/" + a.SmallImageName));
                }
                if (a.BigImageName != null)
                {
                    System.IO.File.Delete(Server.MapPath("~/Uploads/Activity/" + a.BigImageName));
                }

                //je zapotřebí smazat nejdrive vsechny terminy na tuto aktivitu, a take rezervace na tyto terminy
                TermDao        tDao   = new TermDao();
                ReservationDao resDao = new ReservationDao();
                IList <Term>   terms  = tDao.GetTermsByActivity(a);
                foreach (Term t in terms)
                {
                    IList <Reservation> reservations = resDao.GetAllReservationsByTerm(t);
                    foreach (Reservation res in reservations)
                    {
                        resDao.Delete(res);
                    }
                    tDao.Delete(t);
                }

                aDao.Delete(a);

                TempData["succes"] = "Aktivita " + a.Name + " úspěšně smazána. Stejně tak i všechny termíny na tuto akci.";
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteReservation(int id)
        {
            try
            {
                ReservationDao reservationDao = new ReservationDao();
                Reservation    reservation    = reservationDao.GetById(id);

                TourDao tourDao = new TourDao();
                Tour    tour    = tourDao.GetById(reservation.Tour.Id);

                tour.CurrentCapacity--;
                tourDao.Update(tour);

                reservationDao.Delete(reservation);

                TempData["message-success"] = "Rezervace " + reservation.ValidationNumber + " byla uspesne smazana z databazi";
            }
            catch (Exception e)
            {
                throw;
            }
            return(RedirectToAction("Rezervace", "Tours"));
        }
Esempio n. 11
0
 /// <summary>
 /// Obsługa przycisku usuwania
 /// </summary>
 /// <param name="sender">Obiekt wywołujący zdarzenie</param>
 /// <param name="e">Obiekt zawierający parametry zdarzenia</param>
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     ReservationDao.Delete((long)(sender as Button).Tag);
     RefreshGrid();
 }
 public static void DeleteReservation(int reservationId)
 {
     ReservationDao.Delete(reservationId);
 }