public async Task UpdateMedOffice(MedOffice medOffice) { _context.MedOffices.Update(medOffice); await _context.SaveChangesAsync(); await Task.CompletedTask; }
public async Task AddMedOffice(AddMedOfficeDto medOffice) { var tempMedOffice = await _medOfficeRepository.GetByOfficeNumberAndDepartmentId(medOffice.OfficeNumber, medOffice.DepartmentName); if (tempMedOffice != null) { throw new Exception("This medOffice is existed id DB"); } var department = await _departmentRepository.GetByName(medOffice.DepartmentName); if (department == null) { throw new Exception("Bad departmentId"); } var newMedOffice = new MedOffice(); newMedOffice.Id = Guid.NewGuid(); newMedOffice.Description = medOffice.Description; newMedOffice.Department = department; newMedOffice.OfficeNumber = medOffice.OfficeNumber; await _medOfficeRepository.AddMedOffice(newMedOffice); }
public async Task AddMedOffice(MedOffice medOffice) { await _context.MedOffices.AddAsync(medOffice); await _context.SaveChangesAsync(); await Task.CompletedTask; }
public async Task <IEnumerable <Appointment> > GetByMedOfficeAndDate(MedOffice medOffice, DateTime dateTime) => await Task.FromResult(_context.Appointments .Where(appointment => appointment.MedOffice.Equals(medOffice)) .Where(appointment => appointment.Date.Equals(dateTime)) .ToList());
public async Task <Department> GetByMedOffice(MedOffice medOffice) => await Task.FromResult(_context.Departments .SingleOrDefault(department => department.MedOffices.Equals(medOffice)));