Пример #1
0
        public void EditTour(InsertTourCommand command)
        {
            var checkTour = new Tour();

            using (var connection = new SqlConnection(this._db.Database.GetDbConnection().ConnectionString))
            {
                connection.Open();
                if (command != null)
                {
                    checkTour = connection.Query <Tour>(@"select * from Tour").FirstOrDefault(n => n.Id == command.Id);
                }
                connection.Close();
            }

            checkTour.Code        = command.Code;
            checkTour.Cost        = command.Cost;
            checkTour.Day         = command.Day;
            checkTour.Night       = command.Night;
            checkTour.Quantity    = command.Quantity;
            checkTour.Description = command.Description;

            dbSet.Attach(checkTour);
            _db.Entry(checkTour).State = EntityState.Modified;
            _db.SaveChanges();
        }
Пример #2
0
        public async Task <IActionResult> PutTour(long id, Tour tour)
        {
            if (id != tour.Id)
            {
                return(BadRequest());
            }

            tour.LastModified = DateTime.Now;

            _context.Entry(tour).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TourExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(tour));
        }
Пример #3
0
 public void EditTourCategory(int id, [FromBody] tourcategory tourCategory)
 {
     if (id == tourCategory.IdTourCategory)
     {
         db.Entry(tourCategory).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Пример #4
0
 public ActionResult Edit([Bind(Include = "TourID,TourName,TourDescription,TourPrice")] Tour tour)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tour).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tour));
 }
 public ActionResult Edit([Bind(Include = "ID,LocationID,LocationName,LocationDescription,Country")] Location location)
 {
     if (ModelState.IsValid)
     {
         db.Entry(location).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(location));
 }
Пример #6
0
 public ActionResult Edit([Bind(Include = "idCliente,identificacion,nombre,apellidos,email,telefono,password,activo")] cliente cliente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cliente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cliente));
 }
Пример #7
0
 public ActionResult Edit([Bind(Include = "idReserva,idTour,idCliente,cantidadNinos,cantidadAdultos,costoTotal,fechaReserva")] reserva_tour reserva_tour)
 {
     if (ModelState.IsValid)
     {
         db.Entry(reserva_tour).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idCliente = new SelectList(db.cliente, "idCliente", "identificacion", reserva_tour.idCliente);
     ViewBag.idTour    = new SelectList(db.tour, "idTour", "nombre", reserva_tour.idTour);
     return(View(reserva_tour));
 }
Пример #8
0
 public ActionResult Edit([Bind(Include = "ID,Name,PriceUSD,StartConnectionID,ProgramFirstDayID,Description,FoodTypeID")] Tour tour)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tour).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProgramFirstDayID = new SelectList(db.Day_Connection, "Id", "Id", tour.ProgramFirstDayID);
     ViewBag.FoodTypeID        = new SelectList(db.FoodType, "Id", "Description", tour.FoodTypeID);
     ViewBag.StartConnectionID = new SelectList(db.Route_Connection, "ID", "ID", tour.StartConnectionID);
     return(View(tour));
 }
        public ActionResult EditTour(Tour tour, int[] selectedList)
        {
            Tour newTour = db.Tours.Find(tour.Id);

            newTour.Name    = tour.Name;
            newTour.StartAt = tour.StartAt;
            newTour.EndAt   = tour.EndAt;

            newTour.Categories.Clear();
            if (selectedList != null)
            {
                foreach (var c in db.Categories.Where(co => selectedList.Contains(co.Id)))
                {
                    newTour.Categories.Add(c);
                }
            }

            db.Entry(newTour).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Пример #10
0
 public ActionResult Edit(Models.tour objTour)
 {
     if (TempData.ContainsKey("mensaje"))
     {
         ViewBag.Mensaje = TempData["mensaje"].ToString();
     }
     try
     {
         // TODO: Add update logic here
         db.Entry(objTour).State =
             System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         TempData["mensaje"] = "Tour actualizado satisfactoriamente!";
         return(RedirectToAction("Index"));
     }
     catch
     {
         TempData["mensaje"] = "El tour no se logro actualizar";
         return(View());
     }
 }
Пример #11
0
        public void BookingTour(BookingTourCommand command)
        {
            var newCustomer = new Customer();

            newCustomer.Name    = command.Name;
            newCustomer.Email   = command.Email;
            newCustomer.Address = command.Address;
            newCustomer.Phone   = command.Phone;

            _db.Customers.Add(newCustomer);
            _db.SaveChanges();
            //Insert Contract
            ContractViewModel contract = new ContractViewModel();
            {
                contract.CustomerId = newCustomer.Id;
                contract.TourId     = command.TourId;
                contract.BeginDate  = command.BeginDate;
                contract.Paid       = false;
                contract.Content    = command.Content;
            }
            var newContract = new Contract(contract);

            _db.Contracts.Add(newContract);
            _db.SaveChanges();

            var tour = new Tour();

            using (var connection = new SqlConnection(this._db.Database.GetDbConnection().ConnectionString))
            {
                connection.Open();
                if (command != null)
                {
                    tour = connection.Query <Tour>(@"select * from Tour").FirstOrDefault(n => n.Id == command.TourId);
                }
                connection.Close();
            }

            tour.Quantity = tour.Quantity - Convert.ToInt32(command.PeopleGo);

            dbSet.Attach(tour);
            _db.Entry(tour).State = EntityState.Modified;

            _db.SaveChanges();
            //Insert ContractDetail
            ContractDetailViewModel contractDetail = new ContractDetailViewModel();
            {
                contractDetail.TourId     = tour.Id;
                contractDetail.NameTour   = tour.NameTour;
                contractDetail.Cost       = tour.Cost;
                contractDetail.PeopleGo   = Convert.ToInt32(command.PeopleGo);
                contractDetail.ContractId = newContract.Id;
            }
            var newContractDetail = new ContractDetail();

            {
                newContractDetail.TourId     = contractDetail.TourId;
                newContractDetail.NameTour   = contractDetail.NameTour;
                newContractDetail.Cost       = contractDetail.Cost;
                newContractDetail.PeopleGo   = contractDetail.PeopleGo;
                newContractDetail.ContractId = contractDetail.ContractId;
            }
            _db.ContractDetails.Add(newContractDetail);
            _db.SaveChanges();

            using (MailMessage emailMessage = new MailMessage())
            {
                emailMessage.From = new MailAddress("*****@*****.**", "Công ty du lịch");
                emailMessage.To.Add(new MailAddress("*****@*****.**", "Account1"));
                emailMessage.Subject  = "Thông tin đặt tour";
                emailMessage.Body     = "TourId: " + contractDetail.TourId + Environment.NewLine + "Tên Tour: " + contractDetail.NameTour + Environment.NewLine + "Giá: " + contractDetail.Cost + Environment.NewLine + "Số người đi: " + contractDetail.PeopleGo;
                emailMessage.Priority = MailPriority.Normal;
                using (SmtpClient MailClient = new SmtpClient("smtp.gmail.com", 587))
                {
                    MailClient.EnableSsl   = true;
                    MailClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "tungvipro809");
                    MailClient.Send(emailMessage);
                }
            }
        }