Пример #1
0
        public void Create(CarriageDetailDTO carriage)
        {
            CarriageDetail carr = new CarriageDetail();

            carr.Train_Id      = carriage.Train_Id;
            carr.Carriage_Desc = carriage.Carriage_Desc;
            carr.Amount        = carriage.Amount;

            Database.CarriageDetails.Create(carr);
            Database.Save();
        }
Пример #2
0
        public void Update(CarriageDetailDTO carriage)
        {
            CarriageDetail carr = Database.CarriageDetails.Get(carriage.Id);

            if (carr == null)
            {
                throw new ValidationException("Вагон не найден", "");
            }
            carr.Train_Id      = carriage.Train_Id;
            carr.Carriage_Desc = carriage.Carriage_Desc;
            carr.Amount        = carriage.Amount;

            Database.CarriageDetails.Update(carr);
            Database.Save();
        }
Пример #3
0
 public void Delete(int id)
 {
     if (IsAdmin)
     {
         CarriageDetail carriage = Database.CarriageDetails.Get(id);
         if (carriage == null)
         {
             throw new ValidationException("Вагон не найден", "");
         }
         IEnumerable <BookingTable> bookings = (Database.BookingTables.Find(d => d.Carriage_Id == carriage.Id));
         if (bookings != null && bookings.GetEnumerator().MoveNext())
         {
             throw new ValidationException("В вагоне уже забронированы места", "");
         }
         Database.CarriageDetails.Delete(carriage.Id);
         Database.Save();
     }
 }
Пример #4
0
        public void BookPlace(BookingTableDTO bookt)
        {
            CarriageDetail carriage = Database.CarriageDetails.Get(bookt.Carriage_Id);

            // валидация
            if (carriage == null)
            {
                throw new ValidationException("Вагон не найден", "");
            }

            BookingTable bt = new BookingTable
            {
                CarriageDetail = carriage,
                Carriage_Id    = bookt.Carriage_Id,
                Date           = DateTime.Now,
                NAME           = bookt.NAME,
                EMAIL          = bookt.EMAIL,
                Description    = bookt.Description,
                Seat_Num       = bookt.Seat_Num
            };

            Database.BookingTables.Create(bt);
            Database.Save();

            /*
             * try
             * {
             *  MailMessage mailMessage = new MailMessage();
             *  mailMessage.To.Add(bookt.EMAIL);
             *  mailMessage.From = new MailAddress("*****@*****.**");
             *  mailMessage.Subject = "Place booked";
             *  mailMessage.Body = "Hello. You have booked a ticket via NovaZaliznitsya service. Your place "+ bookt.Seat_Num;
             *  SmtpClient smtpClient = new SmtpClient("smtp.isp.com");
             *  smtpClient.Send(mailMessage);
             * }
             * catch (Exception ex)
             * {
             *  Response.Write("Could not send the e-mail - error: " + ex.Message);
             * }*/
        }