Example #1
0
        public void AddRepairSheet(RepairSheetPostModel repair)
        {
            RepairSheet repairSheet = new RepairSheet()
            {
                defect_conclusion = repair.defect_conclusion,
                totalCost         = repair.totalCost,
                estimatedDate     = repair.estimatedDate,
                status            = repair.status,
                service_ID        = repair.service_ID,
                Workmanships      = repair.workmanships.Select(work => new Workmanship()
                {
                    time       = work.time,
                    operations = work.operations,
                    price      = work.price
                }).ToArray(),
                Parts = repair.parts.Select(part => new Part()
                {
                    partName = part.partName,
                    price    = part.price
                }).ToArray()
            };

            DbContext.RepairSheets.Add(repairSheet);
            DbContext.SaveChanges();
        }
Example #2
0
        public void DeleteRepairSheet(int id)
        {
            RepairSheet repair = DbContext.RepairSheets.Include(w => w.Workmanships).Include(p => p.Parts).FirstOrDefault(r => r.ID_repair == id);

            if (repair == null)
            {
                return;
            }
            DbContext.RepairSheets.Remove(repair);
            DbContext.SaveChanges();
        }