public async Task <ActionResult <AuditFinding> > PostAuditFinding(AuditFinding auditFinding) { _context.AuditFinding.Add(auditFinding); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAuditFinding", new { id = auditFinding.AuditFindingId }, auditFinding)); }
/// <summary> /// Asserts that the given entity exists in DB. /// </summary> /// <param name="entity">The entity to check.</param> protected static void AssertEntityExists(AuditFinding entity) { var parameters = new Dictionary <string, object>(); parameters["AuditFindingNumber"] = entity.AuditFindingNumber; parameters["BusinessUnit_Id"] = entity.BusinessUnit?.Id; parameters["AuditTitle"] = entity.AuditTitle; parameters["RootCause_Id"] = entity.RootCause?.Id; parameters["RootCauseDetail"] = entity.RootCauseDetail; parameters["Source_Id"] = entity.Source?.Id; parameters["MitigationStrategy"] = entity.MitigationStrategy; parameters["AuditYear_Id"] = entity.AuditYear?.Id; parameters["AuditMonth_Id"] = entity.AuditMonth?.Id; parameters["RemediationYear_Id"] = entity.RemediationYear?.Id; parameters["RemediationMonth_Id"] = entity.RemediationMonth?.Id; parameters["Status_Id"] = entity.Status?.Id; parameters["ReportedToGORM_Id"] = entity.ReportedToGORM?.Id; parameters["ReportedToORMYear_Id"] = entity.ReportedToORMYear?.Id; parameters["ReportedToORMMonth_Id"] = entity.ReportedToORMMonth?.Id; parameters["CompletionType"] = entity.CompletionType; parameters["CreatedBy"] = entity.CreatedBy; parameters["CreatedTime"] = entity.CreatedTime; parameters["LastUpdatedBy"] = entity.LastUpdatedBy; parameters["LastUpdatedTime"] = entity.LastUpdatedTime; parameters["Id"] = entity.Id; TestHelper.AssertDatabaseRecordExists(typeof(AuditFinding).Name, parameters); AssertManyToManyMappings(entity.Id, entity.Impact, "AuditFinding_AuditFindingImpactValue", "AuditFindingId", "AuditFindingImpactValueId"); }
public async Task <IActionResult> PutAuditFinding(int id, AuditFinding auditFinding) { if (id != auditFinding.AuditFindingId) { return(BadRequest()); } _context.Entry(auditFinding).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuditFindingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public long Create(AuditFinding entity) { CommonHelper.ValidateArgumentNotNull(entity, nameof(entity)); Helper.ValidateTodayIsAllowedUpdateDate(entity.AuditYear, entity.AuditMonth, InputAllowedInDays); // populate audit fields PopulateAuditFields(entity, null, creating: true); return AuditFindingService.Create(entity).Id; }
public void TestGetAccuracy2() { // arrange long id = 3; // act AuditFinding result = instance.Get(id); // assert AssertResult(result); }
public void TestCreateAccuracy() { // arrange AuditFinding entity = CreateTestEntity <AuditFinding>(7); // act AuditFinding result = instance.Create(entity); // assert AssertEntityExists(entity); result.Id = 0; AssertResult(result); }
public void TestUpdateAccuracy() { // arrange AuditFinding entity = CreateTestEntity <AuditFinding>(5); entity.Id = 2; // act AuditFinding result = instance.Update(entity); // assert AssertEntityExists(entity); AssertResult(result); }
public AuditFinding Update(long id, AuditFinding entity) { CommonHelper.ValidateArgumentNotNull(entity, nameof(entity)); Helper.ValidateTodayIsAllowedUpdateDate(entity.AuditYear, entity.AuditMonth, InputAllowedInDays); var existing = AuditFindingService.Get(id); if (!IsAdmin()) { Helper.ValidateStatusIsDraft(existing.Status); } // populate audit fields PopulateAuditFields(entity, existing); entity.Id = id; return AuditFindingService.Update(entity); }
public static AuditFinding CreateAuditFinding(int ID, string findingReference, string findingDescription, global::System.DateTime findingDate, global::System.DateTime targetResolutionDate, byte[] rowVersion) { AuditFinding auditFinding = new AuditFinding(); auditFinding.Id = ID; auditFinding.FindingReference = findingReference; auditFinding.FindingDescription = findingDescription; auditFinding.FindingDate = findingDate; auditFinding.TargetResolutionDate = targetResolutionDate; auditFinding.RowVersion = rowVersion; return auditFinding; }
public void AddToAuditFindings(AuditFinding auditFinding) { base.AddObject("AuditFindings", auditFinding); }