Пример #1
0
 private void addClientButton(string obj)
 {
     myview.client.address = myview.address;
     model.AddClient(myview.client);
     reset();
     //int a = 26;
 }
Пример #2
0
 public ActionResult Create(ClientModel client)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ClientModel Client = new ClientModel();
             Client.AddClient(client);
             ViewBag.Message = "Records added successfully.";
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Confirmation(int identification,
                                         string name,
                                         string lastname,
                                         string email,
                                         int idroom,
                                         int amount,
                                         string arrivaldate,
                                         string departuredate,
                                         int paymentcardid)
        {
            ClientModel      clientModel      = new ClientModel(connectionString);
            ReservationModel reservationModel = new ReservationModel(connectionString);
            Client           clientResult     = clientModel.GetClientByidentification(identification);
            SendMail         sendMail         = null;
            RoomModel        roomModel        = new RoomModel(connectionString);
            Room             newRoom          = roomModel.GetRoomById(idroom);
            TypeRoomModel    typeRoomModel    = new TypeRoomModel(connectionString);
            TypeRoom         newTypeRoom      = typeRoomModel.GetTypeRoomByIdRoom(newRoom.id);

            if (clientResult == null)
            {
                Client newclient = new Client()
                {
                    id             = 0,
                    identification = identification,
                    name           = name,
                    lastname       = lastname,
                    email          = email
                };
                clientResult = clientModel.AddClient(newclient);
            }

            Reservation reservation = new Reservation()
            {
                id            = 0,
                idroom        = idroom,
                idClient      = clientResult.id,
                amount        = amount,
                arrivaldate   = arrivaldate,
                departuredate = departuredate,
                creationdate  = DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss")
            };

            Reservation resultReservation = reservationModel.AddReservation(reservation);

            if (resultReservation != null)
            {
                sendMail = new SendMail()
                {
                    email          = clientResult.email,
                    name           = clientResult.name,
                    lastname       = clientResult.lastname,
                    identification = clientResult.identification,
                    action         = ".Su reserva en la habitación tipo " + newTypeRoom.description + " número " + newRoom.number + " ha sido exitosa, para el día " + reservation.arrivaldate +
                                     " y hasta " + reservation.departuredate +
                                     " por un monto total de " + reservation.amount + " dolares."
                };
                sendMail.SendMailAction();

                PaymentCardModel paymentModel = new PaymentCardModel(connectionString);
                var result = paymentModel.AddVoucher(paymentcardid, resultReservation.id);
                if (result < 1)
                {
                    return(View("Data"));
                }
            }

            ViewBag.Reservation = reservation;
            ViewBag.Client      = clientResult;
            ViewBag.Email       = sendMail;

            return(View());
        }