public ActionResult Create([Bind(Include = "FirstName,LastName,PhoneNumber,UserId")] ApplicationUser newUser) { if (ModelState.IsValid) { EmployeeUsers newEmployee = new EmployeeUsers() { UserId = User.Identity.GetUserId(), FirstName = newUser.FirstName, LastName = newUser.LastName, PhoneNumber = newUser.PhoneNumber }; db.EmployeeUsers.Add(newEmployee); db.SaveChanges(); ApplicationUser currentUser = db.Users.FirstOrDefault(c => c.Id == newEmployee.UserId); var ViewModel = new EmployeeUsersCreateViewModel { Employee = newEmployee, AppUser = currentUser }; return(View("Create", ViewModel)); } return(View(newUser)); }
public ActionResult DeleteConfirmed(int id) { EmployeeUsers employeeUsers = db.EmployeeUsers.Find(id); db.EmployeeUsers.Remove(employeeUsers); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: EmployeeUsers public ActionResult Index() { var currentUserId = User.Identity.GetUserId(); EmployeeUsers employee = db.EmployeeUsers.Where(c => c.UserId == currentUserId).First(); var employeeZip = db.Users.Where(c => c.Id == employee.UserId).First().Zipcode; List <PickUps> PickUpsByZipToday = db.PickUps.Where(c => c.Zipcode == employeeZip && DbFunctions.TruncateTime(c.PickUpDate) == DateTime.Today.Date).ToList(); return(View(PickUpsByZipToday)); }
public ActionResult Edit([Bind(Include = "EmployeeId,UserId,Address")] EmployeeUsers employeeUsers) { if (ModelState.IsValid) { db.Entry(employeeUsers).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employeeUsers)); }
// GET: EmployeeUsers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeUsers employeeUsers = db.EmployeeUsers.Find(id); if (employeeUsers == null) { return(HttpNotFound()); } return(View(employeeUsers)); }
public ActionResult LoginAdmin(string userinputLogin, string passwordinputLogin) { EmployeeUsers employeeUser = new EmployeeUsers(); employeeUser = loginService.LoginEmployee(userinputLogin, passwordinputLogin); if (employeeUser.SuccessfulOperation == true) { System.Web.Security.FormsAuthentication.RedirectFromLoginPage(employeeUser.Id.ToString(), false); } return(View("Index")); }