public IResult AddArticle(string ArticleTitle, byte[] ImageBytes, string ArticleContent, List <int> CategoryIds, int writerID) { List <Category> categories = new List <Category>(); foreach (var categoryId in CategoryIds) { var category = DbInstance.GetCategoryById(categoryId); bool sonuc = category.Developers.Any(a => a.ObjectID == writerID); if (!sonuc) { return(new ErrorResult(Messages.WriterNotInCategory)); } categories.Add(category); } Article article = new Article { ArticleTitle = ArticleTitle, ArticleContent = ArticleContent, ArticlePictureURL = ImageBytes, Developer = DbInstance.GetDeveloperById(writerID), WriterId = writerID, Categories = categories, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, }; try { DbInstance.AddArticle(article); DbInstance.SaveChanges(); return(new SuccessResult(Messages.SucceededArticle)); } catch (Exception) { return(new ErrorResult(Messages.UnsucceededArticle)); } }