public ActionResult openRatingsPop(Ranking ranking)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (SIPDbContext db = new SIPDbContext())
             {
                 db.rankings.Add(ranking);
                 db.SaveChanges();
                 ModelState.Clear();
                 var results = db.userAccount.Include(o => o.Rankings);
                 return(View("~/Views/Customer/CourierRatingsView.cshtml", results.ToList()));
             }
         }
         else
         {
             return(View("~/Views/Customer/openRatingsPop.cshtml"));
         }
     }
     catch (RetryLimitExceededException /* dex */)
     {
         //Log the error (uncomment dex variable name and add a line here to write a log.)
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
     }
     PopulateDepartmentsDropDownList(ranking.DepartmentID);
     return(View("~/Views/Customer/openRatingsPop.cshtml"));
 }
 public ActionResult Delete(int Id)
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         if (Session["UserId"] != null)
         {
             db.userAccount.Remove(db.userAccount.Single(a => a.Id == Id));
             db.SaveChanges();
         }
         return(View("~/Views/Shared/MainView.cshtml", db.userAccount.ToList()));
     }
 }
 public ActionResult updateOrder(string id, string value)
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         int   ordId        = int.Parse(id);
         int   state        = int.Parse(value);
         Order currentOrder = db.orders.Include(o => o.Parcels).Single(o => o.Id == ordId);
         currentOrder.Parcels.Select(cO => { cO.State = 1; return(cO); }).ToList();
         currentOrder.State = state;
         db.SaveChanges();
         return(View("~/Views/Customer/OrderShipmentView.cshtml", currentOrder));
     }
 }
 public ActionResult openNewOrder()
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         int   Id          = (int)System.Web.HttpContext.Current.Session["UserId"];
         User  currentUser = db.userAccount.Single(u => u.Id == Id);
         Order order       = new Order();
         order.User = currentUser;
         order.Date = DateTime.Now;
         db.orders.Add(order);
         db.SaveChanges();
         ModelState.Clear();
         return(View("~/Views/Customer/OrderShipmentView.cshtml", order));
     }
 }
 public ActionResult Registration(User account)
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         if (ModelState.IsValid)
         {
             db.userAccount.Add(account);
             db.SaveChanges();
             ModelState.Clear();
             return(View("~/Views/Shared/MainView.cshtml", db.userAccount.ToList()));
         }
         else
         {
             return(View("~/Views/Admin/RegistrationScreen.cshtml"));
         }
     }
 }
 public ActionResult Edit(User account)
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         if (ModelState.IsValid)
         {
             var result = db.userAccount.Single(u => u.Email.ToString() == account.Email.ToString());
             if (result != null)
             {
                 result.Name        = account.Name;
                 result.Surname     = account.Surname;
                 result.Password    = account.Password;
                 result.YearOfBirth = account.YearOfBirth;
                 result.Address     = account.Address;
                 db.SaveChanges();
             }
         }
         return(View("~/Views/Shared/MainView.cshtml", db.userAccount.ToList()));
     }
 }
 public ActionResult fillOrderData(int id, Parcel parcel)
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         if (ModelState.IsValid)
         {
             Order currentOrder         = db.orders.Single(o => o.Id == id);
             Tuple <Order, Parcel> tpl1 = PriceController.calculatePrice(currentOrder, parcel);
             currentOrder = tpl1.Item1;
             parcel       = tpl1.Item2;
             currentOrder.Parcels.Add(parcel);
             db.SaveChanges();
             return(View("~/Views/Customer/OrderShipmentView.cshtml", currentOrder));
         }
         else
         {
             ViewData["Message"] = id;
             return(View("~/Views/Customer/addParcelView.cshtml"));
         }
     }
 }
Пример #8
0
 public ActionResult Register(User account)
 {
     if (ModelState.IsValid)
     {
         using (SIPDbContext db = new SIPDbContext())
         {
             db.userAccount.Add(account);
             db.SaveChanges();
             Session["UserId"]   = account.Id;
             Session["UserName"] = account.Name.ToString();
             Session["Surname"]  = account.Surname.ToString();
             ModelState.Clear();
             if (Session["UserId"] != null)
             {
                 return(View("~/Views/Shared/MainView.cshtml", db.userAccount.ToList()));
             }
             else
             {
                 return(View("~/Views/User/Register.cshtml"));
             }
         }
     }
     return(View("~/Views/User/Register.cshtml"));
 }