예제 #1
0
        public ActionResult Edit(decimal?id)
        {
            if (id != Convert.ToDecimal(UserHelper.GetUserId()))
            {
                TempData["message"] = ToasterMessage.Message(ToastType.warning, "Unauthorized Access");
                return(RedirectToAction("Index"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            User_Profile user_Profile = db.User_Profile.Find(id);

            if (user_Profile == null)
            {
                return(HttpNotFound());
            }

            ViewBag.CountryID = new SelectList(db.Country_Master.OrderBy(m => m.Name), "ID", "Name", user_Profile.CountryID);

            ViewBag.Role_id = new SelectList(db.Role_Master, "Id", "Name", user_Profile.Role_id);

            ViewBag.StateID = new SelectList(db.State_Master.OrderBy(m => m.Name), "ID", "Name", user_Profile.StateID);

            ViewBag.StateEnrolled = new SelectList(db.State_Master.OrderBy(m => m.Name), "ID", "Name", user_Profile.StateEnrolled);

            return(View(user_Profile));
        }
 public ActionResult ForgotPassword(User_Profile user_profile)
 {
     try
     {
         using (LaxNarroEntities db = new LaxNarroEntities())
         {
             var account = db.User_Profile.Where(a => a.EmailAddress == user_profile.EmailAddress).ToList();
             //var GetUserData = (db.User_Profile.Where(a => a.EmailAddress == email).ToList());
             string mailResult = "";
             if (account != null)
             {
                 mailResult = SendMail(account[0].EmailAddress, "~/EmailTemplate/ForgotPassword.html", account[0].FirstName,
                                       account[0].LastName, account[0].Password);
             }
             else
             {
                 ViewBag.message = ToasterMessage.Message(ToastType.error, "Invalid email");
             }
             if (mailResult == "success")
             {
                 ViewBag.message = ToasterMessage.Message(ToastType.success, "Password sent, check your email");
             }
         }
     }
     catch (Exception)
     {
     }
     return(View());
 }
예제 #3
0
        public ActionResult Profile(User_Profile refProfile)
        {
            using (var context = new StripeEntities())
            {
                UserProfileExistCheck profileCheck = new UserProfileExistCheck();
                UserProfile           userProfile  = new UserProfile();
                if (profileCheck.UserProfileExistence(refProfile.userProfile_ID, context))
                {
                    userProfile.UserProfileUpdate(context, refProfile);

                    context.SP_USER_PROFILE_REFEREE_UPDATE(refProfile.ref_Game_Specialization_Type,
                                                           refProfile.userProfile_ID,
                                                           refProfile.Sport_Name_spt_Sport_Name_ID);
                    context.SaveChanges();
                }
                else
                {
                    //Inserting Profile
                    userProfile.UserProfileInsert(context, refProfile);

                    context.SP_USER_PROFILE_REFEREE_INSERT(refProfile.ref_Game_Specialization_Type,
                                                           refProfile.userProfile_ID,
                                                           refProfile.Sport_Name_spt_Sport_Name_ID);
                    context.SaveChanges();
                }

                return(RedirectToAction("Profile"));
            }
        }
예제 #4
0
        public async Task <IActionResult> PutUser_Profile(int idUser, User_Profile user_Profile)
        {
            if (idUser != user_Profile.idUser)
            {
                return(BadRequest());
            }

            _context.Entry(user_Profile).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!User_ProfileExists(idUser))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #5
0
        public ActionResult ConfirmAccount()
        {
            ViewBag.message = @"<script type='text/javascript' language='javascript'>alert(""Invalid activation code"")</script>";
            if (RouteData.Values["RoleID"] != null)
            {
                Guid activationCode = new Guid(RouteData.Values["RoleID"].ToString());
                //LaxNarroEntities usersEntities = new LaxNarroEntities();
                User_Profile userActivation = db.User_Profile.Where(p => p.ActivationCode == activationCode).FirstOrDefault();
                if (userActivation != null)
                {
                    //usersEntities.User_Profile.Remove(userActivation);
                    if (userActivation.AccountConfirmed == "Yes")
                    {
                        ViewBag.Status = "This account has already been activated. If you have forgotton your " +
                                         "password click on forget password on login page.";
                    }
                    else
                    {
                        userActivation.AccountConfirmed = "Yes";

                        db.Entry(userActivation).State = EntityState.Modified;

                        db.SaveChanges();

                        SendMail(userActivation.FirstName, userActivation.LastName,
                                 userActivation.EmailAddress, "", "~/EmailTemplate/AccountValidated.html");

                        ViewBag.Status = "Thank you for confirming your account. Now you can Login and start using our services.";
                    }
                }
            }

            return(View());
        }
예제 #6
0
        public ActionResult Login(User_Profile model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                model.Password = null;
                model.UserName = null;
                return(View(model));
            }

            // need to add controller and method name based on changes to routing in WebApiConfig.cs
            response = client.PutAsJsonAsync <User_Profile>(gurukulWebApiUrl + @"/Account/" + @"/PutUser", model).Result;

            if (!response.IsSuccessStatusCode)
            {
                return(null);
            }

            var user = response.Content.ReadAsAsync <User_Profile>().Result;

            if (user == null)
            {
                ModelState.AddModelError("", "Invalid Login");
                return(View());
            }

            accountInternal.SignIn(user.UserName, false); //findout if login cookie needed.

            accountInternal.CurrentUser = user;

            return(RedirectToAction("Index", "Home"));
        }
예제 #7
0
        public ActionResult EditProfile(EditProfileModel model, HttpPostedFileBase postedFile)
        {
            //string username = (string)TempData["UserName"];
            if (postedFile != null)
            {
                string fileName = Path.GetFileName(postedFile.FileName);
                string path     = Server.MapPath("~/UploadedFiles/Images/profiles/");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                postedFile.SaveAs(path + fileName);
                ViewBag.ImageUrl = "~/UploadedFiles/Images/profiles/" + fileName;
            }

            using (XSkillsEntities1 entities = new XSkillsEntities1())
            {
                User_Profile xmodel = entities.User_Profile.Where(x => x.Name == model.Name).FirstOrDefault();
                //xmodel.Name = model.Name;
                xmodel.Skills              = model.Skills;
                xmodel.Wave                = model.Wave;
                xmodel.Trainings           = model.Trainings;
                xmodel.Certifications      = model.Certifications;
                xmodel.ImgUrl              = ViewBag.ImageUrl == null ? model.ImgUrl : ViewBag.ImageUrl;
                xmodel.Aspirational_Skills = string.Join(",", model.AspirationSkillsIds);

                model.ImgUrl = ViewBag.ImageUrl == null ? model.ImgUrl : ViewBag.ImageUrl;

                entities.SaveChanges();
            }
            model.AspirationSkills = GetItems(model.Aspirational_Skills, "Skills");
            return(View(model));
        }
예제 #8
0
        private User_Profile AddUserToDB(User_ProfileModel model)
        {
            //update User Profile
            var service = IoCConfig.Service <IUserProfileService>();

            var id   = model.Id;
            var user = new User_Profile();

            if (id != 0)
            {
                user = service.FindById(id);
                if (user == null)
                {
                    return(null);
                }
            }
            user = model.ToModel(user);
            if (user == null)
            {
                SetCustomError(model.ErrorMessage);
                return(null);//Trung phone va trung name thi khong cho add/edit
            }

            return(AddUserProfileToDB(user));
        }
예제 #9
0
 public async Task UpdateUserProfile(User_Profile profile)
 {
     using (var db = new HeznekServiceDbEntities())
     {
         db.User_Profile.AddOrUpdate(profile);
         await db.SaveChangesAsync();
     }
 }
예제 #10
0
        public ServiceResult InsertUser(User_Profile pProfile)
        {
            try
            {
                var currentdate = StoredProcedure.GetCurrentDate();
                using (var db = new AgnosDBContext())
                {
                    if (db.Users.Where(w => w.UserName.Equals(pProfile.Email_Address.ToLower())).FirstOrDefault() != null)
                    {
                        return new ServiceResult {
                                   Code = ReturnCode.ERROR_DATA_DUPLICATE, Msg = "duplicate " + "Email", Field = "Employee"
                        }
                    }
                    ;

                    var guid = Guid.NewGuid().ToString();
                    while (db.Users.Where(w => w.Id == guid).FirstOrDefault() != null)
                    {
                        guid = Guid.NewGuid().ToString();
                    }

                    db.Users.Add(new ApplicationUser()
                    {
                        Id = guid, UserName = pProfile.Email_Address.ToLower()
                    });

                    pProfile.PWD = hashSHA256(pProfile.PWD);
                    pProfile.ApplicationUser_Id = guid;
                    pProfile.Create_By          = userlogin.Email_Address;
                    pProfile.Create_On          = currentdate;
                    pProfile.Update_By          = userlogin.Email_Address;
                    pProfile.Update_On          = currentdate;

                    db.User_Profile.Add(pProfile);
                    db.SaveChanges();
                    return(new ServiceResult()
                    {
                        Code = ReturnCode.SUCCESS,
                        Msg = Success.GetMessage(ReturnCode.SUCCESS_INSERT),
                        Field = Resource.User
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ServiceResult()
                {
                    Code = ReturnCode.ERROR_INSERT,
                    Msg = Error.GetMessage(ReturnCode.ERROR_INSERT),
                    Field = Resource.User,
                    Exception = ex
                });
            }
        }
예제 #11
0
        //public ServiceResult DeleteUser(Nullable<int> pProfileID)
        //{
        //    try
        //    {
        //        using (var db = new AgnosDBContext())
        //        {
        //            var current = db.User_Profile.Where(w => w.Profile_ID == pProfileID).FirstOrDefault();
        //            if (current != null)
        //            {
        //                db.User_Profile.Remove(current);
        //                db.SaveChanges();
        //            }
        //            return new ServiceResult()
        //            {
        //                Code = ReturnCode.SUCCESS,
        //                Msg = Success.GetMessage(ReturnCode.SUCCESS_DELETE),
        //                Field = Resource.User
        //            };
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        return new ServiceResult()
        //        {
        //            Code = ReturnCode.ERROR_DELETE,
        //            Msg = Error.GetMessage(ReturnCode.ERROR_DELETE),
        //            Field = Resource.User,
        //            Exception = ex
        //        };
        //    }

        //}
        public User_Profile getUserByUsername(String pUName)
        {
            using (var db = new AgnosDBContext())
            {
                User_Profile user = db.User_Profile
                                    .Where(i => i.LDAP_Username.Equals(pUName))
                                    .FirstOrDefault();

                return(user);
            }
        }
예제 #12
0
        public User_Profile getUserByEmail(String pEmail)
        {
            using (var db = new AgnosDBContext())
            {
                User_Profile user = db.User_Profile
                                    .Where(i => i.Email_Address.Equals(pEmail))
                                    .FirstOrDefault();

                return(user);
            }
        }
예제 #13
0
        public User_Profile getUser(String AspNetUser_ID)
        {
            using (var db = new AgnosDBContext())
            {
                User_Profile user = db.User_Profile
                                    .Where(i => i.ApplicationUser_Id.Equals(AspNetUser_ID))
                                    .FirstOrDefault();

                return(user);
            }
        }
예제 #14
0
        public User_Profile getUser(int?pProfileID)
        {
            using (var db = new AgnosDBContext())
            {
                User_Profile user = db.User_Profile.Include(i => i.Role)
                                    .Where(i => i.Profile_ID == pProfileID)
                                    .FirstOrDefault();

                return(user);
            }
        }
        public User_Profile PutUser([FromBody] User_Profile model)
        {
            commonInternal = new CommonControllerInternal();
            _db            = commonInternal.GetConnection(_db);
            var user = _db.User_Profile.FirstOrDefault(u => u.UserName.Equals(model.UserName));

            if (user == null || (model.Password != user.Password))
            {
                return(null);
            }
            return(user);
        }
예제 #16
0
        public ActionResult LoginHome(string pagename)
        {
            string user = User.Identity.GetUserName();
            //var model = _userManager.FindByEmail(user);

            string       name  = dbContext.Users.Where(x => x.Email == user).FirstOrDefault().Name;
            User_Profile model = xSkills.User_Profile.Where(x => x.Name == name).FirstOrDefault();

            ViewBag.username = name;
            ViewBag.ImageUrl = model.ImgUrl;
            ViewBag.page     = pagename;
            return(PartialView("Sidebar"));
        }
예제 #17
0
 /// <summary>
 /// Delete A User By User_Guid
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool DeleteUser(User_Profile_Model model)
 {
     using (var db = new PermaisuriCMSEntities())
     {
         //这样做的好处在于能直接删除一个对象,而不需要先从数据库中提取数据,创建实体对象,再查找并删除之,从而能有效地提升效率
         var user = new User_Profile {
             User_Guid = model.User_Guid
         };
         db.Set <User_Profile>().Attach(user);
         db.User_Profile.Remove(user);
         return(db.SaveChanges() > 0);
     }
 }
예제 #18
0
        private User_Profile AddUserProfileToDB(User_Profile user)
        {
            var service = IoCConfig.Service <IUserProfileService>();
            //Check exist by phone
            var existed = service.FindValidByCriteria(
                a => a.User_Profile_Phone != null && a.User_Profile_Phone.Equals(user.User_Profile_Phone) &&
                a.User_Profile_Name != null && a.User_Profile_Name.Equals(user.User_Profile_Name) &&
                a.Id != user.Id);

            if (existed != null)
            {
                SetCustomError("Thông tin tài khoản không tồn tại hoặc bị trùng tên và số điện thoại!");
                return(null);//Trung phone va trung name thi khong cho add/edit
            }

            if (user.Id != 0)//Edit
            {
                user = service.Update(user);

                //update Account by User Profile
                IoCConfig.Service <IAccountService>().UpdateAccount(user);
            }
            else//Add
            {
                //add user
                user = service.Add(user);

                //add account
                var accountService = IoCConfig.Service <IAccountService>();
                var account        = accountService.Create(user.Email,
                                                           PasswordEncryptManager.EncryptPassword(AppSettings.DefaultPassword),
                                                           user.Obj_Id, user);
                account.HasSetPassword = true;
                account.Status         = user.Status;

                //Add new account
                account = accountService.Add(account);
                if (account != null)
                {
                    //accountService.Active(account);
                    //GetService().Active(u);//user profile khi add đã active sẵn rồi

                    //start sending email
                    //EmailHelper.SendMail_RegisterActiveSuccess(this.ControllerContext, account);
                    //EmailHelper.SendMail_InformUser(this.ControllerContext, user);
                    //end sending email
                }
            }

            return(user);
        }
예제 #19
0
 public ActionResult Register(User_Profile UP)
 {
     if (ModelState.IsValid)
     {
         using (AztecDatabaseEntities ad = new AztecDatabaseEntities())
         {
             ad.User_Profile.Add(UP);
             ad.SaveChanges();
             ModelState.Clear();
             UP = null;
             ViewBag.Message = "Successfully Register !";
         }
     }
     return(View(UP));
 }
예제 #20
0
        public Account UpdateAccount(User_Profile profile)
        {
            var acc = FindByCriteria(a => a.User_Profile_Id == profile.Id);

            if (acc != null)
            {
                acc.Account_Name   = profile.User_Profile_Name;
                acc.Account_Avatar = profile.User_Profile_Avatar;
                acc.Account_Email  = profile.User_Profile_Email;

                acc = Update(acc);
            }

            return(acc);
        }
예제 #21
0
        public ActionResult Details(decimal?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            User_Profile user_Profile = db.User_Profile.Find(id);

            if (user_Profile == null)
            {
                return(HttpNotFound());
            }

            return(View(user_Profile));
        }
예제 #22
0
        public int sendResetPassword(int Profile_ID, string domain)
        {
            DateTime currentdate = StoredProcedure.GetCurrentDate();

            using (var db = new AgnosDBContext())
            {
                try
                {
                    User_Profile user = getUser(Profile_ID);
                    //GENERATE ACTIVATION CODE
                    String code;
                    do
                    {
                        code = "R" + randomString(40);
                    } while (!validateActivationCode(code));

                    Activation_Link activation_link = new Activation_Link()
                    {
                        Activation_Code = code,
                        //SET Time_Limit to activate within LINK_TIME_LIMIT hour
                        Time_Limit = currentdate.AddHours(LINK_TIME_LIMIT),
                        Profile_ID = user.Profile_ID
                    };

                    db.Activation_Link.Add(activation_link);
                    db.SaveChanges();
                    try
                    {
                        //SEND EMAIL
                        //4		System	Send reset password link to user
                        EmailTemplete.sendResetPasswordEmail(user.Email_Address, code, user.Name, domain);
                    }
                    catch
                    {
                        return(0);
                    }
                }
                catch
                {
                    return(0);
                }
            }

            return(1);
        }
예제 #23
0
        public ActionResult Login(User_Profile log)
        {
            if (ModelState.IsValid)
            {
                using (AztecDatabaseEntities adb = new AztecDatabaseEntities())
                {
                    var obj = adb.User_Profile.Where(a => a.UserName.Equals(log.UserName) && a.Password.Equals(log.Password)).FirstOrDefault();
                    if (obj != null)
                    {
                        Session["UserName"] = obj.UserName.ToString();
                        Session["Password"] = obj.Password.ToString();

                        return(RedirectToAction("Index"));
                    }
                }
            }
            return(View(log));
        }
예제 #24
0
        public async Task <IHttpActionResult> UpdateUserProfile([FromBody] User_Profile profile)
        {
            if (string.IsNullOrEmpty(profile.id) || string.IsNullOrWhiteSpace(profile.id))
            {
                return(BadRequest("User id was not provided!"));
            }

            try
            {
                await this.userRepository.UpdateUserProfile(profile);

                return(Ok("Profile updated successfully"));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #25
0
        public User_Profile GetUser()
        {
            var userSession = HttpContext.Session["User"] as User_Profile;

            if (User.Identity.IsAuthenticated)
            {
                if (userSession == null)
                {
                    var          userService = new UserService();
                    User_Profile profile     = userService.getUserByEmail(User.Identity.Name);
                    if (profile != null)
                    {
                        HttpContext.Session["User"] = profile;
                        userSession = HttpContext.Session["User"] as User_Profile;
                    }
                }
            }
            return(userSession);
        }
예제 #26
0
 public User_Profile ToModel(User_Profile u)
 {
     if (u.Id == 0)
     {
         u.User_Profile_Avatar = AppSettings.DefaultAccountAvatar;
     }
     if (uploadFile != null)
     {
         u.User_Profile_Avatar = Helper.SaveAs(AppSettings.UploadUserPhotos, uploadFile);
     }
     u.User_Profile_Name     = User_Profile_Name;
     u.User_Profile_Phone    = User_Profile_Phone;
     u.User_Profile_Address  = User_Profile_Address;
     u.User_Profile_Birthday = User_Profile_Birthday;
     u.User_Profile_Email    = User_Profile_Email;
     u.User_Profile_Gender   = User_Profile_Gender;
     u.Created_Date          = DateTime.Now;
     return(u);
 }
예제 #27
0
        public ActionResult Profile(User_Profile refProfile)
        {
            using (var context = new StripeEntities())
            {
                UserProfileExistCheck profileCheck = new UserProfileExistCheck();
                UserProfile           userProfile  = new UserProfile();
                if (profileCheck.UserProfileExistence(refProfile.userProfile_ID, context))
                {
                    userProfile.UserProfileUpdate(context, refProfile);
                }
                else
                {
                    //Inserting Profile
                    userProfile.UserProfileInsert(context, refProfile);
                }

                return(RedirectToAction("Profile"));
            }
        }
예제 #28
0
        public ActionResult Unsubscribe()
        {
            if (RouteData.Values["RoleID"] != null)
            {
                decimal      id = Convert.ToDecimal(RouteData.Values["RoleID"]);
                User_Profile unsubscribeUser = db.User_Profile.Where(p => p.ID == id).FirstOrDefault();
                if (unsubscribeUser != null)
                {
                    unsubscribeUser.MailUnsubscribed = "Yes";

                    db.Entry(unsubscribeUser).State = EntityState.Modified;

                    db.SaveChanges();

                    ViewBag.Status = unsubscribeUser.EmailAddress + " has been unsubscribed from our e-mailing services.";
                }
            }

            return(View());
        }
예제 #29
0
 /// <summary>
 /// Add New User
 /// </summary>
 /// <param name="model"></param>
 /// <param name="curUserAccount"></param>
 /// <returns></returns>
 public bool AddUser(User_Profile_Model model, String curUserAccount)
 {
     using (var db = new PermaisuriCMSEntities())
     {
         var newUser = new User_Profile
         {
             User_Guid    = Guid.NewGuid(),
             Display_Name = model.Display_Name,
             Created_By   = curUserAccount,
             Created_On   = DateTime.Now,
             //Status = model.Status,
             Primary_Email = model.Primary_Email,
             Mobile_Phone  = model.Mobile_Phone,
             User_Account  = model.User_Account,
             User_Pwd      = model.User_Pwd
         };
         db.User_Profile.Add(newUser);
         return(db.SaveChanges() > 0);
     }
 }
예제 #30
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User_Profile();
                user.Email_Address = model.Email_Address;
                user.PWD           = EncryptUtil.Encrypt(model.Password);

                var uService = new UserService(user);
                var result   = uService.InsertUser(user);
                if (result.Code == ReturnCode.SUCCESS)
                {
                    UserManager <ApplicationUser> userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new AgnosDBContext()));
                    userManager.UserValidator = new UserValidator <ApplicationUser>(userManager)
                    {
                        AllowOnlyAlphanumericUserNames = false
                    };
                    IdentityResult iresult = await userManager.RemovePasswordAsync(user.ApplicationUser_Id);

                    if (iresult.Succeeded)
                    {
                        iresult = await userManager.AddPasswordAsync(user.ApplicationUser_Id, model.Password);

                        if (iresult.Succeeded)
                        {
                            var userauthen = await UserManager.FindAsync(model.Email_Address, model.Password);

                            if (userauthen != null)
                            {
                                await SignInAsync(userauthen, true);

                                return(RedirectToAction("Material", "Material"));
                            }
                        }
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }