public IActionResult Update(long id) { var result = _employeeRest.Find(new EmployeeFilter { Id = id }); if (!result.Success) { return(RedirectToAction(nameof(Index))); } return(View(result.Model)); }
public IActionResult Login(UserModel userLogin) { try { var user = _userRest.Find(new UserFilter { Login = userLogin.Login, Password = userLogin.Password }); if (!user.Success) { ModelState.AddModelError("Login", "Login ou senha incorretos"); return(View("Index", userLogin)); } var employee = _employeeRest.Find(new EmployeeFilter { Id = user.Model.EmployeeId }); if (!employee.Success) { ModelState.AddModelError("Login", "Funcionário não encontrado"); return(View("Index", userLogin)); } SingIn(employee.Model); return(RedirectToAction("Index")); } catch (Exception error) { ModelState.AddModelError("Login", error.GetBaseException().Message); return(RedirectToAction("Index")); } }
public IActionResult Index(int currentPage, Occupation occupation, long vehicleId) { ViewBag.OcccupationSelected = occupation; var membersWorking = _memberRest.FindAll(new MemberFilter { EmployeeStatus = EmployeeStatus.Working }).Model; var membersGuidWorking = membersWorking .Select(d => d.EmployeeGuid).Distinct() .ToList(); var employees = _employeeRest.FindPaginated(new EmployeeFilter { Occupation = occupation, EmployeeGuidWorking = membersGuidWorking, IsMember = true, CurrentPage = currentPage == 0 ? 1 : currentPage }); var vehicles = _vehicleRest.FindAll(new VehicleFilter()); var currentVehicle = vehicles.Model.FirstOrDefault(); if (vehicleId > 0) { currentVehicle = vehicles.Model.FirstOrDefault(d => d.Id == vehicleId); } ViewBag.VehicleId = currentVehicle.Id; List <EmployeeVehicleModel> employeeVehicles = new List <EmployeeVehicleModel>(); foreach (var memberWorking in membersWorking.Where(d => d.VehicleId == currentVehicle.Id)) { var employee = _employeeRest.Find(new EmployeeFilter { Guid = memberWorking.EmployeeGuid }).Model; if (employee != null) { EmployeeVehicleModel employeeVehicleModel = new EmployeeVehicleModel { EmployeeModel = employee, VehicleModel = currentVehicle, MemberId = memberWorking.Id }; employeeVehicles.Add(employeeVehicleModel); } } return(View(new MemberRegisterModel { EmployeeModels = employees, VehicleModels = vehicles.Model, EmployeeVehicleModels = employeeVehicles })); }