public void Add(HttpSession session, AddIssueBindingModel model) { this.CheckIfNull(model); var firstOrDefault = this.Data.Logins.Query().FirstOrDefault(u => u.SessionId == session.Id && u.IsActive); if (firstOrDefault != null) { var getAuthor = firstOrDefault.UserId; var issue = new Issue() { Name = model.Name, PriorityId = model.PriorityId, StatusId = model.StatusId, CreationDate = DateTime.Today, AuthorId = getAuthor }; this.Data.Issue.Add(issue); } if (firstOrDefault == null) { throw new ArgumentNullException(nameof(firstOrDefault), "You should first log in!"); } this.Data.SaveChanges(); }
public void Add(HttpResponse response, HttpSession session, AddIssueBindingModel model) { try { this.service.Add(session, model); this.Redirect(response, "/issue/all"); } catch (Exception ex) { throw new Exception($"Exeption of type: {ex.GetType().Name} and Message: {ex.Message} has been thrown."); } }