Пример #1
0
        public async Task <IActionResult> EditProfile(RegistrationFormModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.FindByEmailAsync(model.Email); // returns ApplicationUser

                string imagePath  = _pathService.PictureFolder;
                string uploadPath = _webHostEnvironment.WebRootPath + imagePath;
                string demoImage  = _pathService.DummyUserImageUrl;

                if (user != null)
                {
                    user.IsVarified  = true;
                    user.FullName    = model.Name;
                    user.Email       = model.Email;
                    user.PhoneNumber = model.Mobile;
                    user.Address     = model.Address;
                    if (model.ImageFile != null && model.ImageFile.Length > 0)
                    {
                        user.ImageUrl = await GeneralUtilityMethods.GetSavedImageUrlAsync(model.ImageFile, uploadPath, demoImage);
                    }
                    var result = await _userManager.UpdateAsync(user);

                    if (result.Succeeded)
                    {
                        return(RedirectToAction("Profile", "Account", new { userId = user.Id.ToString() }));
                    }
                }
            }

            return(View(model));
        }
Пример #2
0
        public async Task <IActionResult> EditCompany(EditCompanyViewModel model)
        {
            if (ModelState.IsValid)
            {
                string imagePath          = _pathService.PictureFolder;
                string physicalUploadPath = _webHostEnvironment.WebRootPath + imagePath;
                string demoImage          = _pathService.DummyCompanyImageUrl;
                model.Company.CompanyImageUrl = await GeneralUtilityMethods.GetSavedImageUrlAsync(model.ImageFile, physicalUploadPath, demoImage);

                imagePath                 = _pathService.LogoFolder;
                physicalUploadPath        = _webHostEnvironment.WebRootPath + imagePath;
                demoImage                 = _pathService.DummyCompanyLogo;
                model.Company.CompanyLogo = await GeneralUtilityMethods.GetSavedImageUrlAsync(model.LogoFile, physicalUploadPath, demoImage);

                await _companyService.EditAsync(model.Company);

                return(RedirectToAction("CompanyPublicView", "Company", new { companyId = model.Company.Id.ToString() }));
            }

            return(View(model));
        }