コード例 #1
0
ファイル: AccountController.cs プロジェクト: BaqerNaqvi/Btado
        public ActionResult Profile(ProfileViewModel profileViewModel)
        {
            AspNetUser result = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindByEmail(User.Identity.Name);
            string savedFileName = "";
            //Save image to Folder
            if ((profileViewModel.UploadImage != null))
            {
                var filename = profileViewModel.UploadImage.FileName;
                var filePathOriginal = Server.MapPath(ConfigurationManager.AppSettings["ProfileImage"]);
                savedFileName = Path.Combine(filePathOriginal, filename);
                profileViewModel.ImageName = filename;

                profileViewModel.UploadImage.SaveAs(savedFileName);
            }

            //Updating Data
            try
            {
                result.FirstName = profileViewModel.FirstName;
                result.LastName = profileViewModel.LastName;
                result.Email = profileViewModel.Email;
                result.PhoneNumber = profileViewModel.PhoneNumber;
                result.Address = profileViewModel.Address;
                result.Qualification = profileViewModel.Qualification;
                result.DateOfBirth = profileViewModel.DateOfBirth;
                if ( profileViewModel.ImageName !=null)
                {
                    result.ImageName = profileViewModel.ImageName;
                    profileViewModel.ImagePath = ConfigurationManager.AppSettings["ProfileImage"] as string + profileViewModel.ImageName;
                }
                else
                {
                    profileViewModel.ImagePath = ConfigurationManager.AppSettings["ProfileImage"] as string + result.ImageName;
                }
                var updationResult = UserManager.UpdateAsync(result);
                ViewBag.MessageVM = new MessageViewModel { Message = "Profile has been updated", IsUpdated = true };

                
                //BaseController oBaseController = new BaseController();
                //oBaseController.SetUserDetail();
                updateSessionValues(result);
            }
            catch (Exception e)
            {
            }
            return View(profileViewModel);
        }
コード例 #2
0
ファイル: AccountController.cs プロジェクト: BaqerNaqvi/Btado
 public ActionResult Profile()
 {
     AspNetUser result = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindByEmail(User.Identity.Name);
     var ProfileViewModel = new ProfileViewModel
     {
         Address = (result.Address != null && result.Address != string.Empty) ? result.Address : string.Empty,
         Email = result.Email,
         FirstName = result.FirstName,
         LastName = result.LastName,
         PhoneNumber = (result.PhoneNumber != null && result.PhoneNumber != string.Empty) ? result.PhoneNumber : string.Empty,
         Qualification = (result.Qualification != null && result.Qualification != string.Empty) ? result.Qualification : string.Empty,
         DateOfBirth = (result.DateOfBirth != null && result.DateOfBirth.ToString() != string.Empty) ? result.DateOfBirth : null,
         ImageName = (result.ImageName != null && result.ImageName != string.Empty) ? result.ImageName : string.Empty,
         ImagePath = ConfigurationManager.AppSettings["ProfileImage"].ToString() + result.ImageName
     };
     ViewBag.FilePath = ConfigurationManager.AppSettings["ProfileImage"] + ProfileViewModel.ImageName;//Server.MapPath
     return View(ProfileViewModel);
 }