コード例 #1
0
        public IHttpActionResult CreateBet([FromBody] CreateBetInsertReq model)
        {
            model.UserId = User.Identity.GetUserId();
            var result = _transactionServices.Create(model);

            // notify all connected clients
            //if(result.Data)
            //    Hub.Clients.All.newBet(model);
            return(ApiHelper.ReturnHttpAction(result, this));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Market,Coin,Unit,BuyingPrice,IsSold,SellPrice")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                transaction.Id        = Guid.NewGuid();
                transaction.UserId    = User.GetLoggedInUserId <Guid>();
                transaction.CreatedBy = transaction.UserId.ToString();
                transaction.CreateDt  = DateTime.Now;
                transaction.Status    = (short)Enums.EntityStatus.Active;

                await _transactionServices.Create(transaction);

                return(Redirect("/transactions"));
            }
            return(View(transaction));
        }
コード例 #3
0
        public async Task <ApiResultModel <Transaction> > Create([FromBody] Transaction transaction, Guid userId)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    transaction.Id        = Guid.NewGuid();
                    transaction.UserId    = userId;
                    transaction.CreatedBy = transaction.UserId.ToString();
                    transaction.CreateDt  = DateTime.Now;
                    transaction.Status    = (short)Enums.EntityStatus.Active;

                    await _transactionServices.Create(transaction);

                    return(new ApiResultModel <Transaction>()
                    {
                        Data = transaction,
                        Success = true,
                        Message = "Success",
                        Code = 200
                    });
                }

                return(new ApiResultModel <Transaction>()
                {
                    Data = transaction,
                    Success = false,
                    Message = JsonConvert.SerializeObject(ModelState.Values),
                    Code = 500
                });
            }
            catch (Exception ex)
            {
                return(new ApiResultModel <Transaction>()
                {
                    Data = new Transaction(),
                    Success = false,
                    Message = ex.Message,
                    Code = ex.HResult
                });
            }
        }
コード例 #4
0
 public IActionResult Post(TransactionVM transactionVM)
 {
     return(Ok(_transactionServices.Create(transactionVM)));
 }