public BTDetail GetBTById(int id) { using (var ctx = new ApplicationDbContext()) { BulkTechSamples entity = ctx.BulkTechSamples.SingleOrDefault(e => e.BTId == id); if (entity.Employee != null) { return(new BTDetail { BTId = entity.BTId, IsComplete = entity.IsComplete, DueOnDate = entity.DueOnDate, CompletedOnDate = entity.CompletedOnDate, Employee = entity.Employee.FirstName + " " + entity.Employee.LastName }); } else { return(new BTDetail { BTId = entity.BTId, IsComplete = entity.IsComplete, DueOnDate = entity.DueOnDate, CompletedOnDate = entity.CompletedOnDate }); } } }
//END OF TEST public bool DeleteBT(int id) { using (var ctx = new ApplicationDbContext()) { BulkTechSamples entity = ctx.BulkTechSamples.SingleOrDefault(e => e.BTId == id); ctx.BulkTechSamples.Remove(entity); return(ctx.SaveChanges() == 1); } }
//TEST public bool UpdateBTCompletedBy(BTEdit model) { using (var ctx = new ApplicationDbContext()) { BulkTechSamples entity = ctx.BulkTechSamples.SingleOrDefault(e => e.BTId == model.BTId); //entity.DueOnDate = model.DueOnDate; entity.CompletedOnDate = DateTime.Now; entity.IsComplete = true; entity.EmployeeId = model.EmployeeId; return(ctx.SaveChanges() == 1); } }
public bool BTCreate(BTCreate model) { BulkTechSamples entity = new BulkTechSamples() { DueOnDate = model.DueOnDate, IsComplete = false }; using (var ctx = new ApplicationDbContext()) { ctx.BulkTechSamples.Add(entity); return(ctx.SaveChanges() == 1); } }