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)); }
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)); }