コード例 #1
0
        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);
        }
コード例 #2
0
        public async Task <IActionResult> Add([FromBody] CreateServiceByAdminDto serviceParams)
        {
            await _serviceService.Add(serviceParams);

            return(Ok("Service has been created"));
        }