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 }));
        }
示例#2
0
 public async Task Delete(Violation model)
 {
     this.db.Violation.Remove(model);
     await this.db.SaveChangesAsync();
 }
示例#3
0
 public async Task CreateAsync(Violation model)
 {
     model.ReportedOn = DateTime.Now;
     this.db.Violation.Add(model);
     await this.db.SaveChangesAsync();
 }