public ActionResult ToMainView()
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         return(View("~/Views/Shared/MainView.cshtml", db.userAccount.ToList()));
     }
 }
 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 openMap()
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         var results = db.orders.Where(o => o.State != 3).Include(o => o.Parcels);
         return(View("~/Views/Customer/Map.cshtml", results.ToList()));
     }
 }
 public ActionResult openAddParcelForm(int id)
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         ViewData["Message"] = id;
         return(View("~/Views/Customer/addParcelView.cshtml"));
     }
 }
示例#5
0
 // GET: MainUser
 public ActionResult openOrderHistory()
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         var results = db.orders.Where(o => o.State == 3).Include(o => o.Parcels);
         return(View("~/Views/User/OrderView.cshtml", results.ToList()));
     }
 }
 private void PopulateDepartmentsDropDownList(object selectedDepartment = null)
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         var departmentsQuery = from d in db.userAccount
                                orderby d.Email
                                select d;
         ViewBag.DepartmentID = new SelectList(departmentsQuery, "DepartmentID", "Email", selectedDepartment);
     }
 }
 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 MainView()
 {
     if (Session["UserId"] != null)
     {
         using (SIPDbContext db = new SIPDbContext())
         {
             return(View("~/Views/Shared/MainView.cshtml", db.userAccount.ToList()));
         }
     }
     else
     {
         return(RedirectToAction("Login"));
     }
 }
 public ActionResult Details(int Id)
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         if (Session["UserId"] != null)
         {
             var usr = db.userAccount.Single(u => u.Id == Id);
             return(View("~/Views/Admin/UserView.cshtml", usr));
         }
         else
         {
             return(View("~/Views/User/Login.cshtml"));
         }
     }
 }
 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 Edit(int Id)
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         if (Session["UserId"] != null)
         {
             var usr = db.userAccount.Single(u => u.Id == Id);
             return(View("~/Views/Admin/EditView.cshtml", usr));
         }
         else
         {
             return(View("~/Views/Shared/MainView.cshtml"));
         }
     }
 }
 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 JsonResult getDeliveryAddress()
        {
            using (SIPDbContext db = new SIPDbContext())
            {
                string[] currentOrder = new string[50];

                int k = 0;

                foreach (Parcel parcel in db.parcels)
                {
                    currentOrder[k] = parcel.DeliveryAddress;
                    k++;
                }

                return(Json(currentOrder, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult openCourierRatings(string searchString)
        {
            using (SIPDbContext db = new SIPDbContext())
            {
                if (!String.IsNullOrEmpty(searchString))
                {
                    var results = db.userAccount.Include(o => o.Rankings).Where(s => s.Email.Contains(searchString));


                    return(View("~/Views/Customer/CourierRatingsView.cshtml", results.ToList()));
                }
                else
                {
                    var results = db.userAccount.Include(o => o.Rankings);
                    return(View("~/Views/Customer/CourierRatingsView.cshtml", results.ToList()));
                }
            }
        }
示例#16
0
 public ActionResult Login(User user)
 {
     using (SIPDbContext db = new SIPDbContext())
     {
         var usr = db.userAccount.Single(u => u.Email == user.Email && u.Password == user.Password);
         if (usr != null)
         {
             Session["UserId"]   = usr.Id;
             Session["UserName"] = usr.Name.ToString();
             Session["Surname"]  = usr.Surname.ToString();
             return(RedirectToAction("MainView"));
         }
         else
         {
             ModelState.AddModelError("", "E-pašto adresas arba slaptažodis neteisingi");
         }
     }
     return(View("~/Views/User/Login.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"));
         }
     }
 }
示例#19
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"));
 }