Esempio n. 1
0
        public ActionResult DeleteConfirmed(string id)
        {
            RentalBusOrder check = db.RentalBusOrder.Find(id);

            if (check.EmailGuest != null)
            {
                MailMessage mm      = new MailMessage("*****@*****.**", check.EmailGuest);
                var         subject = new StringBuilder();
                subject.Append("Hủy Đơn Hàng:  " + check.Departure + " - " + check.Stoplocation + " ( " + id + " ) ");

                var bodymail = "Đơn hàng của bạn đã được hủy thành công!";
                mm.Subject    = subject.ToString();
                mm.Body       = bodymail;
                mm.IsBodyHtml = false;

                SmtpClient smtp = new SmtpClient();
                smtp.Host      = "smtp.gmail.com";
                smtp.Port      = 587;
                smtp.EnableSsl = true;

                NetworkCredential nc = new NetworkCredential("*****@*****.**", "Hlb@1234");
                smtp.UseDefaultCredentials = true;
                smtp.Credentials           = nc;
                smtp.Send(mm);
            }



            RentalBusOrder rentalBusOrder = db.RentalBusOrder.Find(id);

            db.RentalBusOrder.Remove(rentalBusOrder);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "RentalBusId,UserID,PaymentStatusId,Departure,Stoplocation,GettingOfBus,DepartureDay,ReturnDay,ConfimDelivery,DateBuy,Bustype,TotalMoney,NameGuest,AddGuest,PhoneGuest,EmailGuest")] RentalBusOrder rentalBusOrder)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rentalBusOrder).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserID          = new SelectList(db.Users, "Id", "Address", rentalBusOrder.UserID);
     ViewBag.PaymentStatusId = new SelectList(db.PaymentStatus, "PaymentStatusId", "PaymentStatusName", rentalBusOrder.PaymentStatusId);
     return(View(rentalBusOrder));
 }
Esempio n. 3
0
        // GET: RentalOrderManageAdmin/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "RentalOrderManageAdmin"));
            }
            RentalBusOrder rentalBusOrder = db.RentalBusOrder.Find(id);

            if (rentalBusOrder == null)
            {
                return(RedirectToAction("Index", "RentalOrderManageAdmin"));
            }
            return(View(rentalBusOrder));
        }
Esempio n. 4
0
        // GET: RentalOrderManageAdmin/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "RentalOrderManageAdmin"));
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            RentalBusOrder rentalBusOrder = db.RentalBusOrder.Find(id);

            if (rentalBusOrder == null)
            {
                return(RedirectToAction("Index", "RentalOrderManageAdmin"));
            }
            return(View(rentalBusOrder));
        }
Esempio n. 5
0
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "RentalOrderManageAdmin"));
            }
            RentalBusOrder rentalBusOrder = db.RentalBusOrder.Find(id);

            if (rentalBusOrder == null)
            {
                return(RedirectToAction("Index", "RentalOrderManageAdmin"));
            }
            ViewBag.UserID          = new SelectList(db.Users, "Id", "Address", rentalBusOrder.UserID);
            ViewBag.PaymentStatusId = new SelectList(db.PaymentStatus, "PaymentStatusId", "PaymentStatusName", rentalBusOrder.PaymentStatusId);
            return(View(rentalBusOrder));
        }
Esempio n. 6
0
        public ActionResult Edit([Bind(Include = "RentalBusId,UserID,PaymentStatusId,Departure,Stoplocation,GettingOfBus,DepartureDay,ReturnDay,ConfimDelivery,DateBuy,Bustype,TotalMoney,NameGuest,AddGuest,PhoneGuest,EmailGuest")] RentalBusOrder rentalBusOrder)
        {
            if (rentalBusOrder.EmailGuest != null)
            {
                MailMessage mm      = new MailMessage("*****@*****.**", rentalBusOrder.EmailGuest);
                var         subject = new StringBuilder();
                subject.Append("Xác Nhận Đơn Hàng:  " + " " + rentalBusOrder.Departure + "-" + rentalBusOrder.Stoplocation + " ( " + rentalBusOrder.RentalBusId + " ) ");
                var bodymail = new StringBuilder();
                bodymail.AppendLine("Đơn Hàng Đã Đặt Thành Công");
                bodymail.AppendLine("Tổng Số Tiền Thanh Toán: " + rentalBusOrder.TotalMoney);
                bodymail.AppendLine("Tình Trạng Thanh Toán: " + rentalBusOrder.ConfimDelivery);
                bodymail.AppendLine("");
                bodymail.AppendLine("HoLa Bus!");
                mm.Subject    = subject.ToString();
                mm.Body       = bodymail.ToString();
                mm.IsBodyHtml = false;

                SmtpClient smtp = new SmtpClient();
                smtp.Host      = "smtp.gmail.com";
                smtp.Port      = 587;
                smtp.EnableSsl = true;

                NetworkCredential nc = new NetworkCredential("*****@*****.**", "Hlb@1234");
                smtp.UseDefaultCredentials = true;
                smtp.Credentials           = nc;
                smtp.Send(mm);
            }
            if (ModelState.IsValid)
            {
                db.Entry(rentalBusOrder).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.UserID          = new SelectList(db.Users, "Id", "Address", rentalBusOrder.UserID);
            ViewBag.PaymentStatusId = new SelectList(db.PaymentStatus, "PaymentStatusId", "PaymentStatusName", rentalBusOrder.PaymentStatusId);
            return(View(rentalBusOrder));
        }
        public ActionResult BuyRental(RentalBusUserViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Waring = "Không được để trống thông tin!";
                return(RedirectToAction("OrderRental", "UserRentalBusOrder"));
            }

            MailMessage mm      = new MailMessage("*****@*****.**", model.Email);
            var         subject = new StringBuilder();

            subject.Append("Thông Tin Đơn Hàng:  " + model.Departure + " - " + model.StopLocation + " (" + model.RentalBusId + ") ");

            var bodymail = new StringBuilder();

            bodymail.AppendLine("Tên Khách Hàng: " + model.NameUser);
            bodymail.AppendLine("Số Điện Thoại: " + model.Phone);
            bodymail.AppendLine("Địa Chỉ: " + model.Address);
            bodymail.AppendLine("Email: " + model.Email);
            bodymail.AppendLine("Tên Tuyến Xe: " + model.Departure + " - " + model.StopLocation);
            bodymail.AppendLine("Loại Xe: " + model.Bustype + " Chỗ");
            bodymail.AppendLine("Mã Đơn: " + model.RentalBusId);
            bodymail.AppendLine("Ngày Tạo Đơn: " + model.Datebyu);
            bodymail.AppendLine("Điểm Khời Hành: " + model.Departure);
            bodymail.AppendLine("Địa Đến: " + model.StopLocation);
            bodymail.AppendLine("Điểm Trả Khách Ngày Về: " + model.GettingOfLocation);
            bodymail.AppendLine("Ngày Khởi Hành: " + model.DepartureDay);
            bodymail.AppendLine("Ngày Về: " + model.ReturnDay);
            bodymail.AppendLine("Tình Trạng Đơn: Đang chờ HoLa Bus xác nhận! ");
            bodymail.AppendLine("Cảm ơn bạn đã sử dụng dịch vụ của HoLa Bus, đơn hàng của bạn đang trong trạng thái chờ xử lý! ");
            bodymail.AppendLine("");
            bodymail.AppendLine("HoLa Bus!");
            mm.Subject    = subject.ToString();
            mm.Body       = bodymail.ToString();
            mm.IsBodyHtml = false;

            SmtpClient smtp = new SmtpClient();

            smtp.Host      = "smtp.gmail.com";
            smtp.Port      = 587;
            smtp.EnableSsl = true;

            NetworkCredential nc = new NetworkCredential("*****@*****.**", "Hlb@1234");

            smtp.UseDefaultCredentials = true;
            smtp.Credentials           = nc;
            smtp.Send(mm);

            var retalbusorder = new RentalBusOrder()
            {
                NameGuest       = model.NameUser,
                PhoneGuest      = model.Phone,
                AddGuest        = model.Address,
                EmailGuest      = model.Email,
                Bustype         = model.Bustype,
                DateBuy         = model.Datebyu,
                RentalBusId     = model.RentalBusId,
                UserID          = model.UserId,
                PaymentStatusId = 1,
                Departure       = model.Departure,
                Stoplocation    = model.StopLocation,
                GettingOfBus    = model.GettingOfLocation,
                DepartureDay    = model.DepartureDay,
                ReturnDay       = model.ReturnDay,
                ConfimDelivery  = null,
            };

            DbContext.RentalBusOrder.Add(retalbusorder);
            DbContext.SaveChanges();
            return(RedirectToAction("Index", "RentalBusManageUser"));
        }