public async Task<ActionResult> Create([Bind(Include = "Id,Name,Sex,PassportNumber,MyanmarICNumber,ContactNumber,Email,CountryOfVote,SubmitDate,VotingState,VotingTownship,VotingWard,VotingOtherLocation,NameMissing,BallotMissingPyithu,BallotMissingAmyotha,BallotMissingState,BallotMissingRace,CountryIssue,OtherIssue,OtherIssueReason")] ComplainForm complainForm) { if (ModelState.IsValid) { complainForm.SourceIp = Request.UserHostAddress; complainForm.SaveDate = DateTimeOffset.Now; if (string.IsNullOrWhiteSpace(complainForm.VotingOtherLocation)) complainForm.VotingOtherLocation = string.Empty; else complainForm.VotingOtherLocation = complainForm.VotingOtherLocation.Trim(); if (string.IsNullOrWhiteSpace(complainForm.OtherIssueReason)) complainForm.OtherIssueReason = string.Empty; else complainForm.OtherIssueReason = complainForm.OtherIssueReason.Trim(); _db.ComplainForms.Add(complainForm); _db.SaveChanges(); try { var cfd = new ComplainFormDetail(complainForm); cfd.FillDataforKeys(_db); HostingEnvironment.QueueBackgroundWorkItem(ct => SendMailAsync(cfd)); } catch { //Ignore } return RedirectToAction("Details", new { id = complainForm.Id }); } await StoreStateInviewBag(); return View(complainForm); }
// GET: ComplainForms/Details/5 public async Task<ActionResult> Details(int id) { if (id <= 0) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } ComplainForm complainForm = await _db.ComplainForms.FirstOrDefaultAsync(e => e.Id == id); if (complainForm == null) { return HttpNotFound(); } var cfd = new ComplainFormDetail(complainForm); cfd.FillDataforKeys(_db); return View(cfd); }