public IActionResult AddPost([FromBody] GetPost v)
        {
            PostOrder veg = new PostOrder();

            //veg.Id = 2;
            veg.item_name    = v.itemName;
            veg.quantity     = v.quantity;
            veg.unit_price   = v.unitPrice;
            veg.expired_date = v.expireDate;
            veg.harvest_date = v.harvestDate;
            veg.item_image   = v.item_image;
            veg.description  = v.description;
            veg.is_active    = 1;
            veg.user_id      = v.farmerId;
            Boolean id = _service.AddPost(veg);

            if (id)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Пример #2
0
        public async Task <GetPostResponse> Get(GetPost request)
        {
            if (request.Id <= 0)
            {
                throw new ArgumentNullException(nameof(request.Id));
            }

            var user = SessionAs <AuthUserSession>();
            var post = await Db.SingleByIdAsync <Post>(request.Id);

            OrganizationMember groupMember = null;

            if (post != null)
            {
                AssertCanViewOrganization(Db, post.OrganizationId, user, out _, out groupMember);
            }

            if (post == null || post.Deleted != null && !user.IsOrganizationModerator(groupMember))
            {
                throw HttpError.NotFound("Post does not exist");
            }

            var postComments = request.Include == "comments"
                ? await Db.SelectAsync <PostComment>(x => x.PostId == request.Id && x.Deleted == null)
                : TypeConstants <PostComment> .EmptyList;

            return(new GetPostResponse
            {
                Cache = Stopwatch.GetTimestamp(),
                Post = post,
                Comments = postComments,
            });
        }
Пример #3
0
        public async Task <IActionResult> GetPost(int groupId, int postId)
        {
            var command = new GetPost {
                GroupId = groupId, PostId = postId
            };

            return(Ok(await _mediator.Send(command)));
        }
Пример #4
0
        private void TrySavePost()
        {
            var post    = new GetPost();
            var results = validator.Validate(post);

            if (results.IsValid)
            {
                _postRepository.SavePost(post);
            }
            else
            {
                DisplayErrors(results);
            }
        }
Пример #5
0
 public object Any(GetPost request) => new GetPostResponse
 {
     Id          = request.Id,
     Title       = $"Title {request.Id}",
     Description = $"Post Description {request.Id}",
 };
Пример #6
0
 private async Task <List <PostDetail> > GetData()
 {
     return(await GetPost.Get_All_Post());
 }
Пример #7
0
 public void Open(GetPost method, JsString url, bool async, JsString user, JsString password)
 {
 }
Пример #8
0
 public void Open(GetPost method, JsString url, bool async, JsString user)
 {
 }
Пример #9
0
 public void Open(GetPost method, JsString url)
 {
 }