示例#1
0
        public ActionResult Add([FromBody] ArticleDto model)
        {
            if (model == null)
            {
                return(BadRequest("Makale boş olamaz."));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest("Lütfen girmiş olduğunuz değerleri kontrol ediniz."));
            }
            try
            {
                var res = articleService.Add(model);

                logger.LogInformation("Makale eklendi.");

                return(Ok(res));
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
                return(StatusCode(500, ex.Message));
            }
        }
示例#2
0
        public async Task <IActionResult> Add(ArticleAddViewModel articleAddViewModel)
        {
            if (ModelState.IsValid)
            {
                var articleDto  = Mapper.Map <ArticleAddDto>(articleAddViewModel);
                var imageResult = await ImageHelper.Upload(articleAddViewModel.Title, articleAddViewModel.Thumbnail, PictureType.Post);

                articleDto.Thumbnail = imageResult.Data.FullName;
                var result = await _articleService.Add(articleDto, LoggedInUser.UserName, LoggedInUser.Id);

                if (result.resultStatus == ResultStatus.Succes)
                {
                    _toastNotification.AddSuccessToastMessage(result.Message);
                    return(RedirectToAction("Index", "Article"));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            var categories = await _categoryService.GetAllByNonDeletedAndActive();

            articleAddViewModel.Categories = categories.Data.Categories;
            return(View(articleAddViewModel));
        }
示例#3
0
        public virtual ActionResult Add(AddUpdateArticleModel model)
        {
            _articleService.Add(new Article
            {
                Body          = model.Body.ToSafeHtml(),
                Category      = _categoryService.Find(model.CategoryId),
                CommentStatus = model.CommentStatus,
                CreatedDate   = DateAndTime.GetDateTime(),
                Description   = model.Description,
                Keyword       = model.Keywords,
                LikeCount     = 0,
                Status        = model.ArticleStatus,
                Title         = model.Title,
                User          = _userService.Find(User.Identity.Name),
                VisitedCount  = 0,
            });

            _uow.SaveChanges();

            return(PartialView(MVC.Admin.Shared.Views._Alert, new Alert
            {
                Message = "مطلب جدید با موفقیت در سیستم ثبت شد",
                Mode = AlertMode.Success
            }));
        }
示例#4
0
        public IActionResult Add(ArticleEntity entity)
        {
            entity.AccountId = Convert.ToInt32(User.FindFirst(x => x.Type == ClaimTypes.Sid).Value);
            int result = _service.Add(entity);

            return(Redirect("/admin/article/list"));
        }
示例#5
0
        public async Task <IActionResult> Add([FromBody] ArticleAddDto articleDto)
        {
            articleDto.EventDate = articleDto.EventDate.Date;

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

            articleDto.EventDate = articleDto.EventDate.ToLocalTime();

            var photoURL = articleDto.PhotoURL;

            var article = _mapper.Map <Article>(articleDto);

            article.PublishingDate = DateTime.Now;

            var articleResult = await _articleService.Add(article, photoURL);

            if (articleResult == null)
            {
                return(BadRequest());
            }

            return(Ok(_mapper.Map <ArticleResultDto>(articleResult)));
        }
示例#6
0
        public IHttpActionResult Post(ArticleBindingModel articleBindingModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Article article = Mapper.Map <ArticleBindingModel, Article>(articleBindingModel);

            var userId = User.Identity.GetUserId();

            if (userId == null)
            {
                return(BadRequest());
            }

            var user = _userService.GetById(userId);

            article.User = user;

            _articleService.Add(article);
            var articleViewModel = Mapper.Map <Article, ArticleViewModel>(article);

            return(Ok(articleViewModel));
        }
示例#7
0
        public IActionResult AddArticle(ArticleVM model)
        {
            //TODO: attach tags to the article
            var message = "Sikeresen hozzáadva!";

            ModelState.Remove("Article.Slug");
            ModelState.Remove("Article.Magazine.Category.Name");
            ModelState.Remove("Article.Magazine.Title");
            ModelState.Remove("Article.Author.Name");
            if (!ModelState.IsValid)
            {
                message = "Hiba a validáció során. A mezők kitöltése kötelező!";
                return(PartialView("Layout/_ErrorHandling", message));
            }

            var result = _articleService.Add(model.Article, User.Identity.Name);

            if (!result.IsOk())
            {
                message = String.Format("Hiba a hozzáadás során: {0} - {1}", result.Status, result.Message);
                return(PartialView("Layout/_ErrorHandling", message));
            }

            return(Json(""));
        }
示例#8
0
        public IActionResult Add(ArticleViewModel article)
        {
            try
            {
                _articleService.Add(article.Article);
                var lastArticle = _articleService.GetLastArticle();
                foreach (var item in article.Section)
                {
                    var newSec = new Section
                    {
                        ArticleId   = lastArticle.ArticleId,
                        Title       = item.Title,
                        Description = item.Description
                    };
                    _sectionService.Add(newSec);
                }

                foreach (var item in article.Author)
                {
                    var newAuthor = new Author
                    {
                        ArticleId = lastArticle.ArticleId,
                        FirstName = item.FirstName,
                        LastName  = item.LastName
                    };
                    _authorService.Add(newAuthor);
                }
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }

            return(Ok());
        }
        public async Task <IActionResult> Add(Article article)
        {
            var title   = article.Title;
            var content = article.Content;

            var    file = article.NewPicture;
            string str;

            if (file != null)
            {
                using (var ms = new MemoryStream())
                {
                    file.CopyTo(ms);
                    var fileBytes = ms.ToArray();
                    str = Convert.ToBase64String(fileBytes);
                }
            }
            else
            {
                str = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8Xw8AAoMBgDTD2qgAAAAASUVORK5CYII=";
            }
            await Task.Run(() => articleService.Add(title, content, str));

            return(RedirectToAction("Index"));
        }
示例#10
0
        public async Task <ActionResult> Add(WikiMenuModel input)
        {
            input.CreateTime = DateTime.Now;
            input.CreateUser = this.CurrentSession.UserName;
            WikiMenuModel entity = await _articleService.Add(input);

            return(this.AddSuccessData(entity));
        }
示例#11
0
        //[System.Web.Mvc.ValidateInput(false)]
        public async Task <ActionResult> Add(ArticleModel input)
        {
            input.CreateTime = DateTime.Now;
            input.CreateUser = this.CurrentSession.UserName;
            string id = await _articleService.Add(input);

            return(this.SuccessData(id));
        }
示例#12
0
        public IApiResult Add([FromBody] d_Article_Add d_Article_Add)
        {
            //model对象不应该传递给客户端,无论对客户端的传递和接收一律只能通过dto对象
            var m_Article = d_Article_Add.MapTo <m_Article>();

            articleService.Add(m_Article);
            return(ApiResult.Succeed());
        }
示例#13
0
        public ApiResult Add([FromBody] ArticleDTO articleDTO)
        {
            UserDTO user = Auth.GetLoginUser();

            articleDTO.AuthorAccount = user.Account;
            int id = _articleService.Add(articleDTO);

            return(ApiResult.Success(id));
        }
示例#14
0
 public ActionResult AddNewArticle(Article article)
 {
     article.CompanyId    = OperatingUser.CompanyId;
     article.CreatedById  = OperatingUser.Id;
     article.ModifiedById = OperatingUser.Id;
     article.Tag          = string.Join(",", article.Tags);
     article = _articleService.Add(article);
     return(RedirectToAction("Edit", "Article", new { id = article.Id }));
 }
示例#15
0
        public void When使用Add方法新增()
        {
            mork.Add(Arg.Any <Article>()).Returns(true);
            var articleInfo = ScenarioContext.Current.Get <ArticleInfo>("articleInfo");

            //act
            bool act = _articleService.Add(articleInfo);

            ScenarioContext.Current.Set(act, "act");
        }
        public IActionResult Add(ArticleDto articleDto)
        {
            var response = _articleService.Add(articleDto);

            if (!response.IsSuccess)
            {
                return(BadRequest(response));
            }
            return(Ok(response));
        }
示例#17
0
        public async Task <IActionResult> Add(ArticleForAddUpdateDto dto)
        {
            var result = await _articleService.Add(dto);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
示例#18
0
        public ActionResult Add(Article article)
        {
            var myResult = _articleService.Add(article);

            if (myResult.Success)
            {
                return(Ok(myResult));
            }
            return(BadRequest(myResult.Message));
        }
        public IActionResult AddQuestion(Article article)
        {
            var result = _articleService.Add(article);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        public IActionResult Add(Article article)
        {
            bool isAdded = _articleService.Add(article);

            if (isAdded)
            {
                return(Ok("Ürün başarıyla eklendi."));
            }
            return(BadRequest("İşlem başarısız."));
        }
示例#21
0
 public IActionResult Add(Article article)
 {
     try
     {
         return(Ok(_articleService.Add(article)));
     }
     catch (Exception)
     {
         return(BadRequest("Makale eklenemedi"));
     }
 }
示例#22
0
        public IActionResult Add([FromBody] Article article)
        {
            article.Author = "lsp";

            _articleService.Add(article);
            return(Content("ok:添加成功!"));

            //var f = ModelState.IsValid;

            //return Content("ok:添加成功!");
        }
示例#23
0
        public ActionResult Create([Bind(Include = "ID,Name,Description,Price,Total_in_shelf,Total_in_vault,StoreId")] AddEditArticleVM article)
        {
            if (ModelState.IsValid)
            {
                var articleToAdd = ArticleMappers.MapToArticle(article);
                _articleService.Add(articleToAdd);
                return(RedirectToAction("Index"));
            }

            return(View(article));
        }
示例#24
0
        public ServiceResult <ArticleEntity> Create(ArticleEntity article)
        {
            var validResult = ValidArticleType(article);

            if (validResult.HasViolation)
            {
                return(validResult);
            }

            return(_articleService.Add(article));
        }
示例#25
0
        public ServiceResult <ArticleEntity> Create(ArticleEntity article)
        {
            var validResult = ValidArticleType(article);

            if (validResult.HasViolation)
            {
                return(validResult);
            }

            article.ArticleContent = _htmlSanitizer.Sanitize(article.ArticleContent);
            return(_articleService.Add(article));
        }
示例#26
0
        public ActionResult Add(string moudleId, string menuId, string btnId, ArticleDto dto)
        {
            var user     = provider.GetAuthorizeUser();
            var tag      = tagService.Get();
            var category = categoryService.GetCategoryById(1);

            dto.Category = category;
            dto.Author   = user;
            dto.Tags.Add(tag);
            articleService.Add(dto);
            return(RedirectToAction("Index", "Blog"));
        }
 public IActionResult Post(Article article)
 {
     try
     {
         _articleService.Add(article);
         return(new StatusCodeResult(201));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
示例#28
0
        public async Task <IActionResult> CreateArticle([FromBody] ArticleRequest request)
        {
            request.Article.Author = await _userService.Get(HttpContext.GetUserName());

            var response = await _articleService.Add(request);

            if (response == null)
            {
                return(BadRequest(new { message = "Can't add this article!" }));
            }

            return(Ok(new { message = "Article was saved successfuly!" }));
        }
示例#29
0
        public void Add()
        {
            var article = new Article
            {
                Title       = "Test by ajeet",
                Description = "Test data",
                CategoryId  = 1,
                Tag         = "title",
                CompanyId   = 1
            };
            var record = _articleService.Add(article);

            Assert.IsNotNull(record);
        }
示例#30
0
        public async Task <ActionResult> Search(Search search)
        {
            search.ScrapeUrl = _scraperService.ConstructScrapeUrl(search.Query);
            var articles = (await _scraperService.FindMatchingArticles(search)).ToList();

            search = await _searchService.Add(search);

            foreach (var article in articles)
            {
                await _articleService.Add(article);
            }
            search.Articles = articles;
            return(View(search));
        }