public IActionResult Details(int id) { Assignment assignmentDetails = _assignmentService.Find(id); if (assignmentDetails == null) { return(RedirectToAction("Index")); } return(View(assignmentDetails)); }
public ActionResult Index(int?assignmentId) { if (assignmentId.HasValue) { ViewBag.AssignmentNumber = _assignmentService.Find(assignmentId.Value).Number; ViewBag.AssignmentId = assignmentId.Value; } ViewBag.Customers = _customerService.All.Select(item => new SelectListItem { Text = item.CustomerName, Value = item.Id.ToString() }); return(View()); }
public JsonResult ReturnAssignment(int id) { var isAdmin = User.IsInRole("admin"); if (isAdmin) { var assignment = _assignmentService.Find(id); if (assignment.StatusId >= 4) { return(Json(new { Error = "Cannot return closed or funded assignments" })); } assignment.StatusId = 2; assignment.ReturnReason = Request.Form["ReturnReason"]; _uow.SaveChanges(); var user = UserManager.Users.SingleOrDefault(item => item.Id == assignment.UserId); var msg = GetAssignmentReturnEmail(assignment, user); MailService.SendMail(user.Email, "Assignment Returned", msg); return(Json(new { Done = 1 })); } return(Json(new { Error = "You are not authorized to do this action" })); }