Beispiel #1
0
        public async Task <IActionResult> RegisterCook([FromBody] FoodBusinessRegistrationDto foodBusinessRegistrationDto)
        {
            var cookId = JwtMetaData.CookId;

            async Task <FoodBusinessRegistrationDto> RegisterCook()
            {
                foodBusinessRegistrationDto.Id     = null;
                foodBusinessRegistrationDto.CookId = cookId;

                var foodBusRegValidModel = new FoodBusinessRegistrationValidatorModel
                {
                    FoodBusinessRegistration = foodBusinessRegistrationDto
                };

                await _foodBusValidator.ValidateEntityAsync(foodBusRegValidModel, foodBusRegValidModel.RuleSet);

                var foodBusinessReg      = _mapper.Map <FoodBusinessRegistration>(foodBusinessRegistrationDto);
                var savedFoodBusinessReg = await _foodBusRepo.Save(foodBusinessReg);

                return(_mapper.Map <FoodBusinessRegistrationDto>(savedFoodBusinessReg));
            }

            return(await Execute(RegisterCook));
        }
Beispiel #2
0
        public async Task <IActionResult> UpdateCookRegistration(string foodRegistrationId, [FromBody] FoodBusinessRegistrationDto foodBusinessRegDto)
        {
            var cookId = JwtMetaData.CookId;

            async Task <FoodBusinessRegistrationDto> UpdateCookRegistration()
            {
                foodBusinessRegDto.Id     = foodRegistrationId;
                foodBusinessRegDto.CookId = cookId;

                var foodBusRegValidModel = new FoodBusinessRegistrationValidatorModel
                {
                    FoodBusinessRegistration = foodBusinessRegDto,
                };

                await _foodBusValidator.ValidateEntityAsync(foodBusRegValidModel, foodBusRegValidModel.RuleSet);

                var foodBusinessReg = _mapper.Map <FoodBusinessRegistration>(foodBusinessRegDto);

                return(_mapper.Map <FoodBusinessRegistrationDto>(await _foodBusRepo.Save(foodBusinessReg)));
            }

            return(await Execute(UpdateCookRegistration));
        }