public IActionResult DeleteIssuePosition(int issueId, int positionId) { if (issueId != 0 && positionId != 0) { PositionIssue model = _db.PositionIssues.Where(i => i.IssueId == issueId) .FirstOrDefault(i => i.PositionId == positionId); if (model != null) { _db.PositionIssues.Remove(model); _db.SaveChanges(); return(Json("true")); } } return(Json("false")); }
public IActionResult AddForPosition(AddForPositionViewModel model) { if (ModelState.IsValid) { if (model.PositionId != 0 && model.IssuesId == null) { return(RedirectToAction("IndexPosition", "IssuesManage", new { id = model.PositionId })); } if (model.IssuesId == null) { return(RedirectToAction("ListUsers", "UsersManage")); } foreach (var issueId in model.IssuesId) { PositionIssue positionIssue = new PositionIssue(); positionIssue.IssueId = issueId; positionIssue.PositionId = model.PositionId; _db.PositionIssues.Add(positionIssue); _db.SaveChanges(); } } return(RedirectToAction("IndexPosition", "IssuesManage", new { id = model.PositionId })); }