Beispiel #1
0
        public async Task <IActionResult> Profile(MembersProfileVM membersProfileVM)
        {
            if (!ModelState.IsValid)
            {
                return(View(membersProfileVM));
            }

            var statusCode = await membersService.CheckAddress(membersProfileVM);

            if (!statusCode.Item1)
            {
                membersProfileVM.ErrorMessage = statusCode.Item2;
                return(View(membersProfileVM));
            }

            if (membersProfileVM.FilePath != null)
            {
                var uniqueFileName = Helper.GetUniqueFileName(membersProfileVM.FilePath.FileName);
                var images         = Path.Combine(hostingEnvironment.WebRootPath, "profiles");
                var filePath       = Path.Combine(images, uniqueFileName);
                membersProfileVM.FilePath.CopyTo(new FileStream(filePath, FileMode.Create));
                membersProfileVM.Picture = uniqueFileName;
            }

            await membersService.ChangeProfile(membersProfileVM, HttpContext.User);

            return(RedirectToAction(nameof(Profile)));
        }