Пример #1
0
        private SelectList GetAllReceivingEmails()
        {
            var _SettingContexts = new Contexts.SettingContexts();
            var _EmailsContexts  = new Contexts.EmailsContexts();
            var receivingEmail   = _SettingContexts.GetSettings().Select(x => x.ReceivingEmail).FirstOrDefault().ToArray();
            var list             = new List <ReceivingEmailModel>();

            foreach (var item in receivingEmail)
            {
                list = _EmailsContexts.GetEmails().Select(m => new ReceivingEmailModel()
                {
                    ReceivingEmailID  = m.EmailID,
                    ReceivingEmailTxt = m.EmailTxt
                }).ToList();
            }

            var objSocialMedia = new ReceivingEmailModel();

            objSocialMedia.ReceivingEmailTxt = "-- Select Receiving Emails --";
            objSocialMedia.ReceivingEmailID  = 0;
            list.Insert(0, objSocialMedia);
            var objselectlist = new SelectList(list, "ReceivingEmailID", "ReceivingEmailTxt");

            return(objselectlist);
        }
Пример #2
0
        public ActionResult Setting(int?SettingID, int ContentType)
        {
            var _settingContext = new Contexts.SettingContexts();
            var _emailContext   = new Contexts.EmailsContexts();
            var _settingModel   = new SettingModel();
            var settingType     = string.Empty;

            settingType    = (ContentType == 3 ? "Basic" : (ContentType == 5 ? "Theme" : (ContentType == 4 ? "Email" : "")));
            ViewBag.Title  = (SettingID.HasValue ? "Edit " : "Add ") + settingType + " Setting Details ";
            ViewBag.Submit = SettingID.HasValue && SettingID.Value > 0 ? "Update" : "Save";
            bool   isSearchEnabled = true; bool isCommentEnabled = true; bool isSocialSharingEnabled = true;
            string fontSize = string.Empty;

            ViewBag.FromEmails = new SelectList(_emailContext.GetEmails().Where(x => x.EmailTypeID == 1).ToList().OrderBy(x => x.EmailTxt), "EmailID", "EmailTxt");
            ViewBag.ToEmails   = new SelectList(_emailContext.GetEmails().Where(x => x.EmailTypeID == 2).ToList().OrderBy(x => x.EmailTxt), "EmailID", "EmailTxt");
            _settingModel.ReceivingEmailList = GetAllReceivingEmails();
            if (SettingID.HasValue && SettingID.Value > 0)
            {
                if (_settingModel != null)
                {
                    _settingModel.ReceivingEmailList = GetAllToEmails();//Receiving Emails
                    var array_ReceivingEmailID = new string[] { };
                    var receiveEmailTxt        = _settingContext.GetSettings().Select(x => x.ReceivingEmail).FirstOrDefault();
                    _settingModel.SendingEmail = _settingContext.GetSettings().Select(x => x.SendingEmail).FirstOrDefault();
                    if (receiveEmailTxt.Contains(','))
                    {
                        array_ReceivingEmailID = _settingContext.GetSettings().Select(x => x.ReceivingEmail).FirstOrDefault().Split(',');
                    }
                    else
                    {
                        array_ReceivingEmailID = _settingContext.GetSettings().Select(x => x.ReceivingEmail).ToArray();
                    }

                    var selecetdReceivingEmailsarray = Array.ConvertAll <int, string>(_emailContext.GetEmails().Where(x => array_ReceivingEmailID.Contains(x.EmailID.ToString())).Select(x => x.EmailID).ToArray(),
                                                                                      delegate(int i)
                    {
                        return((string)i.ToString());
                    });

                    isSearchEnabled        = _settingContext.GetSettings().Select(x => x.IsSearchEnabled).FirstOrDefault();
                    isCommentEnabled       = _settingContext.GetSettings().Select(x => x.IsCommentEnabled).FirstOrDefault();
                    isSocialSharingEnabled = _settingContext.GetSettings().Select(x => x.IsSocialSharingEnabled).FirstOrDefault();
                    _settingModel.SelectedReceivingEmail = selecetdReceivingEmailsarray;
                }
            }
            else
            {
                ViewBag.Submit = "Save";
                string[] ToEmailarr = new string[] { "0" };
                _settingModel.SelectedToEmails = ToEmailarr;
            }
            #region Fill Values
            var settinglist = _settingContext.GetSettings().FirstOrDefault();
            _settingModel.PagingColor                 = !string.IsNullOrEmpty(settinglist.PagingColor) ? settinglist.PagingColor : "";
            _settingModel.PagingActiveColor           = !string.IsNullOrEmpty(settinglist.PagingActiveColor) ? settinglist.PagingActiveColor : "";
            _settingModel.PagingHoverColor            = !string.IsNullOrEmpty(settinglist.PagingHoverColor) ? settinglist.PagingHoverColor : "";
            _settingModel.NevigationBarColor          = !string.IsNullOrEmpty(settinglist.NevigationBarColor) ? settinglist.NevigationBarColor : "";
            _settingModel.NevigationBarTextFontSize   = !string.IsNullOrEmpty(settinglist.NevigationBarTextFontSize) ? settinglist.NevigationBarTextFontSize : "";
            _settingModel.NevigationBarFontColor      = !string.IsNullOrEmpty(settinglist.NevigationBarFontColor) ? settinglist.NevigationBarFontColor : "";
            _settingModel.NevigationBarHoverColor     = !string.IsNullOrEmpty(settinglist.NevigationBarHoverColor) ? settinglist.NevigationBarHoverColor : "";
            _settingModel.FooterColor                 = !string.IsNullOrEmpty(settinglist.FooterColor) ? settinglist.FooterColor : "";
            _settingModel.SidebarTitleBackgroundColor = !string.IsNullOrEmpty(settinglist.SidebarTitleBackgroundColor) ? settinglist.SidebarTitleBackgroundColor : "";
            _settingModel.SidebarTitleFontcolor       = !string.IsNullOrEmpty(settinglist.SidebarTitleFontcolor) ? settinglist.SidebarTitleFontcolor : "";
            _settingModel.SidebarTitleFontSize        = !string.IsNullOrEmpty(settinglist.SidebarTitleFontSize) ? settinglist.SidebarTitleFontSize : "";
            _settingModel.PostTitleFontColor          = !string.IsNullOrEmpty(settinglist.PostTitleFontColor) ? settinglist.PostTitleFontColor : "";
            _settingModel.PostTitleFontSize           = !string.IsNullOrEmpty(settinglist.PostTitleFontSize) ? settinglist.PostTitleFontSize : "";
            _settingModel.ButtonColor                 = !string.IsNullOrEmpty(settinglist.ButtonColor) ? settinglist.ButtonColor : "";
            _settingModel.ContentType                 = ContentType;
            _settingModel.IsSearchEnabled             = isSearchEnabled;
            _settingModel.IsCommentEnabled            = isCommentEnabled;
            _settingModel.IsSocialSharingEnabled      = isSocialSharingEnabled;
            ViewBag.NevigationbarFontFamily           = GetAllFont(_settingModel != null ? _settingContext.GetSettings().Select(x => x.NevigationBarFontFamily).FirstOrDefault() : string.Empty);// new SelectList(font,"FontID","Name");
            ViewBag.SidebarTitleFontFamily            = GetAllFont(_settingModel != null ? _settingContext.GetSettings().Select(x => x.SidebarTitleFontFamily).FirstOrDefault() : string.Empty);
            ViewBag.PostTitleFontFamily               = GetAllFont(_settingModel != null ? _settingContext.GetSettings().Select(x => x.PostTitleFontFamily).FirstOrDefault() : string.Empty);
            ViewBag.IsSearchEnabled        = Models.Common.GetStatusListBoolean(isSearchEnabled ? "true" : "false");
            ViewBag.IsCommentEnabled       = Models.Common.GetStatusListBoolean(isCommentEnabled ? "true" : "false");
            ViewBag.IsSocialSharingEnabled = Models.Common.GetStatusListBoolean(isSocialSharingEnabled ? "true" : "false");
            ViewBag.fontSize             = Models.Common.GetFontList("12");
            _settingModel.PostPerPage    = _settingContext.GetSettings().Select(x => x.PostPerPage).FirstOrDefault();
            _settingModel.CommentPerPost = _settingContext.GetSettings().Select(x => x.CommentPerPost).FirstOrDefault();
            #endregion

            return(View(_settingModel));
        }
Пример #3
0
        public JsonResult Delete(int?EmailId, int?emailtype)
        {
            Session["Edit/Delete"] = "Delete";
            var EmailContext       = new Contexts.EmailsContexts();
            var SettingContexts    = new Contexts.SettingContexts();
            var objSettingContexts = SettingContexts.GetSettings().FirstOrDefault();
            var rvd   = new RouteValueDictionary();
            int?Page  = 1;
            var count = 1;

            count = EmailContext.GetEmails().Count();
            var page     = Request.QueryString["page"] ?? Models.Common._currentPage.ToString();
            var pagesize = Request.QueryString["pagesize"] ?? Models.Common._pageSize.ToString();

            if (Convert.ToInt32(page) > 1)
            {
                Page = count > ((Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize)) ? Convert.ToInt32(page) : (Convert.ToInt32(page)) - 1;
            }
            rvd.Add("page", Page);
            rvd.Add("Column", Request.QueryString["Column"] != null ? Request.QueryString["Column"].ToString() : "FirstName");
            rvd.Add("Direction", Request.QueryString["Direction"] != null ? Request.QueryString["Direction"].ToString() : "Ascending");
            rvd.Add("pagesize", pagesize);
            rvd.Add("emailtype", emailtype);
            if (EmailId.HasValue)
            {
                try
                {
                    if (EmailContext != null)
                    {
                        var email_coun = 0;
                        if (emailtype == 1)// Sending email
                        {
                            email_coun = SettingContexts.GetSettings().Where(x => x.SendingEmail == Convert.ToString(EmailId)).Count();
                        }
                        else if (emailtype == 2)// Receiving email
                        {
                            if (!string.IsNullOrEmpty(objSettingContexts.ReceivingEmail))
                            {
                                if (objSettingContexts.ReceivingEmail.Contains(","))
                                {
                                    var recevingemail_array = objSettingContexts.ReceivingEmail.Split(',');
                                    email_coun = recevingemail_array.Contains(Convert.ToString(EmailId)) ? 1 : 0;
                                }
                                else
                                {
                                    var recevingemail_array = new string[] { objSettingContexts.ReceivingEmail };
                                    email_coun = recevingemail_array.Contains(Convert.ToString(EmailId)) ? 1 : 0;
                                }
                            }
                        }
                        if (email_coun == 0)
                        {
                            EmailContext.DeleteEmails(EmailId);
                            TempData["AlertMessage"] = "Email details deleted successfully.";
                        }
                        else
                        {
                            TempData["Message"] = "Email is in use, can not be deleted.";
                            return(Json(Url.Action("BlogEmailListing", "Emails", rvd)));
                        }
                    }
                }
                catch
                {
                    TempData["AlertMessage"] = "Some error occured while deleting the Email, Please try again later.";
                }
            }
            return(Json(Url.Action("BlogEmailListing", "Emails", rvd)));
        }