Пример #1
0
        public ActionResult Create(string ct)
        {
            TempData["CroppedImage"] = null;
            using (var objContext = new db_KISDEntities())
            {
                //decrypt content type id(ct)
                ct = !string.IsNullOrEmpty(Convert.ToString(ct)) ? EncryptDecrypt.Decrypt(ct) : "0";
                int ContentTypeID = !string.IsNullOrEmpty(ct) ? Convert.ToInt32(ct) : 0;

                #region Check Tab is Accessible or Not
                int TabType = 0;
                if (ContentTypeID == 1 || ContentTypeID == 2 || ContentTypeID == 3)
                {
                    TabType = Convert.ToInt32(ModuleTypeAlias.Home);
                }
                if (ContentTypeID == 4)
                {
                    TabType = Convert.ToInt32(ModuleTypeAlias.AboutKISD);
                }
                if (ContentTypeID == 5)
                {
                    TabType = Convert.ToInt32(ModuleTypeAlias.School);
                }
                if (ContentTypeID == 6)
                {
                    TabType = Convert.ToInt32(ModuleTypeAlias.NewToKISD);
                }
                if (ContentTypeID == 7 || ContentTypeID == 35)
                {
                    TabType = Convert.ToInt32(ModuleTypeAlias.ParentStudents);
                }
                if (ContentTypeID == 8)
                {
                    TabType = Convert.ToInt32(ModuleTypeAlias.Departments);
                }
                if (ContentTypeID == 9 || ContentTypeID == 34)
                {
                    TabType = Convert.ToInt32(ModuleTypeAlias.SchoolBoard);
                }
                if (ContentTypeID == 10)
                {
                    TabType = Convert.ToInt32(ModuleTypeAlias.Employment);
                }
                if (ContentTypeID == 11)
                {
                    TabType = Convert.ToInt32(ModuleTypeAlias.GoogleAnalytic);
                }

                var userId       = objContext.Users.Where(x => x.UserNameTxt == User.Identity.Name).Select(x => x.UserID).FirstOrDefault();
                var RoleID       = objContext.UserRoles.Where(x => x.UserID == userId).Select(x => x.RoleID).FirstOrDefault();
                var HasTabAccess = GetAccessibleTabAccess(TabType, Convert.ToInt32(userId));
                if (!(HasTabAccess || RoleID == Convert.ToInt32(UserType.SuperAdmin) ||
                      RoleID == Convert.ToInt32(UserType.Admin))) //if tab not accessible then redirect to home
                {
                    if (TabType == Convert.ToInt32(ModuleTypeAlias.Departments) && RoleID == Convert.ToInt32(UserType.DepartmentUser))
                    {
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                #endregion

                ViewBag.ContentTypeID = ContentTypeID;
                ViewBag.Date          = DateTime.Now.ToShortDateString();
                var chkcontenttype = objContext.ContentTypes.Any(x => x.ContentTypeID == ContentTypeID && ContentTypeID <= 43);
                if (!chkcontenttype)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                var objContentModel = new ContentModel();
                objContentModel.ContentTypeID = ContentTypeID;
                var objContent       = objContext.Contents.Where(x => x.ContentTypeID == ContentTypeID).FirstOrDefault();
                var contenttypetitle = objContext.ContentTypes.Find(ContentTypeID).ContentTypeNameTxt;

                objContentModel.RightSections = GetAllRightSections();

                if (objContent != null)
                {
                    objContentModel.ContentID = objContent.ContentID;

                    objContentModel.AbstractTxt            = objContent.AbstractTxt;
                    objContentModel.ContentTypeID          = objContent.ContentTypeID;
                    objContentModel.IsExternalLinkInd      = objContent.IsExternalLinkInd;
                    objContentModel.ExternalLinkTxt        = objContent.ExternalLinkTxt;
                    objContentModel.ExternalLinkTargetInd  = objContent.ExternalLinkTargetInd;
                    objContentModel.PageTitleTxt           = objContent.PageTitleTxt;
                    objContentModel.MenuTitleTxt           = objContent.MenuTitleTxt;
                    objContentModel.PageURLTxt             = objContent.PageURLTxt;
                    objContentModel.BannerImageID          = objContent.BannerImageID;
                    objContentModel.AltBannerImageTxt      = objContent.AltBannerImageTxt;
                    objContentModel.BannerImageAbstractTxt = objContent.BannerImageAbstractTxt;
                    objContentModel.DescriptionTxt         = objContent.DescriptionTxt;
                    objContentModel.ContentCreateDate      = objContent.ContentCreateDate;
                    objContentModel.CreateDate             = objContent.CreateDate;
                    objContentModel.StatusInd               = objContent.StatusInd;
                    objContentModel.PageMetaTitleTxt        = objContent.PageMetaTitleTxt;
                    objContentModel.RightSectionTitleTxt    = objContent.RightSectionTitleTxt;
                    objContentModel.RightSectionAbstractTxt = objContent.RightSectionAbstractTxt;
                    objContentModel.PageMetaDescriptionTxt  = objContent.PageMetaDescriptionTxt;
                    objContentModel.IsGooglePlusSharingInd  = objContent.IsGooglePlusSharingInd.HasValue ? objContent.IsGooglePlusSharingInd.Value : false;
                    objContentModel.IsFacebookSharingInd    = objContent.IsFacebookSharingInd.HasValue ? objContent.IsFacebookSharingInd.Value : false;
                    objContentModel.IsTwitterSharingInd     = objContent.IsTwitterSharingInd.HasValue ? objContent.IsTwitterSharingInd.Value : false;
                    objContentModel.strCreateDate           = objContent.CreateDate.HasValue ? objContent.CreateDate.Value.ToShortDateString() : DateTime.Now.ToShortDateString();
                    ViewBag.IsActiveInd = GetStatusData(objContentModel.StatusInd == true ? "1" : "0");
                    ViewBag.Date        = objContent.ContentCreateDate != null?objContent.ContentCreateDate.Value.ToShortDateString() : DateTime.Now.ToShortDateString();

                    objContentModel.ContentTypeTitle = "Edit " + contenttypetitle + (IsContent(ContentTypeID) ? " Content" : " Page Content");
                    ViewBag.Submit = "Update";
                }
                else
                {
                    ViewBag.Submit = "Save";
                    string[] ToEmailarr = new string[] { "0" };
                    objContentModel.ContentTypeID = ContentTypeID;
                    ViewBag.Date = DateTime.Now.ToShortDateString();
                    objContentModel.IsGooglePlusSharingInd = false;
                    objContentModel.IsFacebookSharingInd   = false;
                    objContentModel.IsTwitterSharingInd    = false;
                    objContentModel.ContentTypeTitle       = "Add " + contenttypetitle + (IsContent(ContentTypeID) ? " Content" : " Page Content");
                    ViewBag.IsActiveInd = GetStatusData(string.Empty);
                }

                var InnerImagesTitle = Models.Common.GetInnerImages();
                ViewBag.InnerImagesTitle = InnerImagesTitle;//get all the inner image titles

                ViewBag.Title = (ContentModel.GetContentTypeName(Convert.ToInt32(ContentTypeID))) + (ContentTypeID == Convert.ToInt32(ContentTypeAlias.Fly) ? " Page" : "");
                return(View(objContentModel));
            }
        }