Example #1
0
        public IActionResult Create([FromBody] PostModel postModel)
        {
            var createdPostModel = _postServices.CreatePost(postModel);

            return(CreatedAtRoute("GetById",
                                  new { id = createdPostModel.Id, languageCode = createdPostModel.LanguageCode },
                                  createdPostModel));
        }
Example #2
0
        public IActionResult CreatePost([FromBody] PostOptions postOptions)
        {
            var result = _postservices.CreatePost(postOptions);

            if (!result.Success)
            {
                return(StatusCode((int)result.ErrorCode,
                                  result.ErrorText));
            }

            return(Json(result.Data));
        }
Example #3
0
 public IActionResult Create(MyProfileViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         postServices.CreatePost(viewModel);
         return(RedirectToAction("MyProfile", "Account"));
     }
     else
     {
         var result = this.View("Error", this.ModelState);
         result.StatusCode = (int)HttpStatusCode.BadRequest;
         return(result);
     }
 }
        public IActionResult Post([FromBody] PostCreateDataModel model)
        {
            var user = currentUserService.CurrentUser;

            postServices.CreatePost(new DAL.Entities.BBS.PostContent()
            {
                Title        = model.Title,
                Contents     = model.Content,
                Images       = model.Images,
                CreateBy     = user,
                ReplySubject = postServices.GetPostById(model.ReplySubject),
                ReplyTo      = usersService.GetById(model.ReplyTo)
            });
            return(new JsonResult(ActionStatusMessage.Success));
        }
Example #5
0
        public async Task <IActionResult> Create([FromBody] CreatePostDto model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var checkName = await _postServices.IsNameExist(model.Title, model.ProductListTypeID);

                    if (checkName == true)
                    {
                        return(BadRequest("Sorry!, This name already exists on our database. Choose another name"));
                    }

                    var createPost = await _postServices.CreatePost(model);

                    return(StatusCode(201, $"{model.Title} created Successfully."));
                }
                return(BadRequest("Sorry! Your task cannot be completed"));
            }
            catch (Exception ex)
            {
                return(BadRequest($"{ex.Message}, Error! Your task failed, Please try again"));
            }
        }