Ejemplo n.º 1
0
        public ActionResult SubmitNewDeal(PurchaseView pv)
        {
            if (ModelState.IsValid)
            {
                var managerHelper = new CalcModel();
                _manager.AddPurchase(pv.ReturnDateDetails());
                managerHelper.ActionResult = "New deal submitted";
                return(Json(managerHelper, JsonRequestBehavior.AllowGet));
            }

            else
            {
                return(PartialView("AddDeal"));
            }
        }
Ejemplo n.º 2
0
 public ActionResult AddNewPurchases(int CarID)
 {
     try
     {
         if (User == null || string.IsNullOrEmpty(User.Identity.Name))
         {
             return(Json(0, JsonRequestBehavior.AllowGet));
         }
         var      UserID = manager.GetAllUsers().Where(p => p.UserName == User.Identity.Name).Select(p => p.ID).FirstOrDefault();
         Purchase pur    = new Purchase();
         pur.UserId = UserID;
         pur.CarID  = CarID;
         var now = DateTime.Now;
         pur.PurchaseDate = now;
         pur.ReturnDate   = now;
         manager.AddPurchase(pur);
         return(Json(1, JsonRequestBehavior.AllowGet));
     }
     catch
     {
         return(Json(-1, JsonRequestBehavior.AllowGet));
     }
 }