Esempio n. 1
0
        //Главный пост
        public void OriginalClick(DateTime date, bool isOriginal)
        {
            var apod = MainApodObjectOperations.Get(date);

            if (apod != null)
            {
                Post_Id.Value    = apod.Id.ToString();
                day.InnerText    = apod.Date().ToString("dd");
                mounth.InnerText = apod.Date().ToString("MMM", CultureInfo.GetCultureInfo("ru-ru"));
                years.InnerText  = apod.Date().ToString("yyyy");
                title.InnerText  = apod.Title;
                Text.InnerText   = isOriginal ? apod.Explanation : apod.ExplanationRu;
                if (apod.MediaType != "image")
                {
                    video.Attributes["src"] = ApodHelper.CutVideoUrl(apod.Url);
                    Picture.Visible         = false;
                }
                else
                {
                    Picture.Attributes["src"] = apod.Url;
                    video.Visible             = false;
                }
                //увеличиваем количество просмотров
                apod.ViewsCount++;
                MainApodObjectOperations.Update(apod);

                AddPostComments(apod);
            }
        }
Esempio n. 2
0
        protected void SendClick(Object sender, EventArgs e)
        {
            var name  = comment_name.Value;
            var email = comment_email.Value;
            var text  = comment_message.Value;

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(text))
            {
                throw new Exception("Обязательные поля должныбыть заполнены");
                return;
            }

            SendEmailAthor(email, name);

            Comments comments = new Comments
            {
                Id            = Guid.NewGuid(),
                Post_Id       = Convert.ToInt32(Post_Id.Value),
                Author_Name   = name,
                Author_Email  = email,
                Text          = text,
                Rating        = 0,
                CreatedDate   = DateTime.Now,
                PublicateDate = DateTime.Now,
                IsPublic      = true,
                ParentId      = null
            };

            MainApodObjectOperations.Save(comments);

            var apod = MainApodObjectOperations.Get(comments.Post_Id);

            Page.Response.Redirect(Page.Request.Url.ToString(), true);
        }