コード例 #1
0
        public IActionResult Create(WorkOrder workOrder)
        {
            _context.WorkOrderItems.Add(workOrder);
            _context.SaveChanges();

            return(CreatedAtRoute("GetWorkOrder", new WorkOrder {
                id = workOrder.id
            }, workOrder));
        }
コード例 #2
0
ファイル: WorkController.cs プロジェクト: Resounding/Work
        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 }));
            }
        }
コード例 #3
0
        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"));
            }
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        public WorkOrderController(WorkOrderContext context)
        {
            _context = context;

            if (_context.WorkOrderItems.Count() == 0)
            {
                _context.WorkOrderItems.Add(new WorkOrder {
                    short_description = "sample workOrder1"
                });
                _context.SaveChanges();
            }
        }
コード例 #6
0
        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"));
            }
        }
コード例 #7
0
        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");
            }
        }
コード例 #8
0
        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");
            }
        }
コード例 #9
0
ファイル: WorkController.cs プロジェクト: Resounding/Work
        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 });
            }
        }