Ejemplo n.º 1
0
 public static void UpdateUserTo(this AspNetUser target, AspNetUserModel source)
 {
     target.Address = source.Address;
     target.Telephone = source.Telephone;
     target.FirstName = source.FirstName;
     target.LastName = source.LastName;
     target.LockoutEnabled = source.LockoutEnabled;
 }
Ejemplo n.º 2
0
 public static AspNetUserModel CreateFrom(this AspNetUser source)
 {
     AspNetUserModel oModel = new AspNetUserModel
     {
         Address = source.Address,
         DateOfBirth = source.DateOfBirth,
         Email = source.Email,
         FirstName = source.FirstName,
         LastName = source.LastName,
         Id = source.Id,
         ImageName = source.ImageName,
         Telephone = source.Telephone,
         UserName = source.UserName,
         LockoutEnabled =  source.LockoutEnabled,
         LockoutEnabledString =  source.LockoutEnabled ? "Yes" : "No",
         IsConfirmedString = source.EmailConfirmed ? "Yes" : "No",
         RoleName = source.AspNetRoles.Any() ? source.AspNetRoles.First().Name : "",
         RoleId = source.AspNetRoles.Any() ? source.AspNetRoles.First().Id : ""
     };
     return oModel;
 }
Ejemplo n.º 3
0
        public async Task<ActionResult> SignUp(AspNetUserModel oModel)
        {
            oModel.UserName = oModel.Email;
            Utility oUtility = new Utility();
            oModel.RoleId = Utility.MemberRoleId;
            oModel.RoleName = Utility.MemberRoleName;
            var user = new AspNetUser
            {
                UserName = oModel.UserName,
                Email = oModel.Email,
                Address = oModel.Address,
                Telephone = oModel.Telephone,
                FirstName = oModel.FirstName,
                LastName = oModel.LastName,
                UserComments = string.Empty,
                LockoutEnabled = false
            };

            user.EmailConfirmed = true;
            if (!String.IsNullOrEmpty(oModel.Password))
            {
                var result = await UserManager.CreateAsync(user, oModel.Password);
                if (result.Succeeded)
                {
                    //Setting role
                    var roleManager = HttpContext.GetOwinContext().Get<ApplicationRoleManager>();
                    var roleName = roleManager.FindById(oModel.RoleId).Name;
                    UserManager.AddToRole(user.Id, roleName);

                    //return PreparePayPalPayment(user);


                    // Add User Preferences for Dashboards Widgets

                    TempData["message"] = new MessageViewModel { Message = "Please check your email for Confirmation", IsSaved = true };
                    return RedirectToAction("Index", "Home");
                }

            }


            return View(oModel);

        }
Ejemplo n.º 4
0
        public ActionResult Profile(AspNetUserModel profileViewModel)
        {
            AspNetUser result = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(User.Identity.GetUserId());

            //Updating Data
            try
            {
                result.FirstName = profileViewModel.FirstName;
                result.LastName = profileViewModel.LastName;
                result.Telephone = profileViewModel.Telephone;
                result.Address = profileViewModel.Address;
                var updationResult = UserManager.Update(result);
                updateSessionValues(result);
                TempData["message"] = new MessageViewModel { Message = "Profile has been updated", IsUpdated = true };
            }
            catch (Exception e)
            {
            }
            return RedirectToAction("Profile");
        }
Ejemplo n.º 5
0
 public ActionResult Profile()
 {
     //AspNetUser result = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(User.Identity.GetUserId());
     //var ProfileViewModel = new ProfileViewModel
     //{
     //    Email = result.Email,
     //    UserName = result.UserName,
     //    Address = result.Address,
     //    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
     //ViewBag.MessageVM = TempData["message"] as MessageViewModel;
     AspNetUserModel ProfileViewModel = new AspNetUserModel();
     ProfileViewModel = AspNetUserService.FindById(User.Identity.GetUserId()).CreateFrom();
     return View(ProfileViewModel);
 }