示例#1
0
        // GET: Admin/Post/Add
        public virtual ActionResult Add()
        {
            PostAdd Post = new PostAdd();

            Post.TagList      = _tagService.DropDownList();
            Post.CategoryList = _categoryService.DropDownList();
            return(View(Post));
        }
        public Post Add(PostAdd post, int userDisplayId)
        {
            var toAdd = new Post {
                Content     = post.Content,
                CreatedById = userDisplayId,
                CreatedOn   = DateTime.Now
            };

            context.Add(toAdd);
            context.SaveChanges();
            return(toAdd);
        }
示例#3
0
        public virtual ActionResult Add(PostAdd postAdd)
        {
            if (ModelState.IsValid)
            {
                var post = new Post();
                Mapper.Map(postAdd, post);
                post.CreatedAt = DateTime.UtcNow;
                RavenSession.Store(post);
                return(RedirectToAction(LinkTo.Post(post)));
            }

            return(View());
        }
示例#4
0
        // Post: Admin/Post/Add/id
        public virtual ActionResult Add(PostAdd model)
        {
            if (!ModelState.IsValid)
            {
                model.TagList      = _tagService.DropDownList(model.TagIds);
                model.CategoryList = _categoryService.DropDownList(model.CategoryIds);
                return(View(model));
            }
            HttpPostedFileBase file = Request.Files["user-avatar"];
            var path = Path.Combine(Server.MapPath("~/Content/upload/images/"), file.FileName);

            file.SaveAs(path);
            model.ImageTitle = file.FileName;
            _postService.Add(model);
            _uow.SaveAllChanges();
            return(RedirectToAction("Index"));
        }
示例#5
0
        public void Add(PostAdd post)
        {
            List <Tag> tags = new List <Tag>();

            foreach (var item in post.TagIds)
            {
                tags.Add(_tags.Find(item));
            }

            List <Category> categories = new List <Category>();

            foreach (var item in post.CategoryIds)
            {
                categories.Add(_categories.Find(item));
            }

            _posts.Add(new Post {
                CreatedDate   = DateTime.Now,
                Title         = post.Title,
                TitleEn       = post.TitleEn,
                TitleAr       = post.TitleAr,
                TitleRu       = post.TitleRu,
                Body          = post.Body,
                BodyEn        = post.BodyEn,
                BodyAr        = post.BodyAr,
                BodyRu        = post.BodyRu,
                Slug          = post.Slug,
                ImageTitle    = post.ImageTitle,
                Tags          = tags,
                Categories    = categories,
                Keyword       = post.Keyword,
                Description   = post.Description,
                DescriptionEn = post.DescriptionEn,
                DescriptionAr = post.DescriptionAr,
                DescriptionRu = post.DescriptionRu
            });
        }
示例#6
0
 public Post Add(PostAdd post) => access.Add(post, displayUserRepository.GetCurrentId());
示例#7
0
        //게시물추가 버튼
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            PostAdd PA = new PostAdd(this);

            PA.ShowDialog();
        }