public ActionResult UserProfile(string RecordId, string MenuId)
        {
            GenelRepository gnlDB = RepositoryManager.GetRepository <GenelRepository>();
            User            model = new User();

            MenuId         = GlobalHelper.Decrypt(MenuId);
            model.RecordId = RecordId;
            model.MenuId   = MenuId;
            SessionContext.Current.ActiveUser.MenuId = MenuId;


            Guid recordId = Guid.Empty;

            if (GlobalHelper.IsGuid(model.RecordId))
            {
                try
                {
                    recordId = Guid.Parse(model.RecordId);
                    model    = gnlDB.BindUser(model, recordId);
                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                }
                catch (Exception exp)
                {
                    ViewBag.Success = false;
                    ModelState.AddModelError("Error", exp.Message);
                }
            }



            return(View(model));
        }
        public ActionResult User(string RecordId, string MenuId)
        {
            GenelRepository gnlDB = RepositoryManager.GetRepository <GenelRepository>();
            User            model = new User();


            MenuId         = GlobalHelper.Decrypt(MenuId);
            model.RecordId = RecordId;
            model.MenuId   = MenuId;
            SessionContext.Current.ActiveUser.MenuId = MenuId;


            Guid recordId = Guid.Empty;

            model.activeGroups = gnlDB.GetActiveGroups();

            if (model.activeGroups != null && model.activeGroups.Count > 0)
            {
                model.SelectedGroupId = model.activeGroups[0].group_id.ToString();
            }

            if (GlobalHelper.IsGuid(model.RecordId))
            {
                try
                {
                    recordId = Guid.Parse(model.RecordId);
                    model    = gnlDB.BindUser(model, recordId);
                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                }
                catch (Exception exp)
                {
                    ViewBag.Success = false;
                    ModelState.AddModelError("Error", exp.Message);
                }
            }

            if (!string.IsNullOrEmpty(model.ManagerId) && GlobalHelper.IsGuid(model.ManagerId))
            {
                gnl_users userManager = gnlDB.GetUser(Guid.Parse(model.ManagerId));

                if (userManager != null)
                {
                    model.ManagerName = userManager.name + " " + userManager.surname;
                }
            }

            return(View(model));
        }
        public ActionResult UserProfile(User model)
        {
            Guid            recordId = Guid.Empty;
            GenelRepository gnlDB    = RepositoryManager.GetRepository <GenelRepository>();

            SessionContext.Current.ActiveUser.MenuId = model.MenuId;
            ViewBag.Success = true;



            ModelState.Remove("name");
            ModelState.Remove("surname");
            ModelState.Remove("email");
            ModelState.Remove("mobile_phone");
            ModelState.Remove("address");



            if (ModelState.IsValid)
            {
                if (GlobalHelper.IsGuid(model.RecordId))
                {
                    recordId = Guid.Parse(model.RecordId);
                    try
                    {
                        string password = gnlDB.GetUserPassword(recordId);
                        if (string.IsNullOrEmpty(model.oldPassword))
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", Resources.GlobalResource.old_password_not_null);
                        }
                        else if (string.IsNullOrEmpty(model.newPassword))
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", Resources.GlobalResource.new_password_not_null);
                        }
                        else if (string.IsNullOrEmpty(model.newPasswordRepeat))
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", Resources.GlobalResource.new_password_repeat_not_null);
                        }
                        else if (password != GlobalHelper.EncriptText(model.oldPassword))
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", Resources.GlobalResource.wrong_old_password);
                        }
                        else if (model.newPassword != model.newPasswordRepeat)
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", Resources.GlobalResource.wrong_repeat_password);
                        }
                        else
                        {
                            model.password = GlobalHelper.EncriptText(model.newPassword.Trim());
                            model          = gnlDB.UpdateUserPassword(model, recordId);

                            if (!string.IsNullOrEmpty(model.password))
                            {
                                ViewBag.ResultMessage = Resources.GlobalResource.transaction_success_with_password;
                            }
                            else
                            {
                                ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                            }
                        }

                        model = gnlDB.BindUser(model, recordId);
                    }
                    catch (Exception exp)
                    {
                        ViewBag.Success = false;
                        ModelState.AddModelError("Error", exp.Message);
                    }
                }
            }
            return(View(model));
        }