Пример #1
0
        public async Task UpdateMedOffice(MedOffice medOffice)
        {
            _context.MedOffices.Update(medOffice);
            await _context.SaveChangesAsync();

            await Task.CompletedTask;
        }
Пример #2
0
        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);
        }
Пример #3
0
        public async Task AddMedOffice(MedOffice medOffice)
        {
            await _context.MedOffices.AddAsync(medOffice);

            await _context.SaveChangesAsync();

            await Task.CompletedTask;
        }
Пример #4
0
 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());
Пример #5
0
 public async Task <Department> GetByMedOffice(MedOffice medOffice)
 => await Task.FromResult(_context.Departments
                          .SingleOrDefault(department => department.MedOffices.Equals(medOffice)));