public IActionResult Create(WorkOrder workOrder) { _context.WorkOrderItems.Add(workOrder); _context.SaveChanges(); return(CreatedAtRoute("GetWorkOrder", new WorkOrder { id = workOrder.id }, workOrder)); }
public ActionResult Index(WorkOrderLog input, Guid crewId, bool isComplete) { using (var context = new WorkOrderContext()) { var workOrder = context.WorkOrders.Include(w => w.WorkOrderLogs).First(w => w.Id == input.WorkOrderId); workOrder.IsComplete = isComplete; var signatureValue = Request.Form["Signature"]; if (!string.IsNullOrEmpty(signatureValue)) { var signature = JsonConvert.DeserializeObject <Signature>(signatureValue); var converter = new SignatureToImage(); var image = converter.SigJsonToImage(signatureValue); } if (!workOrder.WorkOrderLogs.Any()) { input.Date = DateTime.Now; workOrder.WorkOrderLogs.Add(input); } else { var log = workOrder.WorkOrderLogs.First(); log.Date = DateTime.Now; log.Notes = input.Notes; } context.SaveChanges(); return(RedirectToAction("Index", new { crewId = crewId })); } }
public ActionResult Save(Guid?id, WorkOrder input) { using (var context = new WorkOrderContext()) { context.Entry(input).State = System.Data.EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Index")); } }
public void Reset(WorkOrderContext context) { context.Database.ExecuteSqlCommand("Delete dbo.WorkOrderLogs"); context.Database.ExecuteSqlCommand("Delete dbo.WorkOrders"); context.Database.ExecuteSqlCommand("Delete dbo.WorkOrderCategories"); context.Database.ExecuteSqlCommand("Delete dbo.Crews"); Seed(context); context.SaveChanges(); }
public WorkOrderController(WorkOrderContext context) { _context = context; if (_context.WorkOrderItems.Count() == 0) { _context.WorkOrderItems.Add(new WorkOrder { short_description = "sample workOrder1" }); _context.SaveChanges(); } }
public ActionResult Index(WorkOrder input) { using (var context = new WorkOrderContext()) { input.Id = Guid.NewGuid(); context.WorkOrders.Add(input); if (input.Duration.EndsWith("d", StringComparison.InvariantCultureIgnoreCase)) { var duration = default(int); if (int.TryParse(input.Duration.Replace("d", ""), out duration)) { duration--; var days = 1; var date = input.Date.HasValue ? input.Date : (null as DateTime?); while (days <= duration) { if (date.HasValue) { date = date.Value.AddDays(1); if (date.Value.DayOfWeek == DayOfWeek.Saturday) { date = date.Value.AddDays(2); } if (date.Value.DayOfWeek == DayOfWeek.Sunday) { date = date.Value.AddDays(1); } } var nextWorkOrder = new WorkOrder { Id = Guid.NewGuid(), CategoryId = input.CategoryId, CrewId = input.CrewId, Customer = input.Customer, Description = input.Description, Duration = input.Duration, Date = date }; context.WorkOrders.Add(nextWorkOrder); days++; } } } context.SaveChanges(); return(RedirectToAction("Index")); } }
public ActionResult Index(WorkOrder input) { using(var context = new WorkOrderContext()) { input.Id = Guid.NewGuid(); context.WorkOrders.Add(input); if (input.Duration.EndsWith("d", StringComparison.InvariantCultureIgnoreCase)) { var duration = default(int); if (int.TryParse(input.Duration.Replace("d", ""), out duration)) { duration--; var days = 1; var date = input.Date.HasValue ? input.Date : (null as DateTime?); while (days <= duration) { if (date.HasValue) { date = date.Value.AddDays(1); if(date.Value.DayOfWeek == DayOfWeek.Saturday){ date = date.Value.AddDays(2); } if (date.Value.DayOfWeek == DayOfWeek.Sunday) { date = date.Value.AddDays(1); } } var nextWorkOrder = new WorkOrder { Id = Guid.NewGuid(), CategoryId=input.CategoryId, CrewId=input.CrewId, Customer=input.Customer, Description=input.Description, Duration=input.Duration, Date = date }; context.WorkOrders.Add(nextWorkOrder); days++; } } } context.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Save(Guid? id, WorkOrder input) { using (var context = new WorkOrderContext()) { context.Entry(input).State = System.Data.EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Index(WorkOrderLog input, Guid crewId, bool isComplete) { using (var context = new WorkOrderContext()) { var workOrder = context.WorkOrders.Include(w => w.WorkOrderLogs).First(w => w.Id == input.WorkOrderId); workOrder.IsComplete = isComplete; var signatureValue = Request.Form["Signature"]; if (!string.IsNullOrEmpty(signatureValue)) { var signature = JsonConvert.DeserializeObject<Signature>(signatureValue); var converter = new SignatureToImage(); var image = converter.SigJsonToImage(signatureValue); } if (!workOrder.WorkOrderLogs.Any()) { input.Date = DateTime.Now; workOrder.WorkOrderLogs.Add(input); } else { var log = workOrder.WorkOrderLogs.First(); log.Date = DateTime.Now; log.Notes = input.Notes; } context.SaveChanges(); return RedirectToAction("Index", new { crewId = crewId }); } }