コード例 #1
0
        public async Task <IActionResult> CreateTransaction([FromBody] Models.TransactionRequest transactionRequest)
        {
            try
            {
                Entities.Transaction transaction = _mapper.Map <Entities.Transaction>(transactionRequest);
                transaction.SenderId = int.Parse(User.Claims.First(c => c.Type == "premisesID").Value);
                var createByID = int.Parse(User.Claims.First(c => c.Type == "userID").Value);
                transaction.CreateById = createByID;
                await _transactionBL.CreateSellFoodTransactionAsync(transaction);

                var transactionHash = await _foodDataBL.AddCertification(transactionRequest.FoodId, transactionRequest.CertificationNumber, createByID);

                await _foodBL.AddDetail(transactionRequest.FoodId, EFoodDetailType.VERIFY, transactionHash, transaction.CreateById);

                var reponseModel = new Models.TransactionReponse.CreateTransactionReponse()
                {
                    TransactionId = transaction.TransactionId
                };
                return(Ok(new { message = MessageConstant.INSERT_SUCCESS }));
            }
            catch (InvalidDataException ex)
            {
                return(BadRequest(new { message = ex.Message, error = ex.StackTrace }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = MessageConstant.UNHANDLE_ERROR, error = ex.StackTrace }));
            }
        }
コード例 #2
0
ファイル: ProviderController.cs プロジェクト: war-man/TSF
        public async Task <IActionResult> UpdateTransaction(int transactionId, [FromBody] Models.TransactionUpdateRequest trans)
        {
            try
            {
                Entities.Transaction transaction = new Entities.Transaction()
                {
                    TransactionId   = transactionId,
                    StatusId        = trans.StatusId,
                    RejectReason    = trans.RejectedReason,
                    ReceiverComment = trans.ProviderComment,
                };
                await _transactionBL.UpdateTransaction(transaction, transactionId);

                return(Ok(new { message = MessageConstant.UPDATE_SUCCESS }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = MessageConstant.UNHANDLE_ERROR, error = ex.StackTrace }));
            }
        }