예제 #1
0
        public IActionResult New([FromBody] PostingUpsertDto postingUpsertDto)
        {
            if (!_allowTrading)
            {
                return(BadRequest());
            }

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

            var posting = Posting.CreateNew(_dbContext, postingUpsertDto);

            return(Ok(posting));
        }
예제 #2
0
        public static PostingDto CreateNew(RioDbContext dbContext, PostingUpsertDto postingUpsertDto)
        {
            var posting = new Posting
            {
                PostingTypeID      = postingUpsertDto.PostingTypeID,
                PostingDescription = postingUpsertDto.PostingDescription,
                CreateAccountID    = postingUpsertDto.CreateAccountID,
                CreateUserID       = postingUpsertDto.CreateUserID,
                PostingDate        = DateTime.UtcNow,
                Price             = postingUpsertDto.Price,
                Quantity          = postingUpsertDto.Quantity,
                AvailableQuantity = postingUpsertDto.Quantity,
                PostingStatusID   = (int)PostingStatusEnum.Open
            };

            dbContext.Posting.Add(posting);
            dbContext.SaveChanges();
            dbContext.Entry(posting).Reload();

            return(GetByPostingID(dbContext, posting.PostingID));
        }