public ActionResult Edit(Guid? id = null) { if (!id.HasValue) return new HttpNotFoundResult(); using (var context = new WorkOrderContext()) { var workOrder = context.WorkOrders.First(wo => wo.Id == id); var crews = context.Crews.OrderBy(c => c.Name).ToList(); var categories = context.WorkOrderCategories.OrderBy(c => c.Name).ToList(); var durations = new string[] { "", "1h", "2h", "4h", "1d", "2d", "3d", "4d", "5d" }; var crewId = workOrder.CrewId ?? crews[0].Id; var viewModel = new EditWorkOrderViewModel { Id = workOrder.Id, Title = "Edit Work Order", Date = workOrder.DateDisplay, Customer = workOrder.Customer, Description = workOrder.Description, CrewId = crewId, Crews = crews, Duration = workOrder.Duration, Durations = durations, CategoryId = workOrder.CategoryId, Categories = categories }; return View(viewModel); } }
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 Edit(Guid?id = null) { if (!id.HasValue) { return(new HttpNotFoundResult()); } using (var context = new WorkOrderContext()) { var workOrder = context.WorkOrders.First(wo => wo.Id == id); var crews = context.Crews.OrderBy(c => c.Name).ToList(); var categories = context.WorkOrderCategories.OrderBy(c => c.Name).ToList(); var durations = new string[] { "", "1h", "2h", "4h", "1d", "2d", "3d", "4d", "5d" }; var crewId = workOrder.CrewId ?? crews[0].Id; var viewModel = new EditWorkOrderViewModel { Id = workOrder.Id, Title = "Edit Work Order", Date = workOrder.DateDisplay, Customer = workOrder.Customer, Description = workOrder.Description, CrewId = crewId, Crews = crews, Duration = workOrder.Duration, Durations = durations, CategoryId = workOrder.CategoryId, Categories = categories }; return(View(viewModel)); } }
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 Index(Guid?crewId = null) { using (var context = new WorkOrderContext()) { if (!context.WorkOrders.Any(w => w.Date >= DateTime.Today)) { context.Reset(); } if (!(crewId.HasValue)) { var crews = context.Crews.OrderBy(c => c.Name).ToList(); var model = new ChooseCrewModel { Crews = crews }; return(View("ChooseCrew", model)); } var crew = context.Crews.FirstOrDefault(c => c.Id == crewId.Value); var workOrders = context.WorkOrders .Include(w => w.Crew) .Include(w => w.Category) .Include(w => w.WorkOrderLogs) .Where(w => !w.IsComplete && w.CrewId == crewId.Value) .ToList(); var viewModel = new CrewListViewModel(crew, workOrders); return(View(viewModel)); } }
public ActionResult Index(Guid? crewId = null) { using (var context = new WorkOrderContext()) { if (!context.WorkOrders.Any(w => w.Date >= DateTime.Today)) { context.Reset(); } if (!(crewId.HasValue)) { var crews = context.Crews.OrderBy(c => c.Name).ToList(); var model = new ChooseCrewModel { Crews = crews }; return View("ChooseCrew", model); } var crew = context.Crews.FirstOrDefault(c => c.Id == crewId.Value); var workOrders = context.WorkOrders .Include(w => w.Crew) .Include(w => w.Category) .Include(w => w.WorkOrderLogs) .Where(w => !w.IsComplete && w.CrewId == crewId.Value) .ToList(); var viewModel = new CrewListViewModel(crew, workOrders); return View(viewModel); } }
public WorkOrderService(WorkOrderContext context, IMapper mapper, IClaimsService claimsService, IPhotoService photoService) { _context = context; _mapper = mapper; _claimsService = claimsService; _photoService = photoService; }
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 PhotoService(IBlobStorageService blobService, WorkOrderContext context, IMapper mapper) { _blobService = blobService; _context = context; _mapper = mapper; _codec = GetEncoder(ImageFormat.Jpeg); var qualityEncoder = Encoder.Quality; _encoderParameters.Param[0] = new EncoderParameter(qualityEncoder, 25L); }
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 New() { using (var context = new WorkOrderContext()) { var crews = context.Crews.OrderBy(c => c.Name).ToList(); var categories = context.WorkOrderCategories.OrderBy(c => c.Name).ToList(); var durations = new string[] { "", "1h", "2h", "4h", "1d", "2d", "3d", "4d", "5d" }; var viewModel = new NewWorkOrderViewModel { Title = "New Work Order", Date = DateTime.Today.ToString("dd-MMM-yyyy"), Crews = crews, Durations = durations, Categories = categories }; return(View(viewModel)); } }
public ActionResult Reset(bool reset) { if (reset) { using (var context = new WorkOrderContext()) { context.Database.SqlQuery <int>("DELETE dbo.WorkOrderLogs"); context.Database.SqlQuery <int>("DELETE dbo.WorkOrders"); context.Database.SqlQuery <int>("DELETE dbo.Crews"); context.Database.SqlQuery <int>("DELETE dbo.WorkOrderCategories"); context.Database.SqlQuery <int>("DELETE dbo.__MigrationHistory"); context.Database.Initialize(true); } } 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 Index() { using (var context = new WorkOrderContext()) { if (!context.WorkOrders.Any(w => w.Date >= DateTime.Today)) { context.Reset(); } var workOrders = context.WorkOrders .Include(w => w.Crew) .Include(w => w.Category) .Include(w => w.WorkOrderLogs) .ToList(); var viewModel = new BossListViewModel(workOrders); return(View(viewModel)); } }
public ActionResult Index() { using (var context = new WorkOrderContext()) { if (!context.WorkOrders.Any(w => w.Date >= DateTime.Today)) { context.Reset(); } var workOrders = context.WorkOrders .Include(w => w.Crew) .Include(w => w.Category) .Include(w => w.WorkOrderLogs) .ToList(); var viewModel = new BossListViewModel(workOrders); return View(viewModel); } }
public ActionResult Edit(Guid id) { using (var context = new WorkOrderContext()) { var workOrder = context.WorkOrders.Include(w => w.WorkOrderLogs).FirstOrDefault(w => w.Id == id); var log = workOrder.WorkOrderLogs.FirstOrDefault() ?? new WorkOrderLog(); var viewModel = new EditWorkItemViewModel { Id = log.Id, WorkOrderId = workOrder.Id, Title = "Enter work for work order", Date = workOrder.DateDisplay, Customer = workOrder.Customer, Description = workOrder.Description, Duration = workOrder.Duration, Notes = log.Notes, CrewId = workOrder.CrewId.Value, IsComplete = workOrder.IsComplete }; return(View(viewModel)); } }
public ActionResult Edit(Guid id) { using (var context = new WorkOrderContext()) { var workOrder = context.WorkOrders.Include(w => w.WorkOrderLogs).FirstOrDefault(w => w.Id == id); var log = workOrder.WorkOrderLogs.FirstOrDefault() ?? new WorkOrderLog(); var viewModel = new EditWorkItemViewModel { Id = log.Id, WorkOrderId = workOrder.Id, Title = "Enter work for work order", Date = workOrder.DateDisplay, Customer = workOrder.Customer, Description = workOrder.Description, Duration = workOrder.Duration, Notes = log.Notes, CrewId = workOrder.CrewId.Value, IsComplete = workOrder.IsComplete }; return View(viewModel); } }
public WorkOrderHistoriesController(WorkOrderContext context) { _context = context; }
public WorkOrdersController(WorkOrderContext context) { _context = context; }
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 WorkOrdersController(IWorkOrderRepo repo, IMapper mapper, WorkOrderContext db) { _repo = repo; _mapper = mapper; _db = db; }
protected override void Seed(WorkOrderContext context) { if (context.WorkOrderCategories.Count() == 0) { var construction = new WorkOrderCategory { Id = Guid.NewGuid(), Name = "Construction", CssClass = "" }; var maintenance = new WorkOrderCategory { Id = Guid.NewGuid(), Name = "Maintenance", CssClass = "" }; context.WorkOrderCategories.AddOrUpdate(construction, maintenance); if (context.Crews.Count() == 0) { var jim = new Crew { Id = Guid.NewGuid(), Name = "Jim Robertson" }; var sam = new Crew { Id = Guid.NewGuid(), Name = "Sam Philips" }; var terry = new Crew { Id = Guid.NewGuid(), Name = "Terry Johnson" }; var pete = new Crew { Id = Guid.NewGuid(), Name = "Pete Smith" }; context.Crews.AddOrUpdate(jim, sam, terry, pete); if (context.WorkOrders.Count() == 0) { var wo = default(WorkOrder); var monday = DateTime.Today; while (monday.DayOfWeek == DayOfWeek.Saturday || monday.DayOfWeek == DayOfWeek.Sunday) { monday = monday.AddDays(1); } while (monday.DayOfWeek != DayOfWeek.Monday) { monday = monday.AddDays(-1); } // New Deck: 5 day job for (var i = 0; i < 5; i++) { wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = jim.Id, Crew = jim, CategoryId = construction.Id, Category = construction, Customer = "Mr. & Mrs. Ellington", Date = monday.AddDays(i), Description = "The Ellingtons would like to add a deck in the back, out the dining room patio doors. " + "Currently, there's a patio there, but it's in bad shape. They want to go with Trexx decking.", Duration = "5d" }; context.WorkOrders.AddOrUpdate(wo); } // Maintenance Jobs wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = sam.Id, Crew = sam, CategoryId = maintenance.Id, Category = maintenance, Customer = "John Jones", Date = monday, Description = "John needs a new faucet in the kitchen. Counter may need some reinforcement as well, as the " + "old one has been leaking, so there's some water damage.", Duration = "4h" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = sam.Id, Crew = sam, CategoryId = maintenance.Id, Category = maintenance, Customer = "Frank & Gladys Jackson", Date = monday, Description = "The Jacksons have leaky set of taps in their basement laundry tub. Could be just a new washer, but may " + "need a new set of taps.", Duration = "4h" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = sam.Id, Crew = sam, CategoryId = maintenance.Id, Category = maintenance, Customer = "Sally Smith", Date = monday.AddDays(1), Description = "Miss Smith has a wooden front door that she'd like replaced with an insulated steel door. Would like the new door to be red.", Duration = "1d" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = sam.Id, Crew = sam, CategoryId = maintenance.Id, Category = maintenance, Customer = "Mr. & Mrs. McArthur", Date = monday.AddDays(2), Description = "The McArthurs have a broken spindle on their stairway leading upstairs. Off-the-shelf pattern, so can get a new one at Home Depot.", Duration = "2h" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = sam.Id, Crew = sam, CategoryId = maintenance.Id, Category = maintenance, Customer = "Mrs. Brown", Date = monday.AddDays(2), Description = "Mrs. Brown has a cloggged tub. Could be that it just needs Draino, but might need a power snake to clean it out.", Duration = "2h" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = sam.Id, Crew = sam, CategoryId = maintenance.Id, Category = maintenance, Customer = "Mr. & Mrs. MacGillicuddy", Date = monday.AddDays(2), Description = "Garage door is stuck. Motor is likely OK - just came off the rail. May need new cable.", Duration = "2h" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = sam.Id, Crew = sam, CategoryId = maintenance.Id, Category = maintenance, Customer = "Patrick O'Reilly", Date = monday.AddDays(2), Description = "Patrick would like a new electrical outlet in his den. Junction box nearby.", Duration = "2h" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = sam.Id, Crew = sam, CategoryId = construction.Id, Category = construction, Customer = "Pete & Jane Tripp", Date = monday.AddDays(3), Description = "The Tripps would like some new light fixtures - one in the Dining Room and then a matching one in the kitchen. " + "These will need to be wired in, and secured in the ceiling.", Duration = "1d" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = sam.Id, Crew = sam, CategoryId = maintenance.Id, Category = maintenance, Customer = "Tom & Sally Peters", Date = monday.AddDays(4), Description = "Stair is broken on the front step & needs to be replaced.", Duration = "4h" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = sam.Id, Crew = sam, CategoryId = maintenance.Id, Category = maintenance, Customer = "Mr. & Mrs. Thompson", Date = monday.AddDays(4), Description = "There are several sections of deck railing that need to be replaced. The deck itself is pretty solid, but " + "the railings are getting rotten. Patch up what you can & replace what you have to.", Duration = "4h" }; context.WorkOrders.AddOrUpdate(wo); // Terry Jobs wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = terry.Id, Crew = terry, CategoryId = construction.Id, Category = construction, Customer = "Al Bennings", Date = monday, Description = "Al lives in an older home with a fuse panel & would like it upgraded to breakers. He also has some aluminum wiring that should be replaced.", Duration = "2d" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = terry.Id, Crew = terry, CategoryId = construction.Id, Category = construction, Customer = "Al Bennings", Date = monday.AddDays(1), Description = "Al lives in an older home with a fuse panel & would like it upgraded to breakers. He also has some aluminum wiring that should be replaced.", Duration = "2d" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = terry.Id, Crew = terry, CategoryId = construction.Id, Category = construction, Customer = "Steve Alberts", Date = monday.AddDays(2), Description = "Steve is building an addition, and needs the wiring done. He is doing most of the work himself, but needs us to come in " + "and wire it up for him.", Duration = "2d" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = terry.Id, Crew = terry, CategoryId = construction.Id, Category = construction, Customer = "Steve Alberts", Date = monday.AddDays(3), Description = "Steve is building an addition, and needs the wiring done. He is doing most of the work himself, but needs us to come in " + "and wire it up for him.", Duration = "2d" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = terry.Id, Crew = terry, CategoryId = construction.Id, Category = construction, Customer = "Polly Ebbertson", Date = monday.AddDays(4), Description = "Polly would like some new pot lights in her Living Room. She'll need 12 lights, and it's vaulted ceiling, " + "so we'll need the long ladder.", Duration = "1d" }; context.WorkOrders.AddOrUpdate(wo); // Pete's jobs wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = pete.Id, Crew = pete, CategoryId = construction.Id, Category = construction, Customer = "Jeremy & Sonya Phillips", Date = monday, Description = "The Phillips need a new roof. Remove the old one (need dumpster), and shingle the new one. They would like " + "brown architectural shingles, which will be delivered on Saturday.", Duration = "3d" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = pete.Id, Crew = pete, CategoryId = construction.Id, Category = construction, Customer = "Jeremy & Sonya Phillips", Date = monday.AddDays(1), Description = "The Phillips need a new roof. Remove the old one (need dumpster), and shingle the new one. They would like " + "brown architectural shingles, which will be delivered on Saturday.", Duration = "3d" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = pete.Id, Crew = pete, CategoryId = construction.Id, Category = construction, Customer = "Jeremy & Sonya Phillips", Date = monday.AddDays(2), Description = "The Phillips need a new roof. Remove the old one (need dumpster), and shingle the new one. They would like " + "brown architectural shingles, which will be delivered on Saturday.", Duration = "3d" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = pete.Id, Crew = pete, CategoryId = maintenance.Id, Category = maintenance, Customer = "Paul Matthewson", Date = monday.AddDays(3), Description = "Paul would like the windows replaced in all the bedrooms in the house.", Duration = "2d" }; context.WorkOrders.AddOrUpdate(wo); wo = new WorkOrder { Id = Guid.NewGuid(), CrewId = pete.Id, Crew = pete, CategoryId = construction.Id, Category = construction, Customer = "Paul Matthewson", Date = monday.AddDays(4), Description = "Paul would like the windows replaced in all the bedrooms in the house.", Duration = "2d" }; context.WorkOrders.AddOrUpdate(wo); } } } }
public LocationService(WorkOrderContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public ActionResult New() { using (var context = new WorkOrderContext()) { var crews = context.Crews.OrderBy(c => c.Name).ToList(); var categories = context.WorkOrderCategories.OrderBy(c => c.Name).ToList(); var durations = new string[] { "", "1h", "2h", "4h", "1d", "2d", "3d", "4d", "5d" }; var viewModel = new NewWorkOrderViewModel { Title = "New Work Order", Date = DateTime.Today.ToString("dd-MMM-yyyy"), Crews = crews, Durations = durations, Categories = categories }; return View(viewModel); } }
public ActionResult Reset(bool reset) { if (reset) { using (var context = new WorkOrderContext()) { context.Database.SqlQuery<int>("DELETE dbo.WorkOrderLogs"); context.Database.SqlQuery<int>("DELETE dbo.WorkOrders"); context.Database.SqlQuery<int>("DELETE dbo.Crews"); context.Database.SqlQuery<int>("DELETE dbo.WorkOrderCategories"); context.Database.SqlQuery<int>("DELETE dbo.__MigrationHistory"); context.Database.Initialize(true); } } return RedirectToAction("Index"); }
public CarService(WorkOrderContext context, IMapper mapper, IPhotoService photoService) { _context = context; _mapper = mapper; _photoService = photoService; }
public TechnicianService(WorkOrderContext context, IMapper mapper) { _context = context; _mapper = mapper; }