/// <summary>
        /// Добавление данных юридического лица в базу данных
        /// </summary>
        /// <param name="user"></param>
        /// <param name="provider"></param>
        /// <returns></returns>
        private async Task AddProviderToDataBase(User user, ProviderDto provider)
        {
            await _providersService.AddAsync(provider);

            await _userManager.AddToRoleAsync(user, "Provider");

            await _signInManager.SignInAsync(user, false);
        }
예제 #2
0
        public async Task <IActionResult> Post([FromBody] Domain.Models.Provider provider)
        {
            await _providerService.AddAsync(provider);

            return(Created($"/api/provider/{provider.Id}", new Domain.Models.Provider {
                Id = provider.Id
            }));
        }
        public async Task <ActionResult> Create(IFormCollection collection, ProviderViewModel providerViewModel)
        {
            try
            {
                var provider = mapper.Map <Provider>(providerViewModel);
                await providerService.AddAsync(provider);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception)
            {
                return(View());
            }
        }
예제 #4
0
        private async Task <ProviderInfo> SaveProviderAsync(ProviderInfo provider)
        {
            if (_view.Providers.All(x => x.Id != provider.Id))
            {
                provider = await _providerService.AddAsync(provider);

                _view.Providers.Add(provider);
            }
            else
            {
                await _providerService.UpdateAsync(provider);

                provider = await _providerService.GetAsync(provider.Id);

                _view.Providers.AddOrReplace(x => x.Id == provider.Id, provider);
            }

            return(provider);
        }