public void AddALaboratory(LaboratoryModel laboratory)
 {
     if (labRepo.GetByDate(laboratory.Date) != null || labRepo.GetByNumber(laboratory.Number) != null)
     {
         throw new Exception("laboratory already exists");
     }
     laboratory.Id = 0;
     labRepo.Add(Mapper.Map <LaboratoryDto>(laboratory));
     labRepo.Save();
 }
Beispiel #2
0
        public void EditAssignment(AssignmentModel assignment)
        {
            var toUpdate = assignmentRepository.GetById(assignment.Id);

            if (laboratoryRepository.GetById(assignment.Laboratory.Id) == null)
            {
                if (assignment.Laboratory.Id != 0)
                {
                    throw new Exception("lab not present");
                }
            }

            if (toUpdate != null)
            {
                toUpdate.Name         = assignment.Name ?? toUpdate.Name;
                toUpdate.LaboratoryId = assignment.Laboratory.Id != 0 ? assignment.Laboratory.Id : toUpdate.LaboratoryId;
                toUpdate.Description  = assignment.Description ?? toUpdate.Description;
                toUpdate.DueDate      = assignment.DueDate.Date <= DateTime.Now.Date ? toUpdate.DueDate : assignment.DueDate;
                laboratoryRepository.Save();
            }
        }