public ActionResult ViewMyRequests(UserLoadParams userLoadParams) { var currentUserId = CurrentOperatorService.GetCurrentUser().Id; var reqQuery = RequestDataStore.GetAll().Where(req => req.Author.Id == currentUserId); return(ListOfRequests(userLoadParams, reqQuery)); }
public ActionResult Edit(RequestForWorkerDto dto) { if (dto.State == EState.InProgress && string.IsNullOrWhiteSpace(dto.WorkerComment)) { ModelState.AddModelError(nameof(dto.WorkerComment), $"{CurrentOperatorService.GetCurrentUser().Name}, добавьте, пожалуйста, комментарий."); } if (!dto.NextState.HasValue) { ModelState.AddModelError(nameof(dto.NextState), $"{CurrentOperatorService.GetCurrentUser().Name}, выберите следующий статус."); } if (!ModelState.IsValid) { return(View(dto)); } var request = RequestDataStore.Get(dto.Id); request.State = dto.NextState.Value; request.WorkerComment = dto.WorkerComment; request.Executor = CurrentOperatorService.GetCurrentUser(); RequestDataStore.Update(request); return(RedirectToAction("Details", new { id = dto.Id })); }
public ActionResult ViewFinishedRequests(UserLoadParams userLoadParams) { var userId = CurrentOperatorService.GetCurrentUser().Id; var reqQuery = RequestDataStore.GetAll() .Where(req => req.Executor.Id == userId) .Where(req => req.State == EState.Done || req.State == EState.NotDone); return(ListOfRequests(userLoadParams, reqQuery)); }
public ActionResult Create(long?categoryId) { if (!categoryId.HasValue) { var categories = CategoryDataStore.GetAll().ToArray(); return(View("ChooseRequestCategory", categories)); } var cat = CategoryDataStore.Get(categoryId.Value); return(View(new NewRequestFormDto { CategoryId = cat.Id, CategoryName = cat.Name, AuthorId = CurrentOperatorService.GetCurrentUser().Id })); }