public IActionResult CheckPermission([FromBody] AdminCheckPermissionView checkView)
        {
            IActionResult response   = null;
            UserModels    userModels = new UserModels();

            var identity = (ClaimsIdentity)User.Identity;
            IEnumerable <Claim> claims = identity.Claims;
            var userLogin = claims.FirstOrDefault(c => c.Type == ClaimTypes.Email).Value;

            var action = userModels.GetActionByActionName(checkView.TypeAct);

            string typeAct = action != null?action.Id.ToString() : string.Empty;

            ////check permission update
            if (UserModels.CheckPermission(userLogin, checkView.Path, typeAct, checkView.Type))
            {
                response = Json(new { code = Constant.PermissionAccessCode, message = Constant.MessagePermissionAccess });
            }
            else
            {
                response = Json(new { code = Constant.PermissionDeniedCode, message = Constant.MessagePermissionDenied });
            }

            return(response);
        }
        /// <summary>
        /// Updates the status is show page static.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="status">The status.</param>
        /// <param name="type">The type.</param>
        /// <returns>update status is show page static</returns>
        public ActionResult Update_status_is_show_page_static(string id, string status, string type)
        {
            PageModels pageModels = new PageModels();
            C_Pages    cpage      = new C_Pages();
            bool       isOk       = false;

            if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, "change_static", "adminStatic", CommonGlobal.Edit, type))
            {
                isOk = true;
            }
            else
            {
                isOk = false;
            }

            if (!string.IsNullOrEmpty(id))
            {
                if (int.Parse(id) > 0)
                {
                    cpage = pageModels.GetbyID(int.Parse(id));
                }

                if (cpage != null)
                {
                    try
                    {
                        if (bool.Parse(status) == true)
                        {
                            cpage.Show = true;
                        }
                        else
                        {
                            cpage.Show = false;
                        }

                        if (isOk)
                        {
                            cpage.DateModified = DateTime.Now;
                            pageModels.Edit(cpage);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            var jsonSerialiser = new JavaScriptSerializer();
            var results        = Convert.ToDateTime(DateTime.Now).ToString("dd/MM/yyyy") + "|" + cpage.Show;

            return(this.Json(results));
        }
        /// <summary>
        /// Updates the status is hot post.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="status">The status.</param>
        /// <param name="type">The type.</param>
        /// <returns>update status is hot post</returns>
        public ActionResult Update_status_is_hot_post(string id, string status, string type)
        {
            PostModels postModel = new PostModels();
            C_Post     objPost   = new C_Post();
            bool       isOk      = false;

            if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, "change_post", "adminPost", CommonGlobal.Edit, type))
            {
                isOk = true;
            }
            else
            {
                isOk = false;
            }

            if (!string.IsNullOrEmpty(id))
            {
                if (int.Parse(id) > 0)
                {
                    objPost = postModel.GetbyID(int.Parse(id));
                }

                if (objPost != null)
                {
                    try
                    {
                        if (bool.Parse(status) == true)
                        {
                            objPost.IsHot = true;
                        }
                        else
                        {
                            objPost.IsHot = false;
                        }

                        if (isOk)
                        {
                            objPost.DateModified = DateTime.Now;
                            postModel.Edit(objPost);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            var jsonSerialiser = new JavaScriptSerializer();
            var results        = Convert.ToDateTime(DateTime.Now).ToString("dd/MM/yyyy") + "|" + objPost.IsHot;

            return(this.Json(results));
        }
示例#4
0
        public ActionResult Admin_menu()
        {
            StringBuilder strData         = new StringBuilder();
            UserModels    userModels      = new UserModels();
            var           admin_menu_view = new Admin_menu_view();

            using (var data = new Entities())
            {
                List <C_UserPage> lstParent = userModels.GetListParentPage();
                if (lstParent.Any())
                {
                    strData.Append(" <ul class=\"nav nav-list\">");
                    foreach (var parent in lstParent)
                    {
                        List <C_UserPage> lstChild = userModels.GetListUserPageByParrentID(parent.id);
                        bool          isAdd        = false;
                        StringBuilder menuChild    = new StringBuilder();
                        if (lstChild.Any())
                        {
                            menuChild.Append("<ul class=\"submenu\">");
                            foreach (var child in lstChild)
                            {
                                string url = Url.RouteUrl("admin_default", new { controller = "dashboard", action = "index", act = child.act, ctrl = child.ctrl, type_act = child.TypeAction, type = child.Tye, page = "1", parent = "0" });
                                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, child.act, child.ctrl, child.TypeAction, child.Tye))
                                {
                                    menuChild.Append("<li><a href=\"" + url + "\">" + child.Icon + "</i>" + child.Title + "</a></li>");
                                    isAdd = true;
                                }
                            }

                            menuChild.Append("</ul>");
                        }

                        if (isAdd)
                        {
                            strData.Append("<li>");
                            strData.Append(" <a href=\"#\" class=\"dropdown-toggle\">" + parent.Icon + "<span class=\"menu-text\">" + parent.Title + "</span><b class=\"arrow icon-angle-down\"></b></a>");
                            strData.Append(menuChild);
                            strData.Append("</li>");
                        }
                    }

                    strData.Append("</ul>");
                }
            }

            admin_menu_view.Menu = strData.ToString();

            return(this.PartialView("../control/admin_menu", admin_menu_view));
        }
        /// <summary>
        /// Updates the status user.
        /// </summary>
        /// <param name="user_name">Name of the user.</param>
        /// <param name="status">The status.</param>
        /// <param name="type">The type.</param>
        /// <returns>update status user</returns>
        public ActionResult Update_status_user(string user_name, string status, string type)
        {
            UserModels userModels = new UserModels();
            C_User     cuser      = new C_User();
            bool       isOk       = false;

            if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, "change_user", "adminUser", CommonGlobal.Edit, type))
            {
                isOk = true;
            }
            else
            {
                isOk = false;
            }

            if (!string.IsNullOrEmpty(user_name))
            {
                cuser = userModels.GetUserbyUserName(user_name);
                if (cuser != null)
                {
                    try
                    {
                        if (bool.Parse(status) == true)
                        {
                            cuser.Online = true;
                        }
                        else
                        {
                            cuser.Online = false;
                        }

                        if (isOk)
                        {
                            userModels.Update_User(cuser);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            var jsonSerialiser = new JavaScriptSerializer();
            var results        = Convert.ToDateTime(DateTime.Now).ToString("dd/MM/yyyy") + "|" + cuser.Online;

            return(this.Json(results));
        }
        public ActionResult List_email(FormCollection collection, int?email_id, string type, string act, string ctrl, string type_act, int?page, int?page_size)
        {
            EmailModels         emailModel          = new EmailModels();
            EmailTemplateModels emailTemplateModels = new EmailTemplateModels();
            var list_email = new Web.Areas.Admin.ViewModels.List_email_view();

            this.TryUpdateModel(list_email);

            List <SelectListItem> list_select_tempate = new List <SelectListItem>();

            emailTemplateModels.List_email_template(0, ref list_select_tempate);
            StringBuilder sb = new StringBuilder();

            int total_record = 0;

            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : CommonGlobal.RoleAdmin;
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_email";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "dminEmail";
            }

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            string email_address = collection["email_address"].ToString();

            if (email_id > 0 && type_act != null && type_act == CommonGlobal.Delete)
            {
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type))
                {
                    bool rt = emailModel.Delete((int)email_id);
                    if (rt)
                    {
                        list_email.Message = "Bạn đã xóa email: " + email_address;
                    }
                    else
                    {
                        list_email.Message = "Xóa không thành công";
                    }
                }
            }

            int totalRecord = 0;

            if (!string.IsNullOrEmpty(collection["total_record_on_page"]))
            {
                totalRecord = int.Parse(collection["total_record_on_page"]);
            }

            string subject       = collection["emailSubject"];
            string body          = collection["emailBody"];
            bool   flag_SendMail = false;

            if (list_email.IsSendAll)
            {
                list_email.IsSendAll     = true;
                list_email.IsSendAllText = "checked='checked'";
                List <C_Email> lstEmailSend = emailModel.AllEmail();
                if (lstEmailSend.Any())
                {
                    foreach (C_Email objEmail in lstEmailSend)
                    {
                        CommonGlobal.SendMail(objEmail.email, subject, body);
                    }

                    flag_SendMail = true;
                }
            }
            else
            {
                list_email.IsSendAll     = false;
                list_email.IsSendAllText = string.Empty;
                for (int i = 1; i <= totalRecord; ++i)
                {
                    string email  = string.Empty;
                    string chkBox = collection["chk_" + i];
                    if (!string.IsNullOrEmpty(chkBox))
                    {
                        if (chkBox.Contains("true"))
                        {
                            email = collection["email_" + i];
                            CommonGlobal.SendMail(email, subject, body);
                            flag_SendMail = true;
                        }
                    }
                }
            }

            if (flag_SendMail)
            {
                ////Message
                list_email.Message = "Đã gửi mail thành công.";
            }

            //////tab
            sb.Append("<li class=\"active\"><a href=\"#\"><span>Email Marketing</span></a></li>");
            list_email.Html_link_tab = sb.ToString();

            //////list post
            PagedList <C_Email> lstEmail = emailModel.GetListEmail((int)page, (int)page_size, out total_record);

            list_email.ListEmail            = lstEmail;
            list_email.Total_record         = total_record;
            list_email.Total_record_on_page = lstEmail.Count();
            list_email.Type_act             = type_act;
            list_email.ListTemplate         = list_select_tempate;
            //////action
            list_email.Act          = act;
            list_email.Ctrl         = ctrl;
            list_email.SubjectEmail = subject;
            list_email.BodyEmail    = body;

            list_email.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_email.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            //////end action

            return(this.PartialView("../control/list_email", list_email));
        }
        public ActionResult List_page_static(int?id, string act, string ctrl, string type_act, string type, string lang, string search, int?page, int?page_size, string order_by, string order_type)
        {
            PageModels    pageModels     = new PageModels();
            StringBuilder sb             = new StringBuilder();
            C_Pages       cpage          = new C_Pages();
            var           list_page_view = new Web.Areas.Admin.ViewModels.List_page_view();
            int           total_record   = 0;

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_page_static";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminStatic";
            }

            if (string.IsNullOrEmpty(type_act))
            {
                type_act = Request.QueryString["type_act"] != null ? Request.QueryString["type_act"].ToString() : CommonGlobal.View;
            }

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (string.IsNullOrEmpty(lang))
            {
                lang = LanguageModels.ActiveLanguage().LangCultureName;
            }

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            if (id != null && type_act != null && type_act == CommonGlobal.Delete)
            {
                ////check permission delete
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type ?? string.Empty))
                {
                    cpage = pageModels.GetbyID((int)id);
                    if (cpage != null)
                    {
                        ////delete old image
                        if (!string.IsNullOrEmpty(cpage.ImagePath))
                        {
                            string strImg = cpage.ImagePath;
                            strImg = "~" + strImg;
                            string fileDelete = Server.MapPath(strImg);
                            if (System.IO.File.Exists(fileDelete))
                            {
                                System.IO.File.Delete(fileDelete);
                            }

                            string fileDelete2 = Server.MapPath(strImg.Replace("sc_small_", "sc_full_"));
                            if (System.IO.File.Exists(fileDelete2))
                            {
                                System.IO.File.Delete(fileDelete2);
                            }
                        }

                        ////delete category
                        bool rt = pageModels.Delete((int)id);
                        if (rt)
                        {
                            list_page_view.Message = "Bạn đã xóa page " + id;
                        }
                        else
                        {
                            list_page_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_page_view.Message = "Không tìm thấy page : " + id;
                    }
                }
                else
                {
                    list_page_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }

            if (string.IsNullOrEmpty(order_by) || string.IsNullOrEmpty(order_type))
            {
                order_by   = "OrderDisplay";
                order_type = "asc";
            }

            list_page_view.Type_act  = type_act;
            list_page_view.Cate_type = "Danh sách trang tĩnh ";
            list_page_view.Lang      = lang;
            ////tab
            sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_page_static", ctrl = "adminStatic", page = "1" }) + "\"><span><span>Danh sách trang tĩnh</span></span></a></li>");
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "change_static", ctrl = "adminStatic", type_act = CommonGlobal.Add }) + "\"><span><span>Thêm trang tĩnh</span></span></a></li>");
            list_page_view.Html_link_tab = sb.ToString();
            ////list language
            list_page_view.List_language = this.List_select_language(this.Lang);
            ////list page size and paging
            list_page_view.List_page_size = this.GetSizePagingPublic((int)page_size);
            list_page_view.Page           = (int)page;
            list_page_view.Page_size      = (int)page_size;
            ////list catalog
            list_page_view.Page_list    = pageModels.GetAllPageStaticAdmin(lang, search, (int)page, (int)page_size, order_by, order_type, out total_record);
            list_page_view.Search       = search;
            list_page_view.Order_by     = order_by;
            list_page_view.Order_type   = order_type;
            list_page_view.Total_record = total_record;
            ////acton and parent action
            list_page_view.Act               = act;
            list_page_view.Ctrl              = ctrl;
            list_page_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_page_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/list_page_static", list_page_view));
        }
        public ActionResult List_user(string user_name, string act, string ctrl, string type_act, string type, string lang, string search, int?page, int?page_size, string order_by, string order_type)
        {
            UserModels    userModels     = new UserModels();
            RoleModels    roleModels     = new RoleModels();
            C_User        cuser          = new C_User();
            StringBuilder sb             = new StringBuilder();
            var           list_user_view = new Web.Areas.Admin.ViewModels.List_user_view();

            this.TryUpdateModel(list_user_view);
            int total_record = 0;

            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : string.Empty;
            }

            if (type == string.Empty)
            {
                list_user_view.Message = "Chúng tôi không tìm thấy danh sách bạn yêu cầu";
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_user";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminUser";
            }

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (string.IsNullOrEmpty(lang))
            {
                lang = LanguageModels.ActiveLanguage().LangCultureName;
            }

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            if (user_name != null && type_act != null && type_act == CommonGlobal.Delete)
            {
                ////check permission delete
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type ?? string.Empty))
                {
                    cuser = userModels.GetUserbyUserName(user_name);
                    if (cuser != null)
                    {
                        ////delete user
                        bool rt = userModels.Delete_User(user_name);
                        if (rt)
                        {
                            list_user_view.Message = "Bạn đã xóa " + user_name;
                        }
                        else
                        {
                            list_user_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_user_view.Message = "Không tìm thấy  : " + user_name;
                    }
                }
                else
                {
                    list_user_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }

            if (string.IsNullOrEmpty(order_by) || string.IsNullOrEmpty(order_type))
            {
                order_by   = "Username";
                order_type = "asc";
            }

            list_user_view.Type      = type;
            list_user_view.Cate_type = roleModels.GetRoleByRole(type);
            list_user_view.Lang      = lang;
            list_user_view.Type_act  = type_act;
            ////tab
            sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Danh sách " + list_user_view.Cate_type + "</span></span></a></li>");
            if (type == "Admin")
            {
                sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "change_user", ctrl = "adminUser", type = type, type_act = CommonGlobal.Add }) + "\"><span><span>Thêm " + list_user_view.Cate_type + "</span></span></a></li>");
            }

            list_user_view.Html_link_tab = sb.ToString();
            ////list language
            list_user_view.List_language = this.List_select_language(this.Lang);
            ////list page size and paging
            list_user_view.List_page_size = this.GetSizePagingPublic((int)page_size);
            list_user_view.Page           = (int)page;
            list_user_view.Page_size      = (int)page_size;
            ////list catalog
            list_user_view.Page_list_user = userModels.AdminGetAllUser(type, lang, search, (int)page, (int)page_size, order_by, order_type, out total_record);
            list_user_view.Search         = search;
            list_user_view.Order_by       = order_by;
            list_user_view.Order_type     = order_type;
            list_user_view.Total_record   = total_record;
            ////acton and parent action
            list_user_view.Act               = act;
            list_user_view.Ctrl              = ctrl;
            list_user_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_user_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/list_user", list_user_view));
        }
        public ActionResult List_log(int?id, DateTime?from_date, DateTime?to_date, string act, string ctrl, string type_act, string type, string search, int?page, int?page_size, string order_by, string order_type)
        {
            LogModels     logModels     = new LogModels();
            Log           logs          = new Log();
            StringBuilder sb            = new StringBuilder();
            var           list_log_view = new Web.Areas.Admin.ViewModels.List_log_view();
            int           total_record  = 0;

            if (from_date == null)
            {
                from_date = DateTime.Now.AddMonths(-1);
            }

            if (to_date == null)
            {
                to_date = DateTime.Now;
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_log";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminUser";
            }

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            if (string.IsNullOrEmpty(order_by) || string.IsNullOrEmpty(order_type))
            {
                order_by   = "EventDateTime";
                order_type = "desc";
            }

            if (id != null && type_act != null && type_act == CommonGlobal.Delete)
            {
                ////check permission delete
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type ?? string.Empty))
                {
                    logs = logModels.GetLogbyID((int)id);
                    if (logs != null)
                    {
                        ////delete order
                        bool rt = logModels.Delete((int)id);
                        if (rt)
                        {
                            list_log_view.Message = "Bạn đã xóa log record :" + id;
                        }
                        else
                        {
                            list_log_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_log_view.Message = "Không tìm thấy log record : " + id;
                    }
                }
                else
                {
                    list_log_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }

            list_log_view.Cate_type = "Log system";
            list_log_view.Type_act  = type_act;
            ////tab
            sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Log system</span></span></a></li>");
            list_log_view.Html_link_tab = sb.ToString();
            ////list page size and paging
            list_log_view.List_page_size = this.GetSizePagingPublic((int)page_size);
            list_log_view.Page           = (int)page;
            list_log_view.Page_size      = (int)page_size;
            ////list catalog
            list_log_view.Page_list_log = logModels.GetAllLogByAdmin((DateTime)from_date, (DateTime)to_date, search, (int)page, (int)page_size, order_by, order_type, out total_record);
            list_log_view.Search        = search;
            list_log_view.Order_by      = order_by;
            list_log_view.Order_type    = order_type;
            list_log_view.Total_record  = total_record;
            ////Filter
            list_log_view.Search    = search;
            list_log_view.From_date = (DateTime)from_date;
            list_log_view.To_date   = (DateTime)to_date;
            ////acton and parent action
            list_log_view.Act               = act;
            list_log_view.Ctrl              = ctrl;
            list_log_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_log_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/list_log", list_log_view));
        }
示例#10
0
        public ActionResult List_showroom(int?city, int?district, int?showroom_id, string type, string act, string ctrl, string type_act, int?page, int?page_size)
        {
            ShowroomModels showroomModels = new ShowroomModels();
            CityModels     cityModels     = new CityModels();
            DistrictModels districtModels = new DistrictModels();

            List <SelectListItem> list_city     = new List <SelectListItem>();
            List <SelectListItem> list_district = new List <SelectListItem>();
            var           list_showroom_view    = new Web.Areas.Admin.ViewModels.List_showroom_view();
            StringBuilder sb = new StringBuilder();

            int total_record = 0;

            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : CommonGlobal.RoleAdmin;
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_post";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminPost";
            }

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (city == null)
            {
                city = Request.QueryString["city"] != null?Convert.ToInt32(Request.QueryString["city"].ToString()) : 0;
            }

            if (district == null)
            {
                district = Request.QueryString["district"] != null?Convert.ToInt32(Request.QueryString["district"].ToString()) : 0;
            }

            if (string.IsNullOrEmpty(this.Lang))
            {
                this.Lang = LanguageModels.ActiveLanguage().LangCultureName;
            }

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            list_showroom_view.Page      = (int)page;
            list_showroom_view.Page_size = (int)page_size;

            list_showroom_view.List_city     = cityModels.List_city((int)city);
            list_showroom_view.List_district = districtModels.List_district((int)city, (int)district);

            ////tab
            sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_showroom", ctrl = "adminShowroom", type = type, page = "1", city = city, district = district, lang = Lang }) + "\"><span><span>Danh sách Showroom</span></span></a></li>");
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "change_showroom", ctrl = "adminShowroom", type = type, type_act = "add", city = city, district = district, lang = Lang }) + "\"><span><span>Thêm Showroom</span></span></a></li>");
            list_showroom_view.Html_link_tab = sb.ToString();

            if (showroom_id != null && showroom_id != 0 && type_act != null && type_act == CommonGlobal.Delete)
            {
                ////check permission delete
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type))
                {
                    Showroom objShowroom = new Showroom();
                    objShowroom = showroomModels.GetShowroomById((int)showroom_id);
                    if (objShowroom != null)
                    {
                        ////delete post
                        bool rt = showroomModels.Delete((int)showroom_id);
                        if (rt)
                        {
                            list_showroom_view.Message = "Bạn đã xóa showroom: " + objShowroom.Name;
                        }
                        else
                        {
                            list_showroom_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_showroom_view.Message = "Không tìm thấy showroom: " + objShowroom.Name;
                    }
                }
                else
                {
                    list_showroom_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }
            ////list post
            list_showroom_view.List_page_size     = this.GetSizePagingPublic((int)page_size);
            list_showroom_view.Page_list_showroom = showroomModels.GetListShowroom((int)district, (int)page, (int)page_size, out total_record);
            list_showroom_view.Total_record       = total_record;
            list_showroom_view.Type_act           = type_act;
            ////action
            list_showroom_view.Act               = act;
            list_showroom_view.Ctrl              = ctrl;
            list_showroom_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_showroom_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            ////end action

            return(this.PartialView("../control/list_showroom", list_showroom_view));
        }
        public ActionResult List_catalog(int?parent, int?cate_id, string act, string ctrl, string type, string type_act, string lang, string search, int?page, int?page_size, string order_by, string order_type)
        {
            CatalogModels         cateModels          = new CatalogModels();
            C_Catalog             cate                = new C_Catalog();
            StringBuilder         sb                  = new StringBuilder();
            List <SelectListItem> list_select_catalog = new List <SelectListItem>();
            var list_catalog_view = new Web.Areas.Admin.ViewModels.List_catalog_view();
            int total_record      = 0;
            int level             = 0;

            /////type is get type catalog
            /////ex   : SP - product
            /////     : TT - news
            /////     : CL - collection
            /////     : LB - lookbook
            /////     : GL - gallery
            /////parent is parent id
            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : CommonGlobal.CateProduct;
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_catalog";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminCatalog";
            }

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (parent == null)
            {
                parent = Request.QueryString["parent"] != null?Convert.ToInt32(Request.QueryString["parent"].ToString()) : 0;
            }

            if (string.IsNullOrEmpty(lang))
            {
                lang = LanguageModels.ActiveLanguage().LangCultureName;
            }

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            if (string.IsNullOrEmpty(order_by) || string.IsNullOrEmpty(order_type))
            {
                order_by   = "OrderDisplay";
                order_type = "asc";
            }

            ////type act delete
            if (cate_id != null && type_act != null && type_act == CommonGlobal.Delete)
            {
                ////check permission delete
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type))
                {
                    cate = cateModels.GetbyID((int)cate_id);
                    if (cate != null)
                    {
                        ////delete old image
                        if (!string.IsNullOrEmpty(cate.ImagePath))
                        {
                            string strImg = cate.ImagePath;
                            strImg = "~" + strImg;
                            string fileDelete = Server.MapPath(strImg);
                            if (System.IO.File.Exists(fileDelete))
                            {
                                System.IO.File.Delete(fileDelete);
                            }

                            string fileDelete2 = Server.MapPath(strImg.Replace("sc_small_", "sc_full_"));
                            if (System.IO.File.Exists(fileDelete2))
                            {
                                System.IO.File.Delete(fileDelete2);
                            }
                        }

                        ////delete category
                        bool rt = cateModels.Delete((int)cate_id);
                        if (rt)
                        {
                            list_catalog_view.Message = "Bạn đã xóa danh mục " + cate_id;
                        }
                        else
                        {
                            list_catalog_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_catalog_view.Message = "Không tìm thấy danh mục : " + cate_id;
                    }
                }
                else
                {
                    list_catalog_view.Message = " Bạn không có quyền thực thi hành động xóa cho danh mục này ";
                }
            }

            if (parent != 0)
            {
                cate = cateModels.GetbyID((int)parent);
                list_catalog_view.Category_name = cate.CategoryName;
            }

            list_catalog_view.Type      = type;
            list_catalog_view.Cate_type = CommonGlobal.GetCatalogTypeName(type);
            list_catalog_view.Parent    = (int)parent;
            list_catalog_view.Lang      = lang;
            list_catalog_view.Type_act  = type_act;
            ////tab
            var link_dashboard      = Url.Action("index", "dashboard", new { act = "list_catalog", ctrl = "adminCatalog", type_act = CommonGlobal.View, type = type, page = "1", parent = parent, lang = lang });
            var link_change_catalog = Url.Action("index", "dashboard", new { act = "change_catalog", ctrl = "adminCatalog", type_act = CommonGlobal.Add, type = type, parent = parent, lang = lang });

            sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + link_dashboard + "\"><span><span>Danh sách " + CommonGlobal.GetCatalogTypeName(type) + "</span></span></a></li>");
            sb.Append("<li><a href=\"" + link_change_catalog + "\"><span><span>Thêm mới</span></span></a></li>");
            list_catalog_view.Html_link_tab = sb.ToString();
            ////list language
            list_catalog_view.List_language = this.List_select_language(this.Lang);
            ////list category
            cateModels.List_catalog_parent(0, level, (int)parent, type, lang, ref list_select_catalog);
            list_catalog_view.List_parent = list_select_catalog;
            ////list page size and paging
            list_catalog_view.List_page_size = this.GetSizePagingPublic((int)page_size);
            list_catalog_view.Page           = (int)page;
            list_catalog_view.Page_size      = (int)page_size;
            ////list catalog
            list_catalog_view.Page_list_catalog = cateModels.GetAllCatalogByParentID((int)parent, type, lang, search, (int)page, (int)page_size, order_by, order_type, out total_record);
            list_catalog_view.Search            = search;
            list_catalog_view.Order_by          = order_by;
            list_catalog_view.Order_type        = order_type;
            list_catalog_view.Total_record      = total_record;
            ////acton and parent action
            list_catalog_view.Act               = act;
            list_catalog_view.Ctrl              = ctrl;
            list_catalog_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_catalog_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/list_catalog", list_catalog_view));
        }
        public ActionResult List_contact(int?id, string type, string act, string ctrl, string type_act, string lang, string search, int?page, int?page_size, string order_by, string order_type)
        {
            ContactModels contactModels     = new ContactModels();
            C_Contact     objectContact     = new C_Contact();
            StringBuilder sb                = new StringBuilder();
            var           list_contact_view = new Web.Areas.Admin.ViewModels.List_contact_view();
            int           total_record      = 0;

            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : string.Empty;
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_contact";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminGeneral";
            }

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            if (id != null && type_act != null && type_act == CommonGlobal.Delete)
            {
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type))
                {
                    objectContact = contactModels.GetByID((int)id);
                    if (objectContact != null)
                    {
                        ////delete contact
                        bool rt = contactModels.Delete((int)id);
                        if (rt)
                        {
                            list_contact_view.Message = "Bạn đã xóa " + id;
                        }
                        else
                        {
                            list_contact_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_contact_view.Message = "Không tìm thấy  : " + id;
                    }
                }
                else
                {
                    list_contact_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }

            if (string.IsNullOrEmpty(order_by) || string.IsNullOrEmpty(order_type))
            {
                order_by   = "ContactId";
                order_type = "desc";
            }

            list_contact_view.Type      = type;
            list_contact_view.Cate_type = "Ý kiến khách hàng";
            list_contact_view.Type_act  = type_act;
            ////tab
            sb.Append("<li class=\"active\"><a class=\"active\" href=\"#\"><span><span>Ý kiến khách hàng</span></span></a></li>");
            list_contact_view.Html_link_tab = sb.ToString();
            ////list page size and paging
            list_contact_view.List_page_size = this.GetSizePagingPublic((int)page_size);
            list_contact_view.Page           = (int)page;
            list_contact_view.Page_size      = (int)page_size;
            ////list catalog
            list_contact_view.Page_list_contact = contactModels.AdminGetAllContactClient(lang, search, (int)page, (int)page_size, order_by, order_type, out total_record);
            list_contact_view.Search            = search;
            list_contact_view.Order_by          = order_by;
            list_contact_view.Order_type        = order_type;
            list_contact_view.Total_record      = total_record;
            ////acton and parent action
            list_contact_view.Act               = act;
            list_contact_view.Ctrl              = ctrl;
            list_contact_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_contact_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/list_contact", list_contact_view));
        }
        public ActionResult List_emailtemplate(int?email_id, string type, string act, string ctrl, string type_act, string lang, int?page, int?page_size)
        {
            EmailTemplateModels emailModels       = new EmailTemplateModels();
            var           list_emailtemplate_view = new Web.Areas.Admin.ViewModels.List_emailtemplate_view();
            StringBuilder sb = new StringBuilder();

            int total_record = 0;

            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : CommonGlobal.RoleAdmin;
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_post";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminPost";
            }

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (string.IsNullOrEmpty(lang))
            {
                lang = LanguageModels.ActiveLanguage().LangCultureName;
            }

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            list_emailtemplate_view.Page      = (int)page;
            list_emailtemplate_view.Page_size = (int)page_size;

            ////tab
            sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_emailtemplate", ctrl = "adminEmail", type = type, page = "1" }) + "\"><span><span>Danh sách email template</span></a></li>");
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "change_emailtemplate", ctrl = "adminEmail", type_act = "add", lang = lang }) + "\"><span><span>Thêm mới</span></span></a></li>");
            list_emailtemplate_view.Html_link_tab = sb.ToString();

            if (email_id != null && email_id != 0 && type_act != null && type_act == CommonGlobal.Delete)
            {
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type))
                {
                    C_EmailTemplate objEmailTempate = new C_EmailTemplate();
                    objEmailTempate = emailModels.GetEmailTemplateById((int)email_id);
                    if (objEmailTempate != null)
                    {
                        ////delete post
                        bool rt = emailModels.Delete((int)email_id);
                        if (rt)
                        {
                            list_emailtemplate_view.Message = "Bạn đã xóa email template: " + objEmailTempate.name;
                        }
                        else
                        {
                            list_emailtemplate_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_emailtemplate_view.Message = "Không tìm thấy email template : " + objEmailTempate.name;
                    }
                }
                else
                {
                    list_emailtemplate_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }
            ////list post
            list_emailtemplate_view.List_page_size           = this.GetSizePagingPublic((int)page_size);
            list_emailtemplate_view.Page_list_email_template = emailModels.GetListEmailTemplateAll((int)page, (int)page_size, out total_record);
            list_emailtemplate_view.Total_record             = total_record;
            list_emailtemplate_view.Type_act = type_act;
            ////action
            list_emailtemplate_view.Act               = act;
            list_emailtemplate_view.Ctrl              = ctrl;
            list_emailtemplate_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_emailtemplate_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            ////end action

            return(this.PartialView("../control/list_emailtemplate", list_emailtemplate_view));
        }
        public ActionResult List_post(int?parent, int?cate_id, int?post_id, string type, string act, string ctrl, string type_act, string lang, string search, int?page, int?page_size, string order_by, string order_type)
        {
            CatalogModels         cataModel           = new CatalogModels();
            PostModels            postModel           = new PostModels();
            C_Post                post                = new C_Post();
            List <SelectListItem> list_select_catalog = new List <SelectListItem>();
            var           list_post_view              = new Web.Areas.Admin.ViewModels.List_post_view();
            StringBuilder sb = new StringBuilder();

            int total_record = 0;
            int level        = 0;

            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : CommonGlobal.CateNews;
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_post";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminPost";
            }

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (parent == null)
            {
                parent = Request.QueryString["parent"] != null?Convert.ToInt32(Request.QueryString["parent"].ToString()) : 0;
            }

            if (string.IsNullOrEmpty(lang))
            {
                lang = LanguageModels.ActiveLanguage().LangCultureName;
            }

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            list_post_view.Page      = (int)page;
            list_post_view.Page_size = (int)page_size;

            list_post_view.Cate_type = CommonGlobal.GetCatalogTypeName(type);

            ////list category
            cataModel.List_catalog_parent(0, level, (int)parent, type, lang, ref list_select_catalog);
            list_post_view.List_parent = list_select_catalog;

            ////list language
            list_post_view.List_language = this.List_select_language(lang);

            ////tab
            sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_post", ctrl = "adminPost", type = type, page = "1", parent = parent, lang = lang }) + "\"><span><span>Danh mục " + CommonGlobal.GetCatalogTypeName(type) + "</span></span></a></li>");
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "change_post", ctrl = "adminPost", type = type, type_act = "add", parent = parent, lang = lang }) + "\"><span><span>Thêm bài viết</span></span></a></li>");
            list_post_view.Html_link_tab = sb.ToString();

            if (post_id != null && post_id != 0 && type_act != null && type_act == CommonGlobal.Delete)
            {
                ////check permission delete
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type))
                {
                    post = postModel.GetbyID((int)post_id);
                    if (post != null)
                    {
                        ////delete old image
                        if (!string.IsNullOrEmpty(post.ImagePath))
                        {
                            string strImg = post.ImagePath;
                            strImg = "~" + strImg;
                            string fileDelete = Server.MapPath(strImg);
                            if (System.IO.File.Exists(fileDelete))
                            {
                                System.IO.File.Delete(fileDelete);
                            }

                            string fileDelete2 = Server.MapPath(strImg.Replace("sc_small_", "sc_full_"));
                            if (System.IO.File.Exists(fileDelete2))
                            {
                                System.IO.File.Delete(fileDelete2);
                            }
                        }
                        ////delete post
                        bool rt = postModel.Delete((int)post_id);
                        if (rt)
                        {
                            list_post_view.Message = "Bạn đã xóa bài viết: " + post_id;
                        }
                        else
                        {
                            list_post_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_post_view.Message = "Không tìm thấy bài viết : " + post_id;
                    }
                }
                else
                {
                    list_post_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }

            ////list post
            list_post_view.List_page_size = this.GetSizePagingPublic((int)page_size);
            list_post_view.Page_list_post = postModel.GetListPostAll(lang, type, (int)parent, search, (int)page, (int)page_size, order_by, order_type, out total_record);
            list_post_view.Total_record   = total_record;
            list_post_view.Search         = search;
            list_post_view.Type_act       = type_act;
            list_post_view.Type           = type;
            ////action
            list_post_view.Act               = act;
            list_post_view.Ctrl              = ctrl;
            list_post_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_post_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            ////end action

            return(this.PartialView("../control/list_post", list_post_view));
        }
示例#15
0
        public ActionResult Index()
        {
            if (!this.CheckAdminlogin())
            {
                return(this.RedirectToAction("login", "dashboard", new { area = "admin" }));
            }
            else
            {
                var return_url = Request.Url.ToString();
                var index_view = new Index_view();
                int count      = Request.QueryString.Count;
                if (count > 0)
                {
                    string act, ctrl, type_act, type;
                    act      = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : string.Empty;
                    ctrl     = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : string.Empty;
                    type_act = Request.QueryString["type_act"] != null ? Request.QueryString["type_act"].ToString() : CommonGlobal.View;
                    type     = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : string.Empty;
                    if (act != string.Empty && ctrl != string.Empty)
                    {
                        bool       isOk  = false;
                        UserModels sv    = new UserModels();
                        RoleModels roleM = new RoleModels();
                        C_Role     itR   = new C_Role();
                        C_User     itU   = new C_User();

                        itU = sv.GetUserbyUserName(Session["mem"].ToString());
                        itR = roleM.GetRoleItem(itU.Role);
                        ////check permission view/add/edit
                        if (ctrl == "adminProduct" && (act == "image_product" || act == "property_product" || act == "list_Rating"))
                        {
                            ////Chỉ được phép thay đổi thuộc tính của sản phẩm nếu có quyền edit product
                            if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, "change_product", ctrl, type_act, type) && itR.Role == "Admin")
                            {
                                isOk = true;
                            }
                            else
                            {
                                isOk = false;
                            }
                        }
                        else
                        {
                            if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type) && itR.Role == "Admin")
                            {
                                isOk = true;
                            }
                            else
                            {
                                isOk = false;
                            }
                        }

                        if (isOk == true)
                        {
                            index_view.Act      = act;
                            index_view.Ctrl     = ctrl;
                            index_view.Type_act = type_act;
                            index_view.Type     = type;
                        }
                        else
                        {
                            logger.Error(Session["mem"].ToString() + " đã truy cập khu vực không hợp lệ:act = " + act + ",ctrl = " + ctrl + ",type_act= " + type_act + ",type= " + type);
                            index_view.Act  = "access_denied";
                            index_view.Ctrl = "dashboard";
                        }
                    }
                    else
                    {
                        logger.Error(Session["mem"].ToString() + " đã truy cập khu vực không hợp lệ:act = " + act + ",ctrl = " + ctrl + ",type_act= " + type_act + ",type= " + type);
                        index_view.Act  = "access_denied";
                        index_view.Ctrl = "dashboard";
                    }
                }
                else
                {
                    index_view.Act      = "statistic";
                    index_view.Ctrl     = "dashboard";
                    index_view.Type_act = CommonGlobal.View;
                    index_view.Type     = string.Empty;
                }

                index_view.Return_url = return_url;

                return(this.PartialView("../page/index", index_view));
            }
        }
        public ActionResult List_album_images(FormCollection collection)
        {
            CatalogModels         cateModels          = new CatalogModels();
            GalleryModels         galleryModels       = new GalleryModels();
            C_Catalog             cate                = new C_Catalog();
            ImageAlbum            imgPro              = new ImageAlbum();
            StringBuilder         sb                  = new StringBuilder();
            List <SelectListItem> list_select_catalog = new List <SelectListItem>();
            var list_album_images_view                = new Web.Areas.Admin.ViewModels.List_album_images_view();

            this.TryUpdateModel(list_album_images_view);
            int  total_record = 0;
            int  level        = 0;
            bool rt           = true;
            bool is_valid     = true;

            list_album_images_view.Cate_type = CommonGlobal.GetCatalogTypeName(list_album_images_view.Type);
            ////tab
            sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_catalog", ctrl = "adminCatalog", type = list_album_images_view.Type, page = "1", parent = list_album_images_view.Parent }) + "\"><span><span>Danh sách " + CommonGlobal.GetCatalogTypeName(list_album_images_view.Type) + "</span></span></a></li>");
            list_album_images_view.Html_link_tab = sb.ToString();
            ////list page size and paging
            list_album_images_view.List_page_size = this.GetSizePagingPublic(list_album_images_view.Page_size);
            ////acton and parent action
            list_album_images_view.Act               = "list_album_images";
            list_album_images_view.Ctrl              = "adminLink";
            list_album_images_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_album_images_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
            ////delete image
            if (list_album_images_view.Id > 0 && list_album_images_view.Type_act == CommonGlobal.Delete)
            {
                ////check permission delete
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, list_album_images_view.Act, list_album_images_view.Ctrl, list_album_images_view.Type_act, list_album_images_view.Type))
                {
                    imgPro = galleryModels.GetImageById(list_album_images_view.Id);
                    if (imgPro != null)
                    {
                        ////delete old image
                        if (!string.IsNullOrEmpty(imgPro.Images))
                        {
                            string strImg = imgPro.Images;
                            strImg = "~" + strImg;
                            string fileDelete = Server.MapPath(strImg);
                            if (System.IO.File.Exists(fileDelete))
                            {
                                System.IO.File.Delete(fileDelete);
                            }

                            string fileDelete2 = Server.MapPath(strImg.Replace("sc_small_", "sc_full_"));
                            if (System.IO.File.Exists(fileDelete2))
                            {
                                System.IO.File.Delete(fileDelete2);
                            }
                        }
                        ////delete image product
                        rt = galleryModels.Delete_Images(list_album_images_view.Id);

                        if (rt)
                        {
                            list_album_images_view.Message = "Bạn đã xóa ảnh " + list_album_images_view.Id;
                        }
                        else
                        {
                            list_album_images_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_album_images_view.Message = "Không tìm thấy ảnh : " + list_album_images_view.Id;
                    }
                }
                else
                {
                    list_album_images_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }
            else
            {
                if (list_album_images_view.Type_act == CommonGlobal.Add)
                {
                    ////check permission add
                    if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, list_album_images_view.Act, list_album_images_view.Ctrl, list_album_images_view.Type_act, list_album_images_view.Type))
                    {
                        ////validation server
                        if (list_album_images_view.Album == 0)
                        {
                            is_valid = false;
                            list_album_images_view.Message = "Bạn cần lựa chọn album";
                        }

                        if (list_album_images_view.File_image == null)
                        {
                            is_valid = false;
                            list_album_images_view.Message = "Bạn cần chọn ảnh";
                        }

                        var max_length = 1024 * 1024 * 10; ////10MB
                        var length_all = 0;
                        foreach (HttpPostedFileBase fi in list_album_images_view.File_image)
                        {
                            if (fi != null)
                            {
                                length_all = length_all + fi.ContentLength;
                            }
                        }

                        if (length_all == 0)
                        {
                            is_valid = false;
                        }

                        if (length_all > max_length)
                        {
                            is_valid = false;
                            list_album_images_view.Message = "Bạn đã không thể đăng quá nhiều ảnh (Tổng dung lượng tối đa 10MB)";
                        }

                        if (is_valid)
                        {
                            ////upload multi images
                            foreach (HttpPostedFileBase fi in list_album_images_view.File_image)
                            {
                                if (fi != null && fi.ContentLength > 0 && CommonGlobal.IsImage(fi) == true)
                                {
                                    ////add new image
                                    var imgPathTemp = "images/photogallery/" +
                                                      DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/";
                                    var name_time = DateTime.Now.Day + DateTime.Now.Month + DateTime.Now.Year + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Ticks + string.Empty;

                                    imgPro = new ImageAlbum();
                                    string image_small = imgPathTemp + "sc_small_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(fi.FileName);
                                    string image_lager = imgPathTemp + "sc_full_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(fi.FileName);
                                    //////save images for multi file
                                    this.Savephoto(null, fi, imgPathTemp, image_small, image_lager);

                                    imgPro.Images     = "/" + image_small;
                                    imgPro.ImagesFull = "/" + image_lager;
                                    imgPro.CatalogID  = list_album_images_view.Album;
                                    list_album_images_view.ImagePath = "/" + image_small;
                                    rt = galleryModels.Add_Images(imgPro);

                                    if (rt)
                                    {
                                        list_album_images_view.Message = "Bạn đã thêm ảnh thành công!";
                                    }
                                    else
                                    {
                                        if (list_album_images_view.Message != string.Empty)
                                        {
                                            list_album_images_view.Message = "updload ảnh không thành công: " + CommonGlobal.CompleteNamefileImages(fi.FileName);
                                        }
                                        else
                                        {
                                            list_album_images_view.Message += "; " + CommonGlobal.CompleteNamefileImages(fi.FileName);
                                        }
                                    }

                                    list_album_images_view.File_image = null;
                                }
                            }
                        }
                    }
                    else
                    {
                        list_album_images_view.Message = " Bạn không có quyền thực thi thêm ảnh cho album ";
                    }
                }
                else
                {
                    list_album_images_view.Message = string.Empty;
                }
            }

            ////list language
            list_album_images_view.List_language = this.List_select_language(list_album_images_view.Lang);
            ////list category
            cateModels.List_catalog_parent(0, level, list_album_images_view.Parent, list_album_images_view.Type, list_album_images_view.Lang, ref list_select_catalog);
            list_album_images_view.List_parent = list_select_catalog;
            ////get list product
            list_album_images_view.Page_list_image = galleryModels.AdminGetAllImageGallery(list_album_images_view.Parent, list_album_images_view.Type, list_album_images_view.Lang, list_album_images_view.Page, list_album_images_view.Page_size, list_album_images_view.Order_by, list_album_images_view.Order_type, out total_record);
            list_album_images_view.Total_record    = total_record;
            list_album_images_view.Order_by        = list_album_images_view.Order_by;
            list_album_images_view.Order_type      = list_album_images_view.Order_type;


            return(this.PartialView("../control/list_album_images", list_album_images_view));
        }
        public ActionResult List_album_images(int?parent, int?id, string type, string act, string ctrl, string type_act, string lang, string search, int?page, int?page_size, string order_by, string order_type)
        {
            CatalogModels         cateModels          = new CatalogModels();
            GalleryModels         galleryModels       = new GalleryModels();
            C_Catalog             cate                = new C_Catalog();
            ImageAlbum            img                 = new ImageAlbum();
            StringBuilder         sb                  = new StringBuilder();
            List <SelectListItem> list_select_catalog = new List <SelectListItem>();
            var list_album_images_view                = new Web.Areas.Admin.ViewModels.List_album_images_view();
            int total_record = 0;
            int level        = 0;

            /////type is get type catalog
            /////ex   : LB - Lookbook
            /////     : GL - Gallery
            /////parent is array parent id
            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : CommonGlobal.CateLookBook;
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_album_images";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminLink";
            }

            if (page == null || page == 0)
            {
                page = Request.QueryString["page"] != null?Convert.ToInt32(Request.QueryString["page"].ToString()) : 1;
            }

            if (page_size == null)
            {
                page_size = int.Parse(Util.GetConfigValue("NumberPageSizeAdmin", "30"));
            }

            if (parent == null)
            {
                parent = Request.QueryString["parent"] != null?Convert.ToInt32(Request.QueryString["parent"].ToString()) : 0;
            }

            if (string.IsNullOrEmpty(lang))
            {
                lang = LanguageModels.ActiveLanguage().LangCultureName;
            }

            if (id != null && type_act != null && type_act == CommonGlobal.Delete)
            {
                ////check permission delete
                if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, act, ctrl, type_act, type))
                {
                    img = galleryModels.GetImageById((int)id);
                    if (img != null)
                    {
                        ////delete old image
                        if (!string.IsNullOrEmpty(img.Images))
                        {
                            string strImg = img.Images;
                            strImg = "~" + strImg;
                            string fileDelete = Server.MapPath(strImg);
                            if (System.IO.File.Exists(fileDelete))
                            {
                                System.IO.File.Delete(fileDelete);
                            }

                            string fileDelete2 = Server.MapPath(strImg.Replace("sc_small_", "sc_full_"));
                            if (System.IO.File.Exists(fileDelete2))
                            {
                                System.IO.File.Delete(fileDelete2);
                            }
                        }
                        ////delete imgage album
                        bool rt = galleryModels.Delete_Images((int)id);
                        if (rt)
                        {
                            list_album_images_view.Message = "Bạn đã xóa ảnh " + id;
                        }
                        else
                        {
                            list_album_images_view.Message = "Xóa không thành công";
                        }
                    }
                    else
                    {
                        list_album_images_view.Message = "Không tìm thấy ảnh : " + id;
                    }
                }
                else
                {
                    list_album_images_view.Message = " Bạn không có quyền thực thi hành động xóa.";
                }
            }

            if (string.IsNullOrEmpty(order_by) || string.IsNullOrEmpty(order_type))
            {
                order_by   = "ID";
                order_type = "asc";
            }

            if (parent != 0)
            {
                cate = cateModels.GetbyID((int)parent);
                list_album_images_view.Category_name = cate.CategoryName;
            }

            list_album_images_view.Type      = type;
            list_album_images_view.Cate_type = CommonGlobal.GetCatalogTypeName(type);
            list_album_images_view.Parent    = (int)parent;
            list_album_images_view.Lang      = lang;
            list_album_images_view.Type_act  = type_act;
            ////tab
            sb.Append("<li class=\"active\"><a class=\"active\" href=\"" + Url.Action("index", "dashboard", new { act = "list_catalog", ctrl = "adminCatalog", type = type, page = "1", parent = parent }) + "\"><span><span>Danh sách " + CommonGlobal.GetCatalogTypeName(type) + "</span></span></a></li>");
            list_album_images_view.Html_link_tab = sb.ToString();
            ////list language
            list_album_images_view.List_language = this.List_select_language(this.Lang);
            ////list category for filter
            cateModels.List_catalog_parent(0, level, (int)parent, type, lang, ref list_select_catalog);
            list_album_images_view.List_parent = list_select_catalog;
            ////list page size and paging
            list_album_images_view.List_page_size = this.GetSizePagingPublic((int)page_size);
            list_album_images_view.Page           = (int)page;
            list_album_images_view.Page_size      = (int)page_size;
            ////list product
            list_album_images_view.Page_list_image = galleryModels.AdminGetAllImageGallery((int)parent, type, lang, (int)page, (int)page_size, order_by, order_type, out total_record);
            list_album_images_view.Order_by        = order_by;
            list_album_images_view.Order_type      = order_type;
            list_album_images_view.Total_record    = total_record;
            ////acton and parent action
            list_album_images_view.Act               = act;
            list_album_images_view.Ctrl              = ctrl;
            list_album_images_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            list_album_images_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/list_album_images", list_album_images_view));
        }