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


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


            model.activeGroups = gnlDB.GetActiveGroups();

            ModelState.Remove("start_date");
            ModelState.Remove("end_date");
            ModelState.Remove("is_active");

            if (model.FromDeleteButton == "1")
            {
                if (GlobalHelper.IsGuid(model.RecordId))
                {
                    gnlDB.DeleteUser(model, Guid.Parse(model.RecordId));
                    return(RedirectToAction("ListPage", "General", new { MenuId = Dcm.Source.GlobalHelper.Encrypt(model.MenuId) }));
                }
            }
            else
            {
                if (ModelState.IsValid)
                {
                    if (GlobalHelper.IsGuid(model.RecordId))
                    {
                        recordId = Guid.Parse(model.RecordId);
                        try
                        {
                            if (!string.IsNullOrEmpty(model.password))
                            {
                                model.password = GlobalHelper.EncriptText(model.password.Trim());
                            }

                            gnl_users userByEmail = new gnl_users();
                            userByEmail = gnlDB.GetUserByEmail(model.email.Trim());

                            if (userByEmail != null && userByEmail.user_id != recordId)
                            {
                                ViewBag.Success = false;
                                ModelState.AddModelError("Error", Resources.GlobalResource.exists_user_email);
                            }
                            else
                            {
                                model = gnlDB.UpdateUser(model, recordId);

                                if (!string.IsNullOrEmpty(model.password))
                                {
                                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success_with_password;
                                }
                                else
                                {
                                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                                }
                            }
                        }
                        catch (Exception exp)
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", exp.Message);
                        }
                    }
                    else
                    {
                        try
                        {
                            gnl_users user = new gnl_users();

                            if (!string.IsNullOrEmpty(model.password))
                            {
                                model.password = GlobalHelper.EncriptText(model.password.Trim());
                            }

                            gnl_users userByEmail = new gnl_users();
                            userByEmail = gnlDB.GetUserByEmail(model.email.Trim());

                            if (userByEmail != null)
                            {
                                ViewBag.Success = false;
                                ModelState.AddModelError("Error", Resources.GlobalResource.exists_user_email);
                            }
                            else
                            {
                                gnlDB.AddUser(user, model);
                                model.RecordId = user.user_id.ToString();

                                if (!string.IsNullOrEmpty(model.password))
                                {
                                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success_with_password;
                                }
                                else
                                {
                                    ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                                }
                            }
                        }
                        catch (Exception exp)
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", exp.Message);
                        }
                    }
                }
                else
                {
                    ViewBag.Success = false;
                }

                if (string.IsNullOrEmpty(model.ManagerName))
                {
                    model.ManagerId = null;
                }

                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));
        }