public HttpResponse Add(AddIssueInputModel input) { if (!this.IsUserSignedIn()) { return(this.Redirect("/Users/Login")); } if (string.IsNullOrEmpty(input.Description) || input.Description.Length < 5) { return(this.Error("Description is required and should be at least 5 characters long.")); } this.issuesService.AddIssue(input.Description, input.CarId); return(this.Redirect($"/Issues/CarIssues?carId={input.CarId}")); }
public void Add(AddIssueInputModel input) { var issue = new Issue() { Description = input.Description, CarId = input.CarId, IsFixed = false }; var carFromDb = this.db.Cars.Where(x => x.Id.ToString() == input.CarId).FirstOrDefault(); carFromDb.Issues.Add(issue); this.db.SaveChanges(); }
public HttpResponse Add(AddIssueInputModel input) { this.issuesService.Add(input); return(this.Redirect(carIssuesPath + input.CarId)); }