private CapabilityAssessment GetCapability(Guid capabilityId) { DataTable capabiltyAssessments = _seedData.Tables["CapabilityAssessment"]; CapabilityAssessment capabilityAssessment = null; DataRow row = capabiltyAssessments.Select("Id = '" + capabilityId.ToString() + "'").FirstOrDefault <DataRow>(); if (row != null) { capabilityAssessment = new CapabilityAssessment() { CapabilityAssessmentId = new Guid(row[0].ToString()), Description = row[1].ToString(), Abbreviation = row[2].ToString(), Name = row[3].ToString(), Status = row[4].ToString(), Assessed = (DateTime)row[5], Achieved = row[6].ToString(), Current = row[7].ToString(), Next = row[8].ToString(), Personnel = Convert.ToInt32(row[9]), Equipment = Convert.ToInt32(row[10]), Supply = Convert.ToInt32(row[11]), Training = Convert.ToInt32(row[12]), Ordnance = Convert.ToInt32(row[13]), Overall = Convert.ToInt32(row[14]) }; } return(capabilityAssessment); }
public async Task <IActionResult> PostCapabilityAssessment([FromBody] CapabilityAssessment capabilityAssessment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.CapabilityAssessments.Add(capabilityAssessment); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCapabilityAssessment", new { id = capabilityAssessment.Id }, capabilityAssessment)); }
private void SeedCapabilityAssessment() { DataTable table = _seedData.Tables["CapabilityAssessment"]; int rowcount = table.Rows.Count; for (int i = 0; i < rowcount; i++) { object[] columns = table.Rows[i].ItemArray; Guid CapabilityId = new Guid(columns[0].ToString()); CapabilityAssessment capabilityAssessment = new CapabilityAssessment { Id = CapabilityId, CapabilityAssessmentId = CapabilityId, Description = columns[1].ToString(), Abbreviation = columns[2].ToString(), Name = columns[3].ToString(), Status = columns[4].ToString(), Assessed = (DateTime)columns[5], Achieved = columns[6].ToString(), Current = columns[7].ToString(), Next = columns[8].ToString(), Personnel = Convert.ToInt32(columns[9]), Equipment = Convert.ToInt32(columns[10]), Supply = Convert.ToInt32(columns[11]), Training = Convert.ToInt32(columns[12]), Ordnance = Convert.ToInt32(columns[13]), Overall = Convert.ToInt32(columns[14]) }; _context.CapabilityAssessments.Add(capabilityAssessment); } _context.SaveChanges(); }
public async Task <IActionResult> PutCapabilityAssessment([FromRoute] Guid id, [FromBody] CapabilityAssessment capabilityAssessment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != capabilityAssessment.Id) { return(BadRequest()); } _context.Entry(capabilityAssessment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CapabilityAssessmentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }