public async Task <ActionResult> CreateReport(Violation model, string postId) { if (!ModelState.IsValid) { return(View(model)); } var post = await postRepository.GetAsync(postId); if (post == null) { return(HttpNotFound()); } var user = await GetLoggedInUser(); model.UserId = user.Id; model.PostId = postId; await violationRepository.CreateAsync(model); return(RedirectToAction("Post", "HomeBlog", new { postId = postId })); }
public async Task Delete(Violation model) { this.db.Violation.Remove(model); await this.db.SaveChangesAsync(); }
public async Task CreateAsync(Violation model) { model.ReportedOn = DateTime.Now; this.db.Violation.Add(model); await this.db.SaveChangesAsync(); }