Esempio n. 1
0
        public Task SendMail(string subject, string message)
        {
            using (var _Context = new ApplicationDbContext())
            {
                var objEntityEmailInfo = new RepositoryPattern <EmailInfo>(_Context);
                var Info = objEntityEmailInfo.SearchFor(x => x.IsActive == "1").ToList().FirstOrDefault();

                SmtpClient  smtpClient  = new SmtpClient(Info.SMTP);
                MailMessage mailMessage = new MailMessage();


                smtpClient.Host = Info.HostName;
                mailMessage.To.Add(new MailAddress(Info.ToEmail));
                mailMessage.Subject              = subject;
                mailMessage.SubjectEncoding      = Encoding.UTF8;
                mailMessage.IsBodyHtml           = true;
                mailMessage.From                 = new MailAddress(Info.FromEmail, subject);
                mailMessage.BodyEncoding         = Encoding.UTF8;
                mailMessage.Body                 = message;
                smtpClient.UseDefaultCredentials = false;
                NetworkCredential networkCredential = (NetworkCredential)(smtpClient.Credentials = new NetworkCredential(Info.FromEmail, Info.Pass));
                smtpClient.Credentials = networkCredential;

                return(smtpClient.SendMailAsync(mailMessage));
            }
        }
Esempio n. 2
0
 // GET: ControlPanel/Blog
 public ActionResult CreatePost()
 {
     using (var _Context = new ApplicationDbContext())
     {
         var objEntityCategory = new RepositoryPattern <Category>(_Context);
         ViewBag.ListCategory = objEntityCategory.SearchFor(x => x.IsActive == "1").ToList();
         return(View());
     }
 }
Esempio n. 3
0
        public ActionResult EditPost(int id)
        {
            DatabaseOperation _dop = new DatabaseOperation();

            using (var _Context = new ApplicationDbContext())
            {
                var objEntityCategory = new RepositoryPattern <Category>(_Context);
                ViewBag.ListCategory = objEntityCategory.SearchFor(x => x.IsActive == "1").ToList();

                var Result = new List <vm_AllPost>();
                Result = _dop.GetAllPost("all").Where(x => x.PostID == id).ToList();

                return(View(Result.FirstOrDefault()));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// بررسی کاربر که اینکه مدیای جاری رو قبلا لایک کرده یا نه
        /// </summary>
        /// <returns></returns>
        ///
        public bool CheckLastActionPost(int PostID, int ActivityType)
        {
            string CurrIP = objNetworkOperation.ClientIPaddress();
            string CurrHN = objNetworkOperation.ClientHostName();
            string CurrDT = objNetworkOperation.ClientDeviceType();
            string CurrBr = objNetworkOperation.ClientBrowser();

            using (var _Context = new ApplicationDbContext())
            {
                var _objEntityAction = new RepositoryPattern <Activity>(_Context);
                var PostLikeState    = _objEntityAction.SearchFor(x =>
                                                                  x.Posts.ID == PostID &&
                                                                  x.IP_Address == CurrIP &&
                                                                  x.HostName == CurrHN &&
                                                                  x.Device == CurrDT &&
                                                                  x.Browser == CurrBr &&
                                                                  x.ActivityType.ID == ActivityType)
                                       .ToList()
                                       .LastOrDefault();

                if (PostLikeState != null)
                {
                    return(true);
                }
            }
            //Search In RAM List
            var _LikeView = C_LikeViewList.GetAllLikeView();

            if (!(_LikeView == null || _LikeView.Count() == 0))
            {
                PostAction CurrItem = _LikeView.FirstOrDefault(x =>
                                                               x.PostID == PostID &&
                                                               x.Browser == CurrBr &&
                                                               x.Device == CurrDT &&
                                                               x.HostName == CurrHN &&
                                                               x.IP_Address == CurrIP &&
                                                               x.ActionTypeID == ActivityType);
                if (CurrItem != null)
                {
                    //در صورتي كه توي ليست (رم) باشد
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 5
0
        public ActionResult ContentDetail(int PostID)
        {
            try
            {
                ViewBag.BeforeLiked = _dop.CheckLastActionPost(PostID, Convert.ToInt32(EnumMethod.ActionType.Like));
            }
            catch (Exception)
            {
                ViewBag.BeforeLiked = false;
            }
            ViewAndLikeLog(PostID, Convert.ToInt32(EnumMethod.ActionType.View));
            var Result = new List <vm_AllPost>();

            Result = _dop.GetAllPost("all").Where(x => x.PostID == PostID && x.IsActive == "1").ToList();
            using (var _Context = new ApplicationDbContext())
            {
                var _objEntityPostComment = new RepositoryPattern <PostComment>(_Context);
                var _PostComment          = _objEntityPostComment.SearchFor(x => x.PostID == PostID && x.Is_Active == "1").ToList();
                ViewBag.listPostComment = _PostComment;
            }

            ViewBag.SeoData = HtmlPageSEO.GetHeadPageData(Result.FirstOrDefault().Title, new robot[] { robot.index, robot.follow },
                                                          new HtmlMetaTag[]
            {
                new HtmlMetaTag()
                {
                    name = MetaName.author, content = "محمد بن سعيد"
                },
                new HtmlMetaTag()
                {
                    name = MetaName.keywords, content = Result.FirstOrDefault().Labels
                },
                new HtmlMetaTag()
                {
                    name = MetaName.description, content = Result.FirstOrDefault().SeoMetaDescription
                }
            },
                                                          null);

            return(View(Result));
        }