예제 #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();
        }
예제 #2
0
 public IHttpActionResult UpdateRepairSheet(int id, RepairSheetPostModel repairSheet)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     repairService.UpdateRepairSheet(id, repairSheet);
     return(Ok("Service sheeet updated! "));
 }
예제 #3
0
        public IHttpActionResult PostRepairSheet(RepairSheetPostModel repairSheet)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            repairService.AddRepairSheet(repairSheet);

            return(Ok());
        }
예제 #4
0
        public void UpdateRepairSheet(int id, RepairSheetPostModel repair)
        {
            var repairRes = DbContext.RepairSheets.SingleOrDefault(b => b.ID_repair == id);

            if (repairRes != null)
            {
                repairRes.defect_conclusion = repair.defect_conclusion;
                repairRes.totalCost         = repair.totalCost;
                repairRes.estimatedDate     = repair.estimatedDate;
                repairRes.status            = repair.status;
                repairRes.service_ID        = repair.service_ID;

                DbContext.SaveChanges();
            }
        }