예제 #1
0
 public accountController()
 {
     db          = new ApplicationDbContext();
     Viewmodel   = new CarClintViewModel();
     searchmodel = new SearchCarViewmodel();
     rigester    = new RigestrationViewModel();
     Viewmodel2  = new NewCarViewModel();
 }
예제 #2
0
        public ActionResult Reservation(CarClintViewModel viewmodel)
        {
            if (viewmodel.car.To != null && viewmodel.car.From != null)
            {
                if (viewmodel.car.To > viewmodel.car.From)
                {
                    try
                    {
                        //return Content("<h1>"+viewmodel.car.Name+"</h1>"+"hhhhhhhhh");
                        var car = db.cars.Include(c => c.categorytype).SingleOrDefault(c => c.id == viewmodel.car.id);

                        car.From    = viewmodel.car.From;
                        car.To      = viewmodel.car.To;
                        car.clintid = viewmodel.clint.id;
                        var clint = db.clints.SingleOrDefault(c => c.id == viewmodel.clint.id);
                        db.SaveChanges();
                        TimeSpan Duration = new TimeSpan();
                        Duration = (TimeSpan)(viewmodel.car.To - viewmodel.car.From);
                        SendSms("+2" + clint.phone, "you are successfully rented this car :" + car.Name + " from :" + viewmodel.car.From + " :to:" + viewmodel.car.To + " " + " and the ending duration of rent is :" + Duration.Duration());
                        SendSms("+201276134569", "The clint :" + clint.Name + "has id :" + clint.id + " have been rented this car :" + car.Name + " it's type " + car.categorytype.Name);
                        return(Json(new { state = true, viewmodel = viewmodel, message = "the message it's on the way to you that confim you are rented thid car: " + car.Name }));
                        //return Content();
                    }
                    catch (Exception e)
                    {
                        return(Content(e.ToString()));
                    }
                }
                else
                {
                    viewmodel.fromstate    = 1;
                    viewmodel.tostate      = 1;
                    viewmodel.messageerror = "the to date must be bigger than from date";
                    return(Json(new { state = false, viewmodel = viewmodel }));
                }
            }
            else
            {
                if (viewmodel.car.From == null)
                {
                    viewmodel.fromstate    = 1;
                    viewmodel.messageerror = "this field is required";
                    return(Json(new { state = false, viewmodel = viewmodel }));
                }
                else /*if (viewmodel.car.From == null) */
                {
                    viewmodel.tostate      = 1;
                    viewmodel.messageerror = "this field is required";
                    return(Json(new { state = false, viewmodel = viewmodel }));
                }
            }
        }
예제 #3
0
 public categoryController()
 {
     db        = new ApplicationDbContext();
     Viewmodel = new CarClintViewModel();
 }
예제 #4
0
 public ClintController()
 {
     db          = new ApplicationDbContext();
     Viewmodel   = new CarClintViewModel();
     searchmodel = new SearchCarViewmodel();
 }