public long AddDoctor(AddDoctorRequest request) { var validationResult = _validator.ValidateRequest(request); if (!validationResult.PassedValidation) { throw new ArgumentException(validationResult.Errors.First()); } Doctor doctor = new Doctor { FirstName = request.FirstName, LastName = request.LastName, Gender = (int)request.Gender, Email = request.Email, DateOfBirth = request.DateOfBirth, Orders = new List <Order>(), Created = request.Created }; _context.Doctor.Add(doctor); _context.SaveChanges(); return(doctor.Id); }
public void AddDoctor(AddDoctorRequest request) { var validationResult = _validator.ValidateRequest(request); if (!validationResult.PassedValidation) { throw new ArgumentException(validationResult.Errors.First()); } _context.Doctor.Add(new Doctor { FirstName = request.FirstName, LastName = request.LastName, Gender = (int)request.Gender, Email = request.Email, DateOfBirth = request.DateOfBirth, Orders = new List <Order>(), Created = _dateTimeProvider.UtcNow }); _context.SaveChanges(); }