public async Task <IActionResult> Edit(int id, [Bind("Investigationid,Investigationprof")] Investigation investigation) { if (id != investigation.Investigationid) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(investigation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvestigationExists(investigation.Investigationid)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(investigation)); }
void updateAvailableInfo() { InvestigationManager im = InvestigationManager.GetInstance(); List <Investigation> investigations = im.getAvailableInvestigations(); if (investigations.Count == 0) { investigationButton.interactable = false; investigationButtonText.text = Dictionary.getString("ALL_RESEARCHED"); nameText.text = ""; priceText.text = ""; descriptionText.text = ""; } else { Investigation selectedInvest = im.getInvestigation(selectedId); nameText.text = selectedInvest.getName(); priceText.text = " " + Dictionary.getString("COST") + " " + selectedInvest.getCost(); descriptionText.text = selectedInvest.getDesc(); investigationButton.interactable = true; investigationButtonText.text = Dictionary.getString("RESEARCH"); //selectedInvest.printInfo (); } }
public static Dictionary <int, Investigation> getReadInvestigations() { Dictionary <int, Investigation> invList = new Dictionary <int, Investigation> (); TextAsset file = Resources.Load("json/investigations", typeof(TextAsset)) as TextAsset; if (file != null) { JSONNode node = JSON.Parse(file.text); for (int j = 0; j < node["INVESTIGATIONS"].Count; ++j) { JSONNode nodeDeeper = node["INVESTIGATIONS"][j]; int id = nodeDeeper ["ID"].AsInt; string name = Dictionary.getString(nodeDeeper["NAME"].Value); string description = Dictionary.getString(nodeDeeper["DESCRIPTION"].Value); string img = nodeDeeper["IMAGE"].Value; int year = nodeDeeper ["YEAR"].AsInt; int req = nodeDeeper ["REQ"].AsInt; int cost = nodeDeeper ["COST"].AsInt; Investigation inv = new Investigation(id, name, description, img, year, req, cost); invList.Add(id, inv); } } else { Debug.Log("File json/investigations not loaded"); } return(invList); }
private void ClearAllInvestigations(Func <Investigation, bool> filter) { IList <Investigation> list = (IList <Investigation>)((ListCollectionView)Application.Current.Resources[ "InvestigationCollectionView"]).SourceCollection; if (!(filter == null)) { try { for (int i = 0; i < Investigation.inv_number; i++) { Investigation inv = list[i]; if (inv.Filled && filter(inv)) { list[i] = new Investigation(); } } ReSortInvestigations(); } catch { MessageBox.Show("Supplied expression failed.", "Error", MessageBoxButton.OK); } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Date,Summary,isPrivate,LocationId")] Investigation investigation) { if (id != investigation.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var currentUser = await GetCurrentUserAsync(); investigation.UserId = currentUser.Id; _context.Update(investigation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvestigationExists(investigation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["LocationId"] = new SelectList(_context.Location, "Id", "Summary", investigation.LocationId); return(View(investigation)); }
public async Task <ActionResult <Investigation> > PostInvestigation(Investigation investigation) { _context.Investigation.Add(investigation); await _context.SaveChangesAsync(); return(CreatedAtAction("GetInvestigation", new { id = investigation.CaseId }, investigation)); }
public async Task <IActionResult> AssignReportToInvestigation(InvestigationViewModel model) { //1. create new investigation if (ModelState.IsValid) { var newInvestigation = new Investigation() { //note, since an investigation can only have one report from report the status can be taken ReportId = model.ReportId, InvestigationDescription = model.InvestigationDescription, InvestigatorId = model.InvestigatorId }; _investigationService.CreateInvestigation(newInvestigation); var alterRep = _reportService.GetReportById(model.ReportId); alterRep.ReportStatus = model.InvestigationStatus; alterRep.ReportInvestigatorId = model.InvestigatorId; await _reportService.EditReport(alterRep); var user = await _userManager.GetUserAsync(HttpContext.User); var reporter = await _userManager.FindByIdAsync(alterRep.ReportReporterId); var reporterEmail = _userService.GetUserEmail(reporter); _emailService.SendEmail(reporter.Email, alterRep.ReportTitle + ", is assigned to a new investigation", user.UserName + EmailBodyContent.AssignInvestigationToReport + alterRep.ReportTitle); return(RedirectToAction("Index")); } //2. if 1==success - alter the report (I) change status (II) add investigatorid to report //----???---- shall we add investigaion id to report? n/y? return(RedirectToAction("Index")); }
public void newYear() { // Se dan por investigadas las que se estaban investigando foreach (Investigation i in m_invest.Values) { if (i.isInvestigating()) { m_invest[i.getID()].setInvestigating(false); m_invest[i.getID()].setPurchased(true); doInvestigatedEffect(i.getID()); } } // Se crean carteles para nuevas invs disponibles List <Investigation> availableInvs = getAvailableInvestigations(); TimeManager tm = GameObject.Find("Logic").GetComponent <TimeManager>(); for (int i = availableInvs.Count - 1; i >= 0; --i) { Investigation currentInv = availableInvs [i]; if (currentInv.getYear() == tm.getCurrentYear()) { GameObject panelTemplate = Resources.Load("Prefabs/InvestigationUnlockedFocusLayer") as GameObject; GameObject panelInstance = GameObject.Instantiate(panelTemplate); GameObject panel = panelInstance.transform.FindChild("InvestigationUnlockedPanel").gameObject; string text = Dictionary.getString("INVESTIGATION_UNLOCKED") + " " + currentInv.getName(); panel.GetComponent <InvestigationUnlockedPanel> ().ChangeText(text); } } }
public async Task <IActionResult> PutInvestigation(long?id, Investigation investigation) { if (id != investigation.CaseId) { return(BadRequest()); } _context.Entry(investigation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvestigationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> OnGetAsync(int id) { Investigation = await _context.Investigation .Include(m => m.MalfunctionWorkOrder) .ThenInclude(m => m.Instrument) .Include(m => m.MalfunctionWorkOrder) .ThenInclude(m => m.MalfunctionInfo) .FirstOrDefaultAsync(m => m.ID == id); if (Investigation == null) { return(NotFound()); } // 如果工单已完成则跳转到工单详情页 if (Investigation.MalfunctionWorkOrder.Progress == WorkOrderProgress.Completed) { return(RedirectToPage("../WorkOrders/Details", new { id = Investigation.MalfunctionWorkOrderID })); } var isAuthorized = await _authorizationService.AuthorizeAsync(User, Investigation.MalfunctionWorkOrder, Operations.Update); if (!isAuthorized.Succeeded) { return(Forbid()); } MalfunctionPartSelectList = new SelectList(_context.MalfunctionParts.AsNoTracking(), "Name", "Name"); MalfunctionReasonSelectList = new SelectList(_context.MalfunctionReason.AsNoTracking(), "Reason", "Reason"); return(Page()); }
public async Task <IActionResult> Edit(int id, [Bind("Id, ReportId, ReportStatus, Description, ActionTakenOn")] InvestigationViewModel editInvestigation) { try { if (id != editInvestigation.Id) { return(NotFound()); } // Gets old investigation (for use later) var oldInvestigation = _investigationRepository.GetInvestigationtById(id); if (oldInvestigation != null) { var user = await _userManager.GetUserAsync(User); // Checks that current signed in user owns the investigation if (oldInvestigation.Investigator.Id == user.Id) { // Checks that model is valid if (ModelState.IsValid) { // Fetches report and sets the new status Report report = _reportRepository.GetReportById(editInvestigation.ReportId); report.Status = editInvestigation.ReportStatus; Investigation updatedInvestigation = new Investigation() { Id = editInvestigation.Id, Report = _reportRepository.GetReportById(editInvestigation.ReportId), DescriptionOfInvestigation = editInvestigation.Description, InvestigatedOn = oldInvestigation.InvestigatedOn, DateOfAction = editInvestigation.ActionTakenOn, Investigator = await _userManager.GetUserAsync(User) }; // Update the investigation with the new details _investigationRepository.UpdateInvestigation(updatedInvestigation); return(RedirectToAction("ViewReports", "Report")); } else { return(View(editInvestigation)); } } else { return(Unauthorized()); } } else { return(NotFound()); } } catch (Exception e) { _logger.LogError(e.Message); return(View("Error")); } }
public async Task should_handle_the_initial_state() { var harness = new InMemoryTestHarness(); _machine = new InvestigationStateMachine(new List <Provider>()); StateMachineSagaTestHarness <Investigation, InvestigationStateMachine> saga = harness.StateMachineSaga <Investigation, InvestigationStateMachine>(_machine); await harness.Start(); var searchRequestedEvent = SearchRequested.Create(new PeopleSearchRequest("test", "test", "test")); try { await harness.InputQueueSendEndpoint.Send(searchRequestedEvent); Assert.IsTrue(harness.Consumed.Select <SearchRequested>().Any(), "Message not received"); Investigation instance = saga.Created.Select(x => x.CorrelationId == searchRequestedEvent.CorrelationId) .FirstOrDefault() ?.Saga; Assert.IsNotNull(instance, "Saga instance not found"); Assert.AreEqual(instance.CurrentState, nameof(_machine.Started)); } finally { await harness.Stop(); } }
public IHttpActionResult PutInvestigation(string id, Investigation investigation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != investigation.MRDno) { return(BadRequest()); } db.Entry(investigation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!InvestigationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostInvestigation(Investigation investigation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Investigations.Add(investigation); try { db.SaveChanges(); } catch (DbUpdateException) { if (InvestigationExists(investigation.MRDno)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = investigation.MRDno }, investigation)); }
public async Task <IActionResult> CreateInvestigation(int reportID, int setStatus, [Bind("DateOfAction, Description")] Investigation investigation) //The Bind maps the fields from the form into the properties of the Investigation object { if (ModelState.IsValid) //If the posted form data is valid //Creating a new investigation object (using the predefined constructor in the investigation class) { Investigation investigationToAdd = new Investigation(); investigationToAdd.ReportId = reportID; investigationToAdd.DateOfAction = investigation.DateOfAction; investigationToAdd.Description = investigation.Description; //Here I am getting the report object to which the investigation in question is related Report repToUpdate = _context.Reports.Where(r => r.ReportId == reportID).SingleOrDefault(); repToUpdate.Status = (status)setStatus; _context.Reports.Update(repToUpdate); //Update the reports table _context.Investigations.Add(investigationToAdd); //Add the new investigation to the investigations table await _context.SaveChangesAsync(); //V.IMP to save changes! //We want to send an email to the user when an investigation is added to their report //Here I am getting the object of the user who submitted the report in question User user = _context.Users.Where(u => u.UserId == repToUpdate.ReporterId).SingleOrDefault(); //Here I am storing the link to the investigation in question string link = "https://*****:*****@gmail.com")); //To address (including name and email of receipient) message.To.Add(new MailboxAddress(user.FullName, user.Email)); //Subject message.Subject = "An Investigation has been Added to your Report \"" + repToUpdate.TypeOfHazard + "\""; //Body - I want to send HTML rather than just plain text, so I have to user a BodyBuilder object BodyBuilder bodyBuilder = new BodyBuilder(); bodyBuilder.HtmlBody = "<h1 style='text-align:center; font-family: Arial;'>An Investigation has been added to Your Report <br/> <span style='font-size:32px;font-weight:300;font-family: Courier New;'>\"" + repToUpdate.TypeOfHazard + "\"</span></h1>" + "<br/><span style='display:block;text-align:center;margin-bottom:15px;'><a href='" + link + "' style='font-size:22px;color:white;background-color:#BA0C2F;text-decoration:none;padding:15px;'>View Investigation</a></span>"; message.Body = bodyBuilder.ToMessageBody(); //Configure and send email using (var client = new SmtpClient()) { //Without this line of code, the SSL certificate handshake fails and an exception is thrown. client.ServerCertificateValidationCallback = (s, c, h, e) => true; //Connecting to gmail's smtp server client.Connect("smtp.gmail.com", 587, false); //This is the username and the password of the sender client.Authenticate("*****@*****.**", "NEMESYSAPP123"); //Sending the message client.Send(message); client.Disconnect(true); } return(RedirectToAction("Details", "Report", new { id = reportID })); } else { //If posted form data is invalid, stay on the create report page return(RedirectToAction("CreateInvestigation", "Investigation", new { forReportID = reportID })); } }
public ActionResult DeleteConfirmed(int id) { Investigation investigation = db.Investigations.Find(id); db.Investigations.Remove(investigation); db.SaveChanges(); return(RedirectToAction("Index")); }
public override global::System.Data.DataSet Clone() { Investigation cln = ((Investigation)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public void Remove(Investigation investigate) { if (Context.Entry(investigate).State == EntityState.Detached) { context.Investigations.Attach(investigate); } context.Investigations.Remove(investigate); }
public void two_different_Investigation_objects_with_default_values_are_equal() { Investigation investigation1 = new Investigation(); Investigation investigation2 = new Investigation(); bool actual = Equals(investigation1, investigation2); Assert.That(actual, Is.True); }
public void two_different_Investigation_objects_are_not_reference_equal() { Investigation investigation1 = new Investigation(); Investigation investigation2 = new Investigation(); bool actual = investigation1 == investigation2; Assert.That(actual, Is.False); }
public async Task <IActionResult> EditInvestigation(int id, [Bind("InvestigationId", "Report", "Description", "DateOfAction", "Status")] EditInvestigation updatedInvestigation) { ViewBag.status = new SelectList(statusoptions); try { //1. Check for incoming data integrity if (id != updatedInvestigation.InvestigationId) { return(NotFound()); } //2. Check if the user has access to this investigation Investigation existingInvestigation = _investigationRepository.GetReportByInvestigationId(id); if (existingInvestigation != null) { var currentUser = await _userManager.GetUserAsync(User); if (existingInvestigation.Investigator.IdNum == currentUser.IdNum) { //2. Validate model if (ModelState.IsValid) { Investigation updated_Investigation = new Investigation() { InvestigationId = updatedInvestigation.InvestigationId, Investigator = await _userManager.GetUserAsync(User), Report = existingInvestigation.Report, Description = updatedInvestigation.Description, DateOfAction = DateTime.UtcNow }; // Updating status of report _reportRepository.UpdateStatus(existingInvestigation.Report.ReportId, updatedInvestigation.Status); _investigationRepository.UpdateInvestigation(updated_Investigation); return(RedirectToAction("Index")); } else { return(View(updatedInvestigation)); } } return(Unauthorized()); } else { return(RedirectToAction("Index")); } } catch (Exception ex) { _logger.LogError(ex.Message); return(View("Error")); } }
public void ShouldReturnName() { //assign ISkill actualSkillBase = new Investigation(); //act ITextObj name = actualSkillBase.Name(); //assert name.Should().Be(new TextObj("Investigation")); }
public void Bonus_InvestigationSpecified_ShouldWork() { SetupCharacter(); Skills investigation = new Investigation(true, true); Assert.AreEqual(-5, investigation.Bonus); Assert.IsTrue(investigation.Proficiency); Assert.IsTrue(investigation.Expertise); }
public async Task <IActionResult> Create([Bind("Investigationid,Investigationprof")] Investigation investigation) { if (ModelState.IsValid) { _context.Add(investigation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(investigation)); }
public void ShouldReturnWisdomAsBaseAttribute() { //arrange ISkill skill = new Investigation(); ICharacterAttribute intellegenceAttribute = new IntellegenceAttribute(); //act ICharacterAttribute actualAttribute = skill.BaseAttribute(); //assert actualAttribute.Should().Be(intellegenceAttribute); }
public ActionResult Edit([Bind(Include = "Id,InvestigationDetails,InvestigationStartDate,InvestigationEndDate,EmployeeId")] Investigation investigation) { if (ModelState.IsValid) { db.Entry(investigation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "EmployeeName", investigation.EmployeeId); return(View(investigation)); }
public IHttpActionResult GetInvestigation(string id) { Investigation investigation = db.Investigations.Find(id); if (investigation == null) { return(NotFound()); } return(Ok(investigation)); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { Investigation ds = new Investigation(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public async Task Create(Investigation investigation) { InvestigationPersonService ipService = new(); InvestigationWebService ws = new(); var p = await ipService.Create(investigation.InvestigationOffenderId); var p2 = await ipService.Create(investigation.InvestigationPlaintiffId); investigation.InvestigationOffenderId.InvestigationPersonId = p.InvestigationPersonId; investigation.InvestigationPlaintiffId.InvestigationPersonId = p2.InvestigationPersonId; await ws.CreateInvestigationAsync(Map(investigation)); }
public void TestMethod1() { // Arrange PhysicalPersonModel phycalPerson = new PhysicalPersonModel("julio cesar", "11298978699", "10/10/2010", "selma irene"); PhysicalPersonCoordinator coordinator = new PhysicalPersonCoordinator(phycalPerson); // Act Investigation investigation = coordinator.Run(); // Assert Assert.Equals(investigation.Completed, true); }