Exemple #1
0
        public ActionResult AddRepairLog(RepairLogView log)
        {
            var workshopRepo = new WorkshopRepository();

            if (workshopRepo.GetRepairLogs().SingleOrDefault(rl => rl.Id == log.Id) != null)
            {
                return(Ok());
            }

            var repairRepo = workshopRepo.GetRepairs();

            log.Repair = repairRepo.Single(r => r.Id == log.Repair.Id);
            workshopRepo.AddRepairLog(log);
            return(Ok());
        }
Exemple #2
0
        public ActionResult UpdateRepairLog(RepairLogView log)
        {
            var           workshopRepo = new WorkshopRepository();
            RepairLogView found        = workshopRepo.GetRepairLogs(log.Repair.Id).SingleOrDefault(rl => rl.Id == log.Id);


            if (found is null)
            {
                workshopRepo.AddRepairLog(log);
            }
            else
            {
                found.Date         = DateTime.Today;
                found.Description  = log.Description;
                found.TechnicianId = log.TechnicianId;
                workshopRepo.UpdateRepairLog(found);
            }

            return(Ok());
        }