예제 #1
0
    public ArticleDTO GetArticleById(string Id)
    {
        string str = "SELECT * FROM Article WHERE Id=@Id";
        IDictionary <string, string> SqlParameter = new Dictionary <string, string>();

        SqlParameter.Add("@Id", Id);

        DataTable dt = _coonDB.LoadTable_SQL(str, SqlParameter);

        ArticleDTO _ArticleDTO = dt.AsEnumerable()
                                 .Select(x => new ArticleDTO()
        {
            id               = x.Field <int>("id"),
            MovieType        = x.Field <string>("MovieType"),
            Name             = x.Field <string>("Name"),
            Content          = x.Field <string>("Content"),
            CreateTime       = x.Field <DateTime>("CreateTime"),
            Title            = x.Field <string>("Title"),
            LastReplyTime    = x.Field <DateTime>("LastReplyTime"),
            YoutubeUrl       = x.Field <string>("YoutubeUrl"),
            ImagePath        = x.Field <string>("ImagePath"),
            StrCreateTime    = x.Field <DateTime>("CreateTime").ToString("yyyy-MM-dd hh:mm:ss"),
            StrLastReplyTime = x.Field <DateTime>("LastReplyTime").ToString("yyyy-MM-dd hh:mm:ss")
        }).FirstOrDefault();

        return(_ArticleDTO);
    }
        public ActionResult Put(string name, [FromBody] ArticleDTO articleDTO)
        {
            var articles = _articleContext.Articles
                           .Include(m => m.Source)
                           .Include(n => n.Informations)
                           .OrderBy(x => x.Date)
                           .FirstOrDefault(m => m.Name.Replace(" ", "-").ToLower() == name.ToLower());

            if (articles == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            articles.Name = articleDTO.Name;
            articles.Source.SourceName = articleDTO.SourceInformation;
            articles.TextArticle       = articleDTO.TextArticle;
            articles.Date = articleDTO.Date;

            _articleContext.SaveChanges();

            return(NoContent());
        }
예제 #3
0
        public async Task UpdateAsync(ArticleDTO item)
        {
            var sourceArticle = await _articleRepository.FindByIdAsync(item.Id);

            try
            {
                if (sourceArticle != null)
                {
                    sourceArticle.Name              = item.Name;
                    sourceArticle.Description       = item.Description;
                    sourceArticle.CategoryId        = item.CategoryId;
                    sourceArticle.TagId             = item.TagId;
                    sourceArticle.PublishedDateTime = DateTime.Now;

                    await _articleRepository.UpdateAsync(sourceArticle);
                }
                else
                {
                    throw new NullReferenceException("Такой записи нет");
                }
            }
            catch (NullReferenceException)
            {
            }
        }
예제 #4
0
        public async Task <IActionResult> OnGetAsync(string url)
        {
            if (String.IsNullOrEmpty(url))
            {
                return(NotFound());
            }
            try
            {
                var articleId   = Convert.ToInt32(url.Remove(0, url.LastIndexOf("-") + 1));
                var articleItem = await _repositoryWrapper.Article.ArticleGetById(articleId);

                if (articleItem != null)
                {
                    articleItem.Content = HttpUtility.HtmlDecode(articleItem.Content);
                    ArticleDetail       = _maper.Map <ArticleDTO>(articleItem);

                    //Add Counter
                    await _repositoryWrapper.Article.ArticleAddCounter(articleItem.Id);
                }
                //GetBread Crumb
                BreadCrumb = await _repositoryWrapper.Article.ArticleBreadCrumbGetByCategoryId(Int32.Parse(articleItem.ArticleCategoryIds));

                var lstRelationArticle = _repositoryWrapper.Article.ArticleGetRelationArticle(articleId);
                var lstRelation        = _repositoryWrapper.Article.ArticleGetRelationArticle(articleId);
                ListArticleRelated = _maper.Map <List <ArticleDTO> >(lstRelation);
            }
            catch
            {
                return(NotFound());
            }

            return(Page());
        }
예제 #5
0
        /// <summary>
        /// Lấy ra điều khoản
        /// </summary>
        /// <returns></returns>
        public async Task <ArticleDTO> GetPaymentPolicy()
        {
            ArticleDTO output = new ArticleDTO();

            try
            {
                var jwt = _httpContextAccessor.HttpContext.User.FindFirst(p => p.Type == "access_token").Value;
                if (jwt != null)
                {
                    _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwt);
                    string apiUrl   = $"/api/v1/Payment/GetPaymentPolicy";
                    var    response = await _client.GetAsync(apiUrl);

                    if (response.IsSuccessStatusCode)
                    {
                        string responseStream = await response.Content.ReadAsStringAsync();

                        output = JsonConvert.DeserializeObject <ArticleDTO>(responseStream);
                    }
                }
            }
            catch (Exception e)
            {
            }

            return(output);
        }
예제 #6
0
 public UpdateArticleVM()
 {
     Categories    = new List <Category>();
     SubCategories = new List <SubCategory>();
     AppUsers      = new List <AppUser>();
     Article       = new ArticleDTO();
 }
예제 #7
0
        public async void PostArticleInvalidIdTest()
        {
            var controller = new ArticlesController(_context, _userManager);

            var article    = new ArticleDTO(_articleDTOs.First());
            int originalId = article.Id;

            article.Lead = "Change";

            //Id does not match article Id
            var result = await controller.PostArticle(article.Id + 1, article);

            Assert.IsType <BadRequestResult>(result);


            //Id matches but does not exist
            article.Id = 40;

            var result2 = await controller.PostArticle(article.Id, article);

            Assert.IsType <NotFoundResult>(result2);


            //GET TEST (Article unchanged)
            var result3 = await controller.GetArticle(originalId);

            var objectResult3 = Assert.IsType <OkObjectResult>(result3);
            var model         = Assert.IsAssignableFrom <ArticleDTO>(objectResult3.Value);

            Assert.Equal(_articleDTOs.First(), model);
        }
예제 #8
0
        public bool InsertArticle(ArticleDTO article)
        {
            var     article_db = ctx.Set <Article>();
            Article newArticle = new Article();

            try
            {
                if (article != null)
                {
                    newArticle.ArticleId    = article.ArticleId;
                    newArticle.ArticlePrice = article.Price;
                    newArticle.BuyerId      = article.BuyerId;
                    newArticle.IsSold       = article.IsSold;
                    newArticle.Name         = article.Name;
                    newArticle.SoldDate     = article.SoldDate;

                    ctx.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception($"Error - {ex.Message} - on inserting new article.");
            }
        }
예제 #9
0
        public void CreateArticle(ArticleDTO data)
        {
            DateTime currentTime = DateTime.Now;

            Article article = new Article()
            {
                Title           = data.Title,
                Text            = data.Text,
                ClientProfileId = data.AuthorId,
                TimeCreated     = currentTime,
                TimeEdited      = currentTime
            };

            foreach (var tag in data.Tags)
            {
                Tag dbtag = _uow.Tags.Get(tag.Id);
                if (dbtag == null)
                {
                    throw new ValidationException("There is no tag with such id.", "TagIds");
                }
                article.Tags.Add(dbtag);
            }

            _uow.Save();
        }
예제 #10
0
        public async Task <bool> EditArticleAsync(ArticleDTO article)
        {
            var path   = Properties.Resources.editArticlePath;
            var result = await _apiHelper.Put(path, article);

            return(result != null && result.ResponseType == ResponseType.Success);
        }
예제 #11
0
        public ArticleDTO GetArticleById(int articleId)
        {
            ArticleDTO articleDTO = new ArticleDTO();

            try
            {
                var article_db = ctx.Articles.Find(articleId);

                if (article_db != null)
                {
                    articleDTO.ArticleId = article_db.ArticleId;
                    articleDTO.BuyerId   = article_db.BuyerId;
                    articleDTO.IsSold    = article_db.IsSold;
                    articleDTO.Name      = article_db.Name;
                    articleDTO.Price     = article_db.ArticlePrice;
                    articleDTO.SoldDate  = article_db.SoldDate;
                }

                return(articleDTO);
            }
            catch (Exception ex)
            {
                throw new Exception($"Error - {ex.Message} - on getting article by id.");
            }
        }
예제 #12
0
        public void AddPictures(ArticleDTO articleDto, int article_id)
        {
            Article article = Database.Articles.Get(article_id);

            if (articleDto.ImagePaths == null)
            {
                articleDto.ImagePaths = new List <string>();
            }
            if (articleDto.ImagePaths.Count() != 0)
            {
                foreach (var image in articleDto.ImagePaths)
                {
                    Image last_image = Database.Images.GetAll().LastOrDefault();
                    int   image_id   = 1;
                    if (last_image != null)
                    {
                        image_id = last_image.ImageId;
                    }
                    Image img = new Image {
                        image_path = image, ImageId = image_id, Article = article
                    };
                    Database.Images.Create(img);
                    article.Images.Add(img);
                    article.Status_of_Article = Database.Status_of_Articles.Get(2);
                    Database.Articles.Update(article);
                    Database.Save();
                }
            }
        }
예제 #13
0
        public IHttpActionResult GetArticleById(string id)
        {
            int idInt    = 0;
            var response = new SingularArticleResponse();
            var result   = new ArticleDTO();

            try
            {
                // Validate request
                if (string.IsNullOrEmpty(id) || !int.TryParse(id, out idInt))
                {
                    return(Ok(ResponseHandler.Error(400)));
                }

                result = ContextBehaviours.GetArticleById(idInt);

                // Validate if find record
                if (result == null)
                {
                    return(Ok(ResponseHandler.Error(404)));
                }

                // Prepare  success response
                response.article = result;
                response.success = true;

                return(Ok(response));
            }
            catch (Exception ex)
            {
                return(Ok(ResponseHandler.Error(500)));
            }
        }
예제 #14
0
        public void AddTags(ArticleDTO articleDto)
        {
            List <string> tags           = new List <string>();
            Regex         regex_for_tags = new Regex(@"\B#\w{0,}");

            if (articleDto.text != "")
            {
                MatchCollection matches = regex_for_tags.Matches(articleDto.text);
                if (matches.Count != 0)
                {
                    foreach (var match in matches)
                    {
                        if (Database.Tags.GetAll().Where(x => x.name == match.ToString()).Count() == 0)
                        {
                            Tag tag = new Tag();
                            tag.name = match.ToString();
                            tag.Articles.Add(Database.Articles.Get(articleDto.ArticleId));
                            Database.Tags.Create(tag);
                            Database.Save();
                        }
                        else
                        {
                            Tag tag = Database.Tags.GetAll().Where(x => x.name == match.ToString()).First();
                            tag.Articles.Add(Database.Articles.Get(articleDto.ArticleId));
                            Database.Tags.Update(tag);
                            Database.Save();
                        }
                    }
                }
            }
        }
예제 #15
0
        public ArticleDTO GetArticleIdWithTitleForBlog(string title, int blog_id)
        {
            Article    article    = Database.Articles.GetAll().Where(x => (x.Blog.BlogId == blog_id && x.title == title)).FirstOrDefault();
            ArticleDTO articleDTO = new ArticleDTO
            {
                ArticleId  = article.Id,
                BlogId     = article.Blog.BlogId,
                Comments   = new List <CommentDTO>(),
                ImagePaths = new List <string>(),
                text       = article.text,
                title      = article.title
            };

            foreach (var image in article.Images)
            {
                articleDTO.ImagePaths.Add(image.image_path);
            }
            foreach (var comment in article.Comments)
            {
                CommentDTO commentDTO = new CommentDTO();
                commentDTO.article_id = comment.Article.Id;
                commentDTO.comment_id = comment.CommentId;
                commentDTO.datetime   = comment.date_of_comment;
                commentDTO.image_path = comment.ApplicationUser.ClientProfile.avatar_path;
                commentDTO.status_id  = comment.Status_of_Comment.Status_of_CommentId;
                commentDTO.text       = comment.text;
                commentDTO.user_name  = comment.ApplicationUser.Email;
                articleDTO.Comments.Add(commentDTO);
            }
            return(articleDTO);
        }
예제 #16
0
        public JsonResult NewArticlePost(ArticleDTO articleDTO)
        {
            var result = new Result <string>();

            if (String.IsNullOrEmpty(articleDTO.articleTitle))
            {
                result.IsSuccess     = false;
                result.ReturnMessage = "没有标题";
            }
            else if (String.IsNullOrEmpty(articleDTO.articleCopyright))
            {
                result.IsSuccess     = false;
                result.ReturnMessage = "没有来源";
            }
            else if (String.IsNullOrEmpty(articleDTO.articleContain))
            {
                result.IsSuccess     = false;
                result.ReturnMessage = "没有填写内容";
            }
            else
            {
                var data = LocalServiceLocator.GetService <IMyBlogService>().AddNewArticle(articleDTO);
                result.IsSuccess     = data.IsSuccess;
                result.ReturnMessage = data.ReturnMessage;
                result.ReturnValue   = data.ReturnValue.ToString();
            }
            return(new JsonResult()
            {
                Data = result
            });
        }
예제 #17
0
        public async Task <IActionResult> CreateArticle([FromBody] ArticleDTO article)
        {
            try
            {
                var result = await _articleService.CreateArticle(article, AuthInfo());

                if (result != null)
                {
                    _logger.LogInformation("User successfully posted an article");
                    return(CreatedAtAction(nameof(GetArticleById), new { id = result.Id }, result));
                }
                else
                {
                    throw new ArgumentNullException();
                }
            }
            catch (ArgumentNullException ex)
            {
                _logger.LogError(ex, ex.Message);
                return(BadRequest());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error occurred while user tried to post an article");
                throw;
            }
        }
예제 #18
0
        public void UpdateArticle(ArticleDTO articleDTO)
        {
            foreach (var teg in articleDTO.Tegs)
            {
                teg.Articles.Add(articleDTO);
            }

            var trackTegs = CreateNewTegsAndGetTrackingTegs(articleDTO);



            var repo         = unitOfWork.GetRepo <Article>();
            var existArticle = repo.GetById(articleDTO.Id);
            var article      = MapArticleDtoToArticle(articleDTO, existArticle);

            //Debug.WriteLine("newArticle - " + article.GetHashCode());
            //var existArticle = repo.GetById(article.Id);
            //Debug.WriteLine("existArticle - " + existArticle.GetHashCode());
            //var allExistTegs = unitOfWork.GetRepo<Teg>().GetAll();
            //existArticle.Title = article.Title;
            //var getTegs = allExistTegs.Intersect(article.Tegs.ToList(), new TegCompare());
            //article.Tegs = getTegs.ToList();
            //Debug.WriteLine("existArticle after change - " + existArticle.GetHashCode());
            //repo.Update(existArticle, "Tegs");

            article.Tegs = trackTegs.ToList();
            repo.Update(article);
            unitOfWork.Save();
        }
예제 #19
0
        public IHttpActionResult PutArticle(int id, ArticleDTO article)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                if (id != article.Id)
                {
                    return(BadRequest());
                }

                Repository.Update(article.ToModel());
                Article updated = Repository.GetByID(id);
                return(Ok(updated.DTO));
            }
            catch (NullReferenceException nre)
            {
                return(NotFound());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #20
0
        public void Create(ArticleDTO entity)
        {
            var article = mapper.Map <Article>(entity);

            UnitOfWork.ArticleRepository.Create(article);
            UnitOfWork.SaveChanges();
        }
예제 #21
0
        public void CreateArticle(ArticleDTO articleDto)
        {
            ValidatorBlogModels.ValidateArticleModel(articleDto);
            Mapper.Initialize(config =>
            {
                config.CreateMap <ArticleDTO, Article>().ForMember(t => t.Tags, i => i.Ignore()).ForMember(c => c.Comments, i => i.Ignore());
            });
            var articl = Mapper.Map <Article>(articleDto);
            var tags   = DataBase.Tags.GetAll().ToList();

            foreach (var tag in articleDto.Tags)
            {
                var newTag = new Tagg()
                {
                    Text = tag
                };
                if (tags.Find(x => x.Text.Equals(newTag.Text)) != null)
                {
                    articl.Tags.Add(tags.First(x => x.Text.Equals(newTag.Text)));
                }
                else
                {
                    DataBase.Tags.Create(newTag);
                    articl.Tags.Add(newTag);
                }
            }

            DataBase.Articles.Create(articl);
            DataBase.Save();
        }
예제 #22
0
        public void CreateModel(ArticleDTO articleDTO)
        {
            ArticleModel articleModel = new ArticleModel();
            var          model        = articleModel.CreateModel(articleDTO);

            Assert.Equal(articleDTO.Content, model.Content);
        }
예제 #23
0
        internal static Article ToEntity(ArticleDTO objet, bool creation)
        {
            Article rtn = new Article();

            if (null != objet)
            {
                rtn.LicenceId     = objet.LicenceId;
                rtn.DateArticle   = objet.DateArticle;
                rtn.Texte         = objet.Texte;
                rtn.Titre         = objet.Titre;
                rtn.TypeArticleId = objet.TypeArticleId;

                if (creation)
                {
                    rtn.IsDeleted        = false;
                    rtn.DateCreation     = DateTime.Now;
                    rtn.DateModification = DateTime.Now;
                }
                else
                {
                    rtn.Id               = objet.Id;
                    rtn.IsDeleted        = objet.IsDeleted;
                    rtn.DateCreation     = objet.DateCreation;
                    rtn.DateModification = objet.DateModification;
                }
            }
            return(rtn);
        }
예제 #24
0
        public ICollection <ArticleDTO> GetArticlesForBlog(int BlogId)
        {
            var articles = Database.Articles.GetAll().Where(x => x.Blog.BlogId == BlogId);
            ICollection <ArticleDTO> articlesDTO = new List <ArticleDTO>();

            foreach (var a in articles)
            {
                ArticleDTO art_DTO = new ArticleDTO();
                art_DTO.ArticleId           = a.Id;
                art_DTO.title               = a.title;
                art_DTO.text                = a.text;
                art_DTO.Status_of_ArticleId = a.Status_of_Article.Status_of_ArticleId;
                art_DTO.Comments            = new List <CommentDTO>();
                foreach (var comment in a.Comments)
                {
                    CommentDTO commentDTO = new CommentDTO();
                    commentDTO.article_id = comment.Article.Id;
                    commentDTO.comment_id = comment.CommentId;
                    commentDTO.datetime   = comment.date_of_comment;
                    commentDTO.image_path = comment.ApplicationUser.ClientProfile.avatar_path;
                    commentDTO.status_id  = comment.Status_of_Comment.Status_of_CommentId;
                    commentDTO.text       = comment.text;
                    commentDTO.user_name  = comment.ApplicationUser.Email;
                    art_DTO.Comments.Add(commentDTO);
                }
                art_DTO.ImagePaths = new List <string>();
                foreach (var img in a.Images)
                {
                    art_DTO.ImagePaths.Add(img.image_path);
                }
                articlesDTO.Add(art_DTO);
            }
            return(articlesDTO);
        }
예제 #25
0
        public async Task <IEnumerable <ArticleDTO> > LoadArticlesAsync()
        {
            HttpResponseMessage response = await _client.GetAsync("api/Articles/");

            if (response.IsSuccessStatusCode)
            {
                var test = await response.Content.ReadAsStringAsync();

                var test2 = JsonConvert.DeserializeObject <dynamic>(test);

                var test3 = new List <ArticleDTO> {
                };
                foreach (var item in test2)
                {
                    var article = new ArticleDTO
                    {
                        Id      = item.Value <int>("id"),
                        Title   = item.Value <string>("title"),
                        Author  = item.Value <string>("author"),
                        UserId  = item.Value <string>("userid"),
                        Date    = item.Value <DateTime>("date"),
                        Summary = item.Value <string>("summary"),
                        Content = item.Value <string>("content"),
                        Leading = item.Value <Boolean>("leading")
                    };
                    test3.Add(article);
                }
                return(test3);
            }

            throw new NetworkException("Service returned response: " + response.StatusCode);
        }
예제 #26
0
        public Result <int> AddNewArticle(ArticleDTO dto)
        {
            var result = DbUtilityFactory.GetDbUtility().Add(new ArticleEntity()
            {
                categoryID       = dto.categoryID,
                articleAbstract  = dto.articleAbstract,
                articleContain   = dto.articleContain,
                articleCopyright = dto.articleCopyright,
                articleDate      = DateTime.Now,
                articleTitle     = dto.articleTitle,
                userID           = dto.userID
            });

            if (result > 0)
            {
                return(new Result <int>()
                {
                    ReturnMessage = "添加成功",
                    IsSuccess = true,
                    ReturnValue = result
                });
            }
            else
            {
                return(new Result <int>()
                {
                    ReturnMessage = "添加失败",
                    IsSuccess = false,
                    ReturnValue = result
                });
            }
        }
예제 #27
0
        public Result <int> EditArticle(ArticleDTO dto)
        {
            var result = DbUtilityFactory.GetDbUtility().Update(new ArticleEntity()
            {
                articleID        = dto.articleID,
                articleAbstract  = dto.articleAbstract,
                articleContain   = dto.articleContain,
                articleCopyright = dto.articleCopyright,
                articleDate      = DateTime.Now,
                articleTitle     = dto.articleTitle,
                categoryID       = dto.categoryID,
                userID           = dto.userID
            }, a => a.articleID == dto.articleID);

            if (result == 1)
            {
                return(new Result <int>()
                {
                    ReturnMessage = "修改成功",
                    IsSuccess = true,
                    ReturnValue = result
                });
            }
            else
            {
                return(new Result <int>()
                {
                    ReturnMessage = "修改失败",
                    IsSuccess = false,
                    ReturnValue = result
                });
            }
        }
        public async Task <IActionResult> AddArticle(ArticleDTO art)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Fill all fields"));
            }
            Article article = new Article()
            {
                Title       = art.Title,
                PublishDate = art.PublishDate,
                Description = art.Description,
            };

            if (await _repos.HasEntity(article))
            {
                return(BadRequest("This article already exists"));
            }

            if (await _repos.Create(article))
            {
                return(Ok("Added new article"));
            }

            return(BadRequest("Failed to add article"));
        }
예제 #29
0
        public async Task <ArticleDTO> GetHomeHighLightsArticlePartialView()
        {
            var output = new ArticleDTO();

            try
            {
                var cacheKey    = "Article_GetHomeHighLightsArticlePartialView";
                var redisEncode = await _distributedCache.GetStringAsync(cacheKey);

                if (redisEncode != null)
                {
                    output = JsonConvert.DeserializeObject <ArticleDTO>(redisEncode);
                }
                else
                {
                    var result = await _repoWrapper.Article.GetHomeHighLightsArticlePartialView();

                    output = _mapper.Map <ArticleDTO>(result);
                    await _distributedCache.SetStringAsync(cacheKey, JsonConvert.SerializeObject(output), Utils.Util.RedisOptions());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"GetHomeHighLightsArticlePartialView: ");
            }
            return(output);
        }
예제 #30
0
        public async Task <ArticleDTO> GetArticleDetail(int ArticleId, int ArticleTypeId)
        {
            var output = new ArticleDTO();

            try
            {
                var cacheKey    = $"Article_GetArticleDetail_{ArticleId}_{ArticleTypeId}";
                var redisEncode = await _distributedCache.GetStringAsync(cacheKey);

                if (redisEncode != null)
                {
                    output = JsonConvert.DeserializeObject <ArticleDTO>(redisEncode);
                }
                else
                {
                    var result = _repoWrapper.Article.GetArticleDetail(ArticleId, ArticleTypeId);
                    output         = _mapper.Map <ArticleDTO>(result);
                    output.Content = HttpUtility.HtmlDecode(output.Content);
                    await _distributedCache.SetStringAsync(cacheKey, JsonConvert.SerializeObject(output), Utils.Util.RedisOptions());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"GetArticleDetail: " + ex.ToString());
            }
            return(output);
        }
예제 #31
0
        public void CreateArticle(ArticleDTO articleDTO)
        {
            if (string.IsNullOrEmpty(articleDTO.Title)) throw new ArgumentException("标题不能为空");
            if (string.IsNullOrEmpty(articleDTO.Category)) throw new ArgumentException("类别不能为空");
            if (articleDTO.Id != Guid.Empty) throw new ArgumentException("新文章不应该包含ID信息");

            articleRepository.Add(articleDTO.MapTo());
            repositoryContext.Commit();
        }
예제 #32
0
 private int getAndSubmitArticle()
 {
     ArticleDTO article = new ArticleDTO();
     article.Title = tbTitle.Text;
     article.GenreID = int.Parse(ddlGenre.SelectedValue);
     article.FullText = tbArticle.Text;
     article.SummaryText = tbSummary.Text;
     article.AuthorID = 5;
     article.PostTime = DateTime.Now;
     int zip = 0;
     if (int.TryParse(tbZip.Text, out zip))
         article.ZipCode = zip;
     return DataTransaction.submitArticle(article);
 }
예제 #33
0
 public void Article_CreateArticle()
 {
     string title = "title";
     string content = "<h1>content</h1>";
     string contentBio = "this is content";
     string category = "C#";
     List<string> tags = new List<string> { "dotnet", "python" };
     ArticleDTO dto = new ArticleDTO()
     {
         Title = title,
         Content = content,
         ContentBio = contentBio,
         Category = category,
         Tags = tags
     };
     articleApplicationImpl.CreateArticle(dto);
 }