コード例 #1
0
        private ApiResponse Update(int id, UpdateTransactionViewModel model)
        {
            var apiResp = new ApiResponse
            {
                Type = ResponseType.Fail
            };

            _transactionBusiness.OwnerId = GetUserId().Value;

            var transaction = new Dto.Transaction
            {
                Id             = id,
                TypeId         = model.TypeId.Value,
                Amount         = model.Amount.Value,
                Description    = model.Description,
                AttachmentName = model.AttachmentName,
                IsDebt         = _transactionBusiness.IsDebtTransaction(model.TypeId.Value),
                Date           = model.Date,
                ModifiedAt     = DateTime.UtcNow
            };

            var resp = _transactionBusiness.Edit(transaction);

            if (resp.Type != ResponseType.Success)
            {
                apiResp.ErrorCode = resp.ErrorCode;
                return(apiResp);
            }

            apiResp.Type = ResponseType.Success;
            return(apiResp);
        }
コード例 #2
0
        public string ConfirmEditTransaction(TransactionsViewModel vm)
        {
            TransactionDomainModel acc_dm = new TransactionDomainModel();
            var    mapper_accs            = new MapperConfiguration(cfg => cfg.CreateMap <TransactionsViewModel, TransactionDomainModel>()).CreateMapper();
            var    transaction            = mapper_accs.Map <TransactionsViewModel, TransactionDomainModel>(vm);
            string response = ts.Edit(transaction);

            return(response);
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int?id, [FromBody] TransactionEditModel NewTransaction)
        {
            try
            {
                if (id == null || id <= 0)
                {
                    throw new CustomException(400, "Id no válido");
                }
                var user_id = int.Parse(User.Claims.First(i => i.Type == "UserId").Value);
                await _transactionBusiness.Edit(id, NewTransaction, user_id);

                return(StatusCode(200));
            }
            catch { throw; }
        }