public async Task <IActionResult> PutPharmDE([FromRoute] int id, [FromBody] PharmDE pharmDE) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != pharmDE.DetailID) { return(BadRequest()); } _context.Entry(pharmDE).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PharmDEExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostPharmDE([FromBody] PharmDE pharmDE) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.PharmDE.Add(pharmDE); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPharmDE", new { id = pharmDE.DetailID }, pharmDE)); }
public async Task <IEnumerable <string> > GenerateFiles([FromRoute] int scheduleId) { List <PharmBatch> batches = await _context.PharmBatch.Where(x => x.ScheduleId == scheduleId).ToListAsync(); foreach (PharmBatch batch in batches) { PharmHeader header = await _context.PharmHeader.FirstOrDefaultAsync(x => x.BatchId == batch.BatchId); if (header == null) { continue; } ExportHeader(ref header); List <PharmDE> details = await _context.PharmDE.Where(x => x.BatchId == batch.BatchId).ToListAsync(); if (details.Count() == 0) { continue; } foreach (PharmDE detail in details) { PharmDE refDetail = detail; ExportDetail(ref refDetail); PharmCD1 compound1 = await _context.PharmCD1.FirstOrDefaultAsync(x => x.DetailID == detail.DetailID); if (compound1 != null) { ExportCompound1(ref compound1); PharmCD2 compound2 = await _context.PharmCD2.FirstOrDefaultAsync(x => x.DetailID == detail.DetailID); if (compound2 != null) { ExportCompound2(ref compound2); } } } ExportTrailer(ref header); } return(new string[] { "pharmacy", "file generation complete" }); }
private void ExportDetail(ref PharmDE detail) { }