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)); } }
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)); }
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 })); }
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")); }
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))); }
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)); }
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("")); }
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")); }
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)); }
//[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)); }
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()); }
public ApiResult Add([FromBody] ArticleDTO articleDTO) { UserDTO user = Auth.GetLoginUser(); articleDTO.AuthorAccount = user.Account; int id = _articleService.Add(articleDTO); return(ApiResult.Success(id)); }
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 })); }
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)); }
public async Task <IActionResult> Add(ArticleForAddUpdateDto dto) { var result = await _articleService.Add(dto); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
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.")); }
public IActionResult Add(Article article) { try { return(Ok(_articleService.Add(article))); } catch (Exception) { return(BadRequest("Makale eklenemedi")); } }
public IActionResult Add([FromBody] Article article) { article.Author = "lsp"; _articleService.Add(article); return(Content("ok:添加成功!")); //var f = ModelState.IsValid; //return Content("ok:添加成功!"); }
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)); }
public ServiceResult <ArticleEntity> Create(ArticleEntity article) { var validResult = ValidArticleType(article); if (validResult.HasViolation) { return(validResult); } return(_articleService.Add(article)); }
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)); }
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()); } }
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!" })); }
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); }
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)); }