public IActionResult Reject(int EventID) { QuestionableEvent chosenEvent = _context.QuestionableEvents.Find(EventID); chosenEvent.status = QuestionableEventStatus.UserRejected; chosenEvent.UpdatedTimestamp = DateTime.Now; Trigger linkedTrigger = chosenEvent.LinkedAlertTrigger; if (linkedTrigger.IgnoredEvents == null) { linkedTrigger.IgnoredEvents = new string[] { chosenEvent.UserField, chosenEvent.IPAddressField } } ; else { string[] newIgnoredEvents = new string[linkedTrigger.IgnoredEvents.Count() + 2]; Array.Copy(linkedTrigger.IgnoredEvents, 0, newIgnoredEvents, 0, linkedTrigger.IgnoredEvents.Count()); newIgnoredEvents[linkedTrigger.IgnoredEvents.Count()] = chosenEvent.UserField; newIgnoredEvents[linkedTrigger.IgnoredEvents.Count() + 1] = chosenEvent.IPAddressField; linkedTrigger.IgnoredEvents = newIgnoredEvents; } _context.QuestionableEvents.Update(chosenEvent); _context.AlertTriggers.Update(linkedTrigger); _context.SaveChanges(); TempData["Alert"] = "Success"; TempData["Message"] = "Your response has been recorded successfully"; return(RedirectToAction("View", new { EventID = chosenEvent.ID })); }
public IActionResult ChangeState(int EventID) { QuestionableEvent qe = _logContext.QuestionableEvents.Find(EventID); if (qe.status.Equals(QuestionableEventStatus.UserAccepted) || qe.status.Equals(QuestionableEventStatus.AdminAccepted)) { qe.status = QuestionableEventStatus.LockedAccepted; } else if (qe.status.Equals(QuestionableEventStatus.UserRejected) || qe.status.Equals(QuestionableEventStatus.AdminRejected)) { qe.status = QuestionableEventStatus.LockedRejected; } else if (qe.status.Equals(QuestionableEventStatus.LockedAccepted) && qe.ReviewUserID > 0) { qe.status = QuestionableEventStatus.UserAccepted; } else if (qe.status.Equals(QuestionableEventStatus.LockedRejected) && qe.ReviewUserID > 0) { qe.status = QuestionableEventStatus.UserRejected; } else if (qe.status.Equals(QuestionableEventStatus.LockedAccepted)) { qe.status = QuestionableEventStatus.AdminAccepted; } else if (qe.status.Equals(QuestionableEventStatus.LockedRejected)) { qe.status = QuestionableEventStatus.AdminRejected; } _logContext.QuestionableEvents.Update(qe); _logContext.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult View(int EventID) { QuestionableEvent chosenEvent = _context.QuestionableEvents.Find(EventID); return(View(new QuestionableEventReviewViewModel { ReviewEvent = chosenEvent, SupplmentaryInformation = ipStackClient.GetIpAddressDetails(chosenEvent.IPAddressField) })); }
public IActionResult Accept(int EventID) { QuestionableEvent chosenEvent = _context.QuestionableEvents.Find(EventID); chosenEvent.status = QuestionableEventStatus.UserAccepted; chosenEvent.UpdatedTimestamp = DateTime.Now; _context.QuestionableEvents.Update(chosenEvent); _context.SaveChanges(); TempData["Alert"] = "Success"; TempData["Message"] = "Your response has been recorded successfully"; return(RedirectToAction("View", new { EventID = chosenEvent.ID })); }
public async Task <IActionResult> Index(int EventID, int UserID) { QuestionableEvent qe = _logContext.QuestionableEvents.Find(EventID); User concerned = await _accountContext.Users.FindAsync(UserID); Alert a = new Alert { TimeStamp = DateTime.Now, LinkedUserID = concerned.ID, LinkedObjectID = qe.LinkedAlertTrigger.LinkedLogInputID, AlertType = AlertType.ReviewQuestionableEvent, Message = "There is a event that needs your review" }; if (concerned.LinkedSettings.CommmuicationOptions.Equals(CommmuicationOptions.EMAIL) && concerned.VerifiedEmailAddress) { SendEmailRequest SESrequest = new SendEmailRequest { Source = Environment.GetEnvironmentVariable("SES_EMAIL_FROM-ADDRESS"), Destination = new Destination { ToAddresses = new List <string> { concerned.EmailAddress } }, Message = new Message { Subject = new Content("Review of Event needed"), Body = new Body { Text = new Content { Charset = "UTF-8", Data = "Hi " + concerned.Name + ",\r\n\nAn event needs your review.\r\nPlease login to SmartInsights to view more details.\r\n\n\nThis is a computer-generated email, please do not reply" } } } }; SendEmailResponse response = await _SESClient.SendEmailAsync(SESrequest); if (response.HttpStatusCode != HttpStatusCode.OK) { a.ExternalNotificationType = ExternalNotificationType.EMAIL; } } else if (concerned.LinkedSettings.CommmuicationOptions.Equals(CommmuicationOptions.SMS) && concerned.VerifiedPhoneNumber) { PublishRequest SNSrequest = new PublishRequest { Message = "An event needs your review. Login to view more details.", PhoneNumber = "+65" + concerned.PhoneNumber }; SNSrequest.MessageAttributes["AWS.SNS.SMS.SenderID"] = new MessageAttributeValue { StringValue = "SmartIS", DataType = "String" }; SNSrequest.MessageAttributes["AWS.SNS.SMS.SMSType"] = new MessageAttributeValue { StringValue = "Transactional", DataType = "String" }; PublishResponse response = await _SNSClient.PublishAsync(SNSrequest); if (response.HttpStatusCode != HttpStatusCode.OK) { a.ExternalNotificationType = ExternalNotificationType.SMS; } } _accountContext.Alerts.Add(a); qe.ReviewUserID = concerned.ID; _logContext.QuestionableEvents.Update(qe); await _accountContext.SaveChangesAsync(); await _logContext.SaveChangesAsync(); return(View(_logContext.QuestionableEvents.ToList())); }