- Timestamp:
- 08/23/24 15:40:14 (2 months ago)
- Branches:
- main
- Children:
- e9bb9d1
- Parents:
- 72b1da2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PostgreSqlDotnetCore/Controllers/BlogPostAnswersController.cs
r72b1da2 r118e414 58 58 [HttpPost] 59 59 [ValidateAntiForgeryToken] 60 public ActionResult Create([Bind(include: "id,parent_id,reply,root_post,usersID")] BlogPostAnswers answerClass)60 public async Task<ActionResult> CreateAsync(int? id, int? parentId, [Bind(include: "reply")] BlogPostAnswers answerClass) 61 61 { 62 if (ModelState.IsValid) 62 63 //string id = Request.Query["BlogId"]; 64 if (id == null && id > 0) 63 65 { 66 return RedirectToAction("NotExist", "Error"); 67 } 68 //string id = Request.Query["BlogId"]; 69 if (parentId== null && parentId > 0) 70 { 71 return RedirectToAction("NotExist", "Error"); 72 } 73 if (answerClass != null && answerClass.reply.Length > 0) 74 { 75 76 var user = await _userManager.GetUserAsync(User); 77 if (user == null) 78 { 79 return RedirectToAction("AccessDenied", "Error"); 80 } 81 82 83 var customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email); 84 answerClass.usersid = customerClass.id; 85 answerClass.BlogPostConsultationid = (int)id; 86 answerClass.parent_id = (int)parentId; 64 87 db.BlogPostAnswersObj.Add(answerClass); 65 88 db.SaveChanges(); 66 return RedirectToAction("Index"); 89 //return RedirectToAction("Index"); 90 return RedirectToAction("Details", "Blog", new { id }); 67 91 } 68 92
Note:
See TracChangeset
for help on using the changeset viewer.