public async Task <IActionResult> Update(VehicleVM vehicleVM, AppUserVM appUserVM, CustomerVM customerVM, string makeName, string modelName)
        {
            vehicleVM.MakeVM = new MakeVM
            {
                Name = makeName
            };
            vehicleVM.ModelVM = new ModelVM
            {
                Name = modelName
            };
            var vehicleModelMVC = new VehicleModelMVC
            {
                Id         = vehicleVM.Id,
                CreateAt   = vehicleVM.CreateAt,
                CustomerVM = customerVM,
                MakeVM     = vehicleVM.MakeVM,
                ModelVM    = vehicleVM.ModelVM,
                AppUserVM  = appUserVM,
                Odometer   = vehicleVM.Odometer,
                VIN        = vehicleVM.VIN,
                Engine     = vehicleVM.Engine
            };
            string token = HttpContext.Session.GetString("token_access");

            return(View(await listChosen(token, vehicleModelMVC)));
        }
        public ActionResult ResetPassword(Guid id)
        {
            AppUserVM auvm = new AppUserVM();

            auvm.AppUser = appRep.FirstOrDefault(x => x.ActivationCode == id);
            return(View(auvm));
        }
Esempio n. 3
0
        public ActionResult RegisterNow(AppUserVM apvm)
        {
            AppUser     appUser = apvm.AppUser;
            UserProfile profile = apvm.UserProfile;

            appUser.Password = DantexCrypt.Crypt(appUser.Password); //sifreyi kriptoladık

            //AppUser.Password = DantexCrypt.DeCrypt(apvm.AppUser.Password);

            if (apRep.Any(x => x.UserName == appUser.UserName))
            {
                ViewBag.ZatenVar = "Kullanıcı ismi daha önce alınmıs";
                return(View());
            }
            else if (apRep.Any(x => x.Email == appUser.Email))
            {
                ViewBag.ZatenVar = "Email zaten kayıtlı";
                return(View());
            }

            //Kullanıcı basarılı bir şekilde register işlemini tamamladıysa ona mail gönder

            string gonderilecekMail = "Tebrikler...Hesabınız olusturulmustur. Hesabınızı aktive etmek icin https://localhost:44389/Register/Activation/" + appUser.ActivationCode + " linkine tıklayabilirsiniz.";

            MailSender.Send(appUser.Email, body: gonderilecekMail, subject: "Hesap aktivasyon!");
            apRep.Add(appUser); //öncelikle bunu eklemelisiniz. Cnkü AppUser'in ID'si ilk basta olusmalı... Cünkü biz birebir ilişkide AppUser zorunlu alan Profile ise opsiyonel alandır. Dolayısıyla ilk basta AppUser'in ID'si SaveChanges ile olusmalı ki sonra Profile'i rahatca ekleyebilelim...

            if (!string.IsNullOrEmpty(profile.FirstName) || !string.IsNullOrEmpty(profile.LastName) || !string.IsNullOrEmpty(profile.Address))
            {
                profile.ID = appUser.ID;
                apdRep.Add(profile);
            }

            return(View("RegisterOk"));
        }
Esempio n. 4
0
        public ActionResult Register(AppUserVM apvm)
        {
            if (!ModelState.IsValid)
            {
                return(View("Register"));
            }

            apvm.AppUser.Password = DantexCrypt.Crypt(apvm.AppUser.Password);

            apvm.AppUser.ConfirmPassword = DantexCrypt.Crypt(apvm.AppUser.ConfirmPassword);



            if (apRep.Any(x => x.Email == apvm.AppUser.Email))
            {
                ViewBag.Mevcut = "Bu Email adresine kayıtlı hesap bulunmaktadır.";
                return(View());
            }
            string gonderilecekMail = "Tebrikler kayıt olma işleminiz başarılı bir şekilde gerçekleştirilmiştir. Hesabınızı aktif etmek için https://localhost:44390/Account/Activation/" + apvm.AppUser.ActivationCode + " linkine tıklamanız yeterlidir.";

            MailSender.Send(apvm.AppUser.Email, body: gonderilecekMail, subject: "Hesap Aktivasyon");

            apRep.Add(apvm.AppUser); //One to one relation on first

            if (!string.IsNullOrEmpty(apvm.UserProfile.FirstName) || !string.IsNullOrEmpty(apvm.UserProfile.LastName) || apvm.UserProfile.Gender != 0 || !string.IsNullOrEmpty(apvm.UserProfile.MobilePhone))
            {
                apvm.UserProfile.ID = apvm.AppUser.ID;
                apdRep.Add(apvm.UserProfile);
            }

            return(View("RegisterOk"));
        }
Esempio n. 5
0
        public ActionResult RegisterNow(AppUserVM apvm)
        {
            AppUser     appUser = apvm.AppUser;
            UserProfile profile = apvm.Profile;

            appUser.Password = DantexCrypt.Crypt(appUser.Password);

            if (apRep.Any(x => x.UserName == appUser.UserName))
            {
                ViewBag.ZatenVar = "Kullanici ismi daha onceden alinmis";
                return(View());
            }
            else if (apRep.Any(x => x.Email == appUser.Email))
            {
                ViewBag.ZatenVar = "Email adresi daha onceden alinmis";
                return(View());
            }

            string gonderilecekMail = "Tebrikler. Hesabiniz olusturuldu. Hesabinizi aktif etmek icin lutfen baglantiya tiklayin. https://localhost:44318/Register/Activation/" + appUser.ActivationCode;

            MailSender.Send(appUser.Email, password: "******", body: gonderilecekMail, subject: "Hesap Aktivasyon", sender: "*****@*****.**");
            apRep.Add(appUser);

            if (!string.IsNullOrEmpty(profile.FirstName) || !string.IsNullOrEmpty(profile.LastName))
            {
                profile.ID = appUser.ID;
                apdRep.Add(profile);
            }
            return(View("RegisterOk"));
        }
Esempio n. 6
0
        private string GenarateToken(AppUserVM UserVM)
        {
            var issuer      = _configuration["JWT:Issuer"];
            var audience    = _configuration["JWT:Audience"];
            var secretkey   = new SymmetricSecurityKey(UTF8Encoding.UTF8.GetBytes(_configuration["JWT:SecretKey"]));
            var credentials = new SigningCredentials(secretkey, SecurityAlgorithms.HmacSha256);
            var claims      = new List <Claim>();

            claims.Add(new Claim("Role", _userRoleService.GetById(UserVM.AppUserRolesId).Result.Name));
            claims.Add(new Claim("AppUserRoleId", _userRoleService.GetById(UserVM.AppUserRolesId).Result.Id.ToString()));
            claims.Add(new Claim(ClaimTypes.Role, _userRoleService.GetById(UserVM.AppUserRolesId).Result.Name));
            claims.Add(new Claim("UserName", UserVM.UserName));
            claims.Add(new Claim("ConfirmEmail", UserVM.ConfirmEmail));
            claims.Add(new Claim("Email", UserVM.Email));
            claims.Add(new Claim("Id", UserVM.Id.ToString()));
            claims.Add(new Claim("FullName", UserVM.FullName));
            var token = new JwtSecurityToken(
                issuer,
                audience,
                claims: claims,
                expires: DateTime.Now.AddDays(7),
                signingCredentials: credentials);

            return(new JwtSecurityTokenHandler().WriteToken(token));
        }
Esempio n. 7
0
        public ActionResult Update(AppUserVM data, HttpPostedFileBase Image)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("List", "AppUser", new { area = "Member" }));
            }

            data.ImagePath = ImageUploader.UploadSingleImage("/Uploads/", Image);
            AppUser appUser = _appUserService.GetById(data.ID);

            if (data.ImagePath != "0" && data.ImagePath != "1" && data.ImagePath != "2")
            {
                appUser.ImagePath = data.ImagePath;
            }
            appUser.UserName       = data.Name;
            appUser.Password       = data.Password;
            appUser.Gender         = data.Gender;
            appUser.Address        = data.Address;
            appUser.IdentityNumber = data.IdentityNumber;
            appUser.Name           = data.Name;
            appUser.LastName       = data.LastName;
            appUser.Salary         = data.Salary;
            appUser.Email          = data.Email;
            appUser.Phone          = data.Phone;
            appUser.District       = data.District;
            appUser.City           = data.City;
            appUser.Country        = data.Country;
            appUser.Birthdate      = data.Birthdate;
            appUser.DepartmentID   = data.DepartmentID;
            appUser.StoreID        = data.StoreID;
            _appUserService.Update(appUser);
            return(RedirectToAction("List", "AppUser", new { area = "Member" }));
        }
Esempio n. 8
0
        public RedirectToRouteResult Update(AppUserVM data, HttpPostedFileBase Image)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("List", "AppUser", new { area = "Admin" }));
            }

            data.ImagePath = ImageUploader.UploadSingleImage("/Uploads/", Image);

            AppUser user = _appuserService.GetById(data.ID);


            if (data.ImagePath != "0" && data.ImagePath != "1" && data.ImagePath != "2")
            {
                user.ImagePath = data.ImagePath;
            }

            user.Name        = data.Name;
            user.LastName    = data.LastName;
            user.PhoneNumber = data.PhoneNumber;
            user.Role        = data.Role;
            user.Email       = data.Email;
            user.UserName    = data.UserName;
            user.Password    = data.Password;

            _appuserService.Update(user);



            return(RedirectToAction("List", "AppUser", new { area = "Admin" }));
        }
Esempio n. 9
0
        public ActionResult <ResultVM <AppUserVM> > LogIn(AppUserVM login)
        {
            var    result = new ResultVM <AppUserVM>();
            string Token  = string.Empty;

            //var user = await AuthenticateUser(login);
            try
            {
                if (!ModelState.IsValid)
                {
                    result.Message    = ModelState.Values.SelectMany(s => s.Errors).FirstOrDefault().ErrorMessage;
                    result.StatusCode = Convert.ToInt32(Enums.StatusCode.BadRequest);
                }
                else
                {
                    var resultModel = accountBusiness.UserExists(login.EmailId, login.Password);
                    mapper.Map(resultModel, result);
                    if (resultModel.Data != null)
                    {
                        Token = GenerateJSONWebToken();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message    = ex.Message;
                result.StatusCode = (int)Enums.StatusCode.ServerError;
            }
            return(Ok(new { Token, result = result }));
        }
Esempio n. 10
0
        public ActionResult Update(Guid?id)
        {
            if (id == null)
            {
                return(RedirectToAction("List", "AppUser", new { area = "Member" }));
            }
            AppUser   data  = _appUserService.GetById((Guid)id);
            AppUserVM model = new AppUserVM()
            {
                ID             = data.ID,
                UserName       = data.UserName,
                Password       = data.Password,
                Gender         = data.Gender,
                Address        = data.Address,
                IdentityNumber = data.IdentityNumber,
                Name           = data.Name,
                LastName       = data.LastName,
                Salary         = data.Salary,
                Email          = data.Email,
                Phone          = data.Phone,
                District       = data.District,
                City           = data.City,
                Country        = data.Country,
                Birthdate      = data.Birthdate,
                ImagePath      = data.ImagePath,
                DepartmentID   = data.DepartmentID,
                StoreID        = data.StoreID,
            };


            TempData["DepartmentListesi"] = _departmentService.GetActive();
            TempData["StoreListesi"]      = _storeService.GetActive();
            return(View(model));
        }
        public ActionResult RegisterNow(AppUserVM apvm)
        {
            AppUser     appUser = apvm.AppUser;
            UserProfile profile = apvm.Profile;

            appUser.Password = DantexCrypt.Crypt(appUser.Password); //sifreyi kriptoladık

            //AppUser.Password = DantexCrypt.DeCrypt(apvm.AppUser.Password);

            if (apRep.Any(x => x.UserName == appUser.UserName))
            {
                ViewBag.ZatenVar = "This username is already taken";
                return(View());
            }
            else if (apRep.Any(x => x.Email == appUser.Email))
            {
                ViewBag.ZatenVar = "This email is already registered";
                return(View());
            }

            //Kullanıcı basarılı bir şekilde register işlemini tamamladıysa ona mail gönder

            string gonderilecekMail = "Congratulations...Your account has been created. You can click the https://localhost:44362/Register/Activation/" + appUser.ActivationCode + " link to activate your account..";

            MailSender.Send(appUser.Email, body: gonderilecekMail, subject: "Account activation!");
            apRep.Add(appUser); //öncelikle bunu eklemelisiniz. Cnkü AppUser'in ID'si ilk basta olusmalı... Cünkü biz birebir ilişkide AppUser zorunlu alan Profile ise opsiyonel alandır. Dolayısıyla ilk basta AppUser'in ID'si SaveChanges ile olusmalı ki sonra Profile'i rahatca ekleyebilelim...

            if (!string.IsNullOrEmpty(profile.FirstName) || !string.IsNullOrEmpty(profile.LastName) || !string.IsNullOrEmpty(profile.Address))
            {
                profile.ID = appUser.ID;
                apdRep.Add(profile);
            }

            return(View("RegisterOk"));
        }
Esempio n. 12
0
        public ReturnMessage Post(AppUserVM appUserVM)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new ReturnMessage
                    {
                        ID = 0,
                        Success = false,
                        Message = "Please enter valid entries."
                    });
                }
                var passwordSalt     = Guid.NewGuid().ToString();
                var originalPassword = appUserVM.szPassword.Trim();
                appUserVM.szPassword     = Encryption.SaltEncrypt(originalPassword, passwordSalt);
                appUserVM.szPasswordSalt = passwordSalt.ToString();
                appUserVM.dCreatedOn     = DateTime.Now;
                appUserVM.szUsername     = appUserVM.szUsername.Trim();
                appUserVM.iChangePW      = false;
                appUserVM.iStatus        = 0;

                var retVal = _IAppUserRepository.AddAppUser(appUserVM.ToEntity());
                //Successful
                if (retVal.isSuccess)
                {
                    //Check if username is email address
                    if (_RegexUtilities.ContainsAlphabet(appUserVM.szUsername.Trim()))
                    {
                        //Send Email Notification
                        _Notification.SendEMail(appUserVM.szUsername.Trim(), "Welcome to GameZone.", "Thank you for joining <b>GameZone</b>. <br/> Your registration was successful.<br/> <br/><a style='background:#ff6a00; color: #ffffff; font-family:bitsumishi !important; padding:6px 12px; font-weight:400;text-align:center; vertical-align: middle; cursor: pointer; border:1px solid transparent; border-radius:4px; text-decoration: none;' href='http://www.gamezone.ng/'> Login </a>");
                    }

                    return(new ReturnMessage
                    {
                        ID = long.Parse(retVal.id),
                        Success = true,
                        Message = retVal.message
                    });
                }
                else
                {
                    return(new ReturnMessage
                    {
                        ID = (bool)appUserVM.isMobile ? 101 : 0,//MTN Number indicator (IsMobile)
                        Data = GetAuthenticateUser(appUserVM.szUsername, "password").Data,
                        Success = false,
                        Message = "Sorry, " + appUserVM.szUsername + " already exists. Please try a different UserID."
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ReturnMessage
                {
                    Success = false,
                    Message = ex.Message
                });
            }
        }
Esempio n. 13
0
        public async Task <IActionResult> AppUser(int id = 0)
        {
            CreateBreadCrumb(new[] { new { Name = "Home", ActionUrl = "#" },
                                     new { Name = "App Users", ActionUrl = "/Account/AppUsers" },
                                     new { Name = "User Profile", ActionUrl = "/Account/AppUser" } });

            BaseViewModel VModel     = null;
            AppUserVM     TempVModel = null;

            if (id != 0)
            {
                TempVModel = await _AppUserService.GetAppUserByID(id);

                if (TempVModel != null)
                {
                    //TempVModel.UserImgPath = GetBaseService().GetUserAvatarPath(string.Format("{0}.{1}", TempVModel.UserId, "jpg"));
                    TempVModel.UserImgPath     = GetBaseService().DirectoryFileService.GetAppUserAvatarPath(TempVModel.UserId);
                    TempVModel.AttachUserImage = new FileUploadInfo();
                }
                else
                {
                    throw new Exception("Not a valid application User");
                }
            }
            else
            {
                TempVModel                 = new AppUserVM();
                TempVModel.UserImgPath     = "~/assets/img/AppUser/BlankUser.jpg";
                TempVModel.AttachUserImage = new FileUploadInfo();
            }

            VModel = await GetViewModel(TempVModel);

            return(View(VModel));
        }
Esempio n. 14
0
        public ActionResult UpdateUser(AppUserVM apvm)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            AppUser     toBeUpdatedUser        = _uRep.FirstOrDefault(x => x.ID == apvm.AppUser.ID);
            UserProfile toBeUpdatedUserProfile = _upRep.FirstOrDefault(x => x.ID == apvm.UserProfile.ID);



            toBeUpdatedUser.Email           = apvm.AppUser.Email;
            toBeUpdatedUser.Password        = apvm.AppUser.Password;
            toBeUpdatedUser.ConfirmPassword = apvm.AppUser.ConfirmPassword;
            toBeUpdatedUser.Role            = apvm.AppUser.Role;

            toBeUpdatedUserProfile.FirstName   = apvm.UserProfile.FirstName;
            toBeUpdatedUserProfile.LastName    = apvm.UserProfile.LastName;
            toBeUpdatedUserProfile.MobilePhone = apvm.UserProfile.MobilePhone;
            toBeUpdatedUserProfile.Gender      = apvm.UserProfile.Gender;
            toBeUpdatedUserProfile.Address     = apvm.UserProfile.Address;


            _uRep.Update(toBeUpdatedUser);
            _upRep.Update(toBeUpdatedUserProfile);

            TempData["updateUser"] = $"{toBeUpdatedUserProfile.FirstName} {toBeUpdatedUserProfile.LastName} kişisi başarıyla güncellenmiştir";


            return(RedirectToAction("UserList", "User", new { Area = "Panel" }));
        }
Esempio n. 15
0
        public async IAsyncEnumerable <bool> UserEdit(AppUserVM appUserVM)
        {
            yield return(await HubHelper.WrapAsync(_logger, async() =>
            {
                var user = await _userManager.FindByIdAsync(appUserVM.Id);
                if (user == default)
                {
                    throw new HubException("User does not exist");
                }

                HubHelper.Validate(appUserVM);

                var nameClaim = (await _userManager.GetClaimsAsync(user))
                                .FirstOrDefault(m => m.Type == JwtClaimTypes.Name);

                if (nameClaim == null || appUserVM.Name != nameClaim.Value)
                {
                    var newNameClaim = new Claim(JwtClaimTypes.Name, appUserVM.Name);
                    if (nameClaim == null)
                    {
                        await _userManager.AddClaimAsync(user, newNameClaim);
                    }
                    else
                    {
                        await _userManager.ReplaceClaimAsync(user, nameClaim, newNameClaim);
                    }
                }

                return true;
            }));
Esempio n. 16
0
        public IActionResult UserEdit()
        {
            AppUser   user      = userManager.FindByNameAsync(User.Identity.Name).Result;
            AppUserVM appUserVM = user.Adapt <AppUserVM>();

            ViewBag.Gender = new SelectList(Enum.GetNames(typeof(Gender)));
            return(View(appUserVM));
        }
Esempio n. 17
0
        public async Task <IActionResult> LogUP([FromBody] AppUserVM user)
        {
            var res = await _auth.SignUp(null);

            return(new ContentResult {
                Content = res
            });
        }
Esempio n. 18
0
        // GET: Manager/AppUser
        public ActionResult ShipperByID(int id)
        {
            AppUserVM avm = new AppUserVM
            {
                AppUser = aRep.Find(id)
            };

            return(View(avm));
        }
Esempio n. 19
0
        public ReturnMessage PostResetPw(AppUserVM appUserVM)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new ReturnMessage
                    {
                        ID = 0,
                        Success = false,
                        Message = "Please enter valid entries."
                    });
                }
                var passwordSalt      = Guid.NewGuid().ToString();
                var originalPassword  = passwordSalt.Substring(0, 6).Trim();
                var encriptedPassword = Encryption.SaltEncrypt(originalPassword, passwordSalt);

                var retVal = _IAppUserRepository.ResetAppUserPassword(appUserVM.szUsername.Trim(), encriptedPassword, passwordSalt, 0, true);
                //Successful
                if (retVal.isSuccess)
                {
                    //Check if username is email address
                    var ContainsAlphabet = _RegexUtilities.ContainsAlphabet(appUserVM.szUsername.Trim());
                    if (ContainsAlphabet)
                    {
                        //"C:\\Users\\Systems\\Documents\\GitHub\\Gamezone\\GameZone.WEB\\Content\\images\\logo.png"
                        //Send Email Notification
                        _Notification.SendEMail(appUserVM.szUsername.Trim(), "GameZone Password Reset.", $"Your password reset was successful. <br/> Your new password is: <b>{originalPassword}</b>. You will be prompted to change this password once you login. <br/><br/> <a style='background:#ff6a00; color: #ffffff; font-family:bitsumishi !important; padding:6px 12px; font-weight:400;text-align:center; vertical-align: middle; cursor: pointer; border:1px solid transparent; border-radius:4px; text-decoration: none;' href='http://www.gamezone.ng/'> Login </a>");
                    }

                    return(new ReturnMessage
                    {
                        ID = long.Parse(retVal.id),
                        Success = true,
                        Message = ContainsAlphabet ? retVal.message + " Your new password has been sent to your registered email address."
                        : retVal.message + " Your new password has been sent to your registered phone no."
                    });
                }
                else
                {
                    return(new ReturnMessage
                    {
                        Success = false,
                        Message = retVal.message
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ReturnMessage
                {
                    Success = false,
                    Message = ex.Message
                });
            }
        }
Esempio n. 20
0
        public async Task <IActionResult> Create(AppUserVM appUserVM)
        {
            if (ModelState.IsValid)
            {
                if (userManager.Users.Any(u => u.PhoneNumber == appUserVM.PhoneNumber))
                {
                    ModelState.AddModelError("", "Bu telefon numarası başka bir üye tarafından kullanılmaktadır");
                    return(View(appUserVM));
                }
                //string uniqueFileName = null;
                //if (appUserVM.cvFile !=null)
                //{

                //    string uploadsFile = Path.Combine(hostingEnvironment.WebRootPath, "CVs");
                //    uniqueFileName = Guid.NewGuid().ToString() + "_" + appUserVM.cvFile.FileName;
                //    string filePath = Path.Combine(uploadsFile, uniqueFileName);
                //    appUserVM.cvFile.CopyTo(new FileStream(filePath, FileMode.Create));
                //}

                AppUser user = new AppUser()
                {
                    UserName    = appUserVM.UserName,
                    FirstName   = appUserVM.FirstName,
                    LastName    = appUserVM.LastName,
                    Email       = appUserVM.Email,
                    Gender      = Convert.ToInt32(appUserVM.Gender),
                    City        = appUserVM.City,
                    BirthDay    = appUserVM.BirthDay,
                    PhoneNumber = appUserVM.PhoneNumber
                                  //cvFile=uniqueFileName
                };
                IdentityResult result = await userManager.CreateAsync(user, appUserVM.Password);

                if (result.Succeeded)
                {
                    string confirmationToken = await userManager.GenerateEmailConfirmationTokenAsync(user);

                    string link = Url.Action("EmailConfirmation", "Account", new
                    {
                        userId = user.Id,
                        token  = confirmationToken
                    }, protocol: HttpContext.Request.Scheme);
                    Helper.EmailConfirmation.SendEmail(link, user.Email);
                    return(View("Login"));
                }
                else
                {
                    foreach (IdentityError item in result.Errors)
                    {
                        ModelState.AddModelError("", item.Description);
                    }
                }
            }

            return(View(appUserVM));
        }
Esempio n. 21
0
        public ActionResult UpdateUser(int id)
        {
            AppUserVM apvm = new AppUserVM
            {
                AppUser     = _uRep.Find(id),
                UserProfile = _upRep.Find(id)
            };

            return(View(apvm));
        }
Esempio n. 22
0
        // GET: Panel/User
        public ActionResult UserList()
        {
            AppUserVM apvm = new AppUserVM
            {
                AppUsers     = _uRep.GetActives(),
                UserProfiles = _upRep.GetActives()
            };

            return(View(apvm));
        }
Esempio n. 23
0
        public async Task <IActionResult> UpdateUsers(AppUserVM appUserVM, AppUserRoleVM appUserRoleVM)
        {
            var    appUserModelMVC = new AppUserModelMVC();
            string token           = HttpContext.Session.GetString("token_access");
            var    list            = await _userRoleServiceApiClient.GetAll(token);

            appUserModelMVC.ListAppUserRoleVM = list;
            appUserModelMVC.appUserRoleVM     = appUserRoleVM;
            appUserModelMVC.appUserVM         = appUserVM;
            return(View(appUserModelMVC));
        }
Esempio n. 24
0
        // update your info
        public async Task <ApiResultVM <string> > Update(AppUserVM appUserVM, string token)
        {
            var client = _httpClientFactory.CreateClient();

            client.BaseAddress = new Uri(_configuration["UrlApi"]);
            client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
            var response = await client.PutAsJsonAsync("/api/users/" + appUserVM.Id, appUserVM);

            var body = await response.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <ApiResultVM <string> >(body));
        }
Esempio n. 25
0
        public async Task <IActionResult> Register(AppUserVM avm)
        {
            AppUser newUser = new AppUser {
                UserName = avm.UserName, Email = avm.Email, PasswordHash = avm.Password
            };

            if (await _ums.AddUser(newUser))
            {
                return(RedirectToAction("RegisterSuccess"));
            }

            return(View(avm));
        }
 public ActionResult AppUserUpdate(int id)
 {
     if (Session["member"] != null)
     {
         AppUserVM appUserVM = new AppUserVM()
         {
             AppUser       = auRep.Default(x => x.ID == id),
             AppUserDetail = audRep.Default(x => x.ID == id),
         };
         return(View(appUserVM));
     }
     return(RedirectToAction("Login", "Home"));
 }
Esempio n. 27
0
        public ReturnMessage PostNewAppUser(AppUserVM appUserVM)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new ReturnMessage
                    {
                        ID = 0,
                        Success = false,
                        Message = "Please enter valid entries."
                    });
                }
                var passwordSalt     = Guid.NewGuid().ToString();
                var originalPassword = appUserVM.szPassword.Trim();
                appUserVM.szPassword     = Encryption.SaltEncrypt(originalPassword, passwordSalt);
                appUserVM.szPasswordSalt = passwordSalt.ToString();
                appUserVM.dCreatedOn     = DateTime.Now;
                appUserVM.szUsername     = appUserVM.szUsername.Trim();
                appUserVM.iChangePW      = false;
                appUserVM.iStatus        = 0;

                var retVal = _IAppUserRepository.AddAppUser(appUserVM.ToEntity());

                if (retVal.isSuccess)
                {
                    return(new ReturnMessage
                    {
                        ID = long.Parse(retVal.id),
                        Success = true,
                        Message = retVal.message
                    });
                }
                else
                {
                    return(new ReturnMessage
                    {
                        Success = false,
                        Message = "Sorry, " + appUserVM.szUsername + " already exists. Please try a different UserID."
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ReturnMessage
                {
                    Success = false,
                    Message = ex.Message
                });
            }
        }
Esempio n. 28
0
        public async Task <JsonResult> AppUser(AppUserVM model)
        {
            if (ModelState.IsValid)
            {
                string   ResetContext = Guid.NewGuid().ToString().Replace("-", "RP");
                DateTime PassValidity = DateTime.Now.AddDays(3); //validity for 3 day
                var      result       = await _AppUserService.SaveAppUserAsync(model, ResetContext, PassValidity).ConfigureAwait(false);

                if (result.Stat)
                {
                    //save the user picture
                    if (model.AttachUserImage.FileSize > 0)
                    {
                        var RtnMsg = GetBaseService().DirectoryFileService.CreateUserAvatarFromBase64String(GetBaseService().GetAppRootPath(), model.UserId, model.AttachUserImage.FileContentsBase64);
                        model.UserImgPath = RtnMsg.StatusMsg;
                        //string UsrImgPath = Path.Combine(GetBaseService().GetAppRootPath(), "AppFileRepo", "UserAvatar");
                        //if (GetBaseService().DirectoryFileService.CreateDirectoryIfNotExist(UsrImgPath))
                        //{
                        //    UsrImgPath = string.Format("{0}\\{1}.{2}", UsrImgPath, model.UserId, "jpg");
                        //    if (GetBaseService().DirectoryFileService.CreateFileFromBase64String(model.AttachUserImage.FileContentsBase64, UsrImgPath))
                        //    {
                        //        //model.UserImgPath = string.Format("~/AppFileRepo/UserAvatar/{0}.{1}?r={2}", model.UserId, "jpg", DateTime.Now.Ticks.ToString());
                        //        model.UserImgPath = GetBaseService().DirectoryFileService.GetAppUserAvatarPath(model.UserId);
                        //    }
                        //}
                    }
                    if (model.Id != 0)
                    {
                        await GetBaseService().AddActivity(ActivityType.Update, model.BUserID, model.BUserName, "Update User", string.Format("Updated user : {0} info.", model.Name));

                        return(Json(new { stat = true, msg = "Successfully updated user" }));
                    }
                    else
                    {
                        var oLoginUser = GetLoginUserInfo();
                        await _JobService.AddNewUserCreateEmailJob(Convert.ToInt64(oLoginUser.ID), model.Name, model.Email, GetAppRootUrl(), ResetContext);
                        await GetBaseService().AddActivity(ActivityType.Create, model.BUserID, model.BUserName, "Save User", string.Format("Save new user : {0} info.", model.Name));

                        return(Json(new { stat = true, msg = "Successfully saved user" }));
                    }
                }
                else
                {
                    return(Json(new { stat = false, msg = result.StatusMsg }));
                }
            }
            else
            {
                return(Json(new { stat = false, msg = "Invalid User data" }));
            }
        }
Esempio n. 29
0
        public async Task <IActionResult> UserEdit(AppUserVM appUserVM)
        {
            ModelState.Remove("Password");
            ModelState.Remove("RepeatPassword");
            ViewBag.Gender = new SelectList(Enum.GetNames(typeof(Gender)));

            if (ModelState.IsValid)
            {
                AppUser user = await userManager.FindByNameAsync(User.Identity.Name);

                string phone = userManager.GetPhoneNumberAsync(user).Result;
                if (phone != appUserVM.PhoneNumber)
                {
                    if (userManager.Users.Any(u => u.PhoneNumber == appUserVM.PhoneNumber))
                    {
                        ModelState.AddModelError("", "Bu telefon numarası başka bir üye tarafından kullanılmaktadır");
                        return(View(appUserVM));
                    }
                }
                user.FirstName   = appUserVM.FirstName;
                user.LastName    = appUserVM.LastName;
                user.UserName    = appUserVM.UserName;
                user.Email       = appUserVM.Email;
                user.City        = appUserVM.City;
                user.BirthDay    = appUserVM.BirthDay;
                user.Gender      = (int)appUserVM.Gender;
                user.PhoneNumber = appUserVM.PhoneNumber;
                IdentityResult result = await userManager.UpdateAsync(user);

                if (result.Succeeded)
                {
                    await userManager.UpdateSecurityStampAsync(user);

                    await signInManager.SignOutAsync();

                    await signInManager.SignInAsync(user, true);


                    ViewBag.success = "true";
                }
                else
                {
                    foreach (var item in result.Errors)
                    {
                        ModelState.AddModelError("", item.Description);
                    }
                }
            }
            return(View(appUserVM));
        }
 public ActionResult AppUserUpdate(AppUserVM item)
 {
     if (ModelState.IsValid)
     {
         //auRep.Update(item.AppUser);
         audRep.Update(item.AppUserDetail);
         ViewBag.Status = 1;
         return(View());
     }
     else
     {
         ViewBag.Status = 2;
         return(View());
     }
 }