public async Task Add(CreateServiceByAdminDto createService) { //Sprawdzić, czy parametry są poprawne //Usługa z DayWorkDto. Przenieść do helpera? var itemService = await _itemServiceRepository.Get(createService.ItemServiceId); var client = await _userRepository.GetUserById(createService.ClientId); var dayWork = await _dayWorkRepository.Get(createService.DayWorkId); if (itemService == null || client == null || dayWork == null) { throw new Exception("Bad Id"); } var serviceToDb = new Service(); serviceToDb.Id = Guid.NewGuid(); serviceToDb.ItemService = itemService; serviceToDb.Client = (UserClient)client; serviceToDb.DayWork = dayWork; serviceToDb.DateOfReservation = DateTime.Now; await _serviceRepsitory.AddService(serviceToDb); }
public async Task <IEnumerable <DayWorkToReturnDto> > Get() { var allDayWork = await _dayWorkRepository.Get(); return(_mapper.Map <IEnumerable <DayWork>, IEnumerable <DayWorkToReturnDto> >(allDayWork)); }