コード例 #1
0
        public async Task <ActionResult <DepositFormRespObj> > AddUpdateDepositForm([FromBody] DepositformObj model)
        {
            try
            {
                var user = await _identityServer.UserDataAsync();

                model.CreatedBy = user.UserName;
                model.UpdatedBy = user.UserName;

                var isDone = _repo.AddUpdateDepositForm(model);
                return(new DepositFormRespObj
                {
                    Status = new APIResponseStatus {
                        IsSuccessful = isDone ? true : false, Message = new APIResponseMessage {
                            FriendlyMessage = isDone ? "Successful" : "Unsuccessful"
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                var errorCode = ErrorID.Generate(5);
                _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                return(new DepositFormRespObj
                {
                    Status = new APIResponseStatus {
                        IsSuccessful = false, Message = new APIResponseMessage {
                            FriendlyMessage = "Error Occurred", TechnicalMessage = ex?.Message, MessageId = errorCode
                        }
                    }
                });
            }
        }
コード例 #2
0
        public bool AddUpdateDepositForm(DepositformObj entity)
        {
            try
            {
                if (entity == null)
                {
                    return(false);
                }
                deposit_depositform Category = null;
                if (entity.DepositFormId > 0)
                {
                    Category = _dataContext.deposit_depositform.Find(entity.DepositFormId);
                    if (Category != null)
                    {
                        Category.DepositFormId          = entity.DepositFormId;
                        Category.Structure              = entity.Structure;
                        Category.Operation              = (int)OperationsEnum.DepositFormSubmit;
                        Category.TransactionId          = entity.TransactionId;
                        Category.AccountNumber          = entity.AccountNumber;
                        Category.Amount                 = entity.Amount;
                        Category.ValueDate              = entity.ValueDate;
                        Category.TransactionDate        = DateTime.Now;
                        Category.TransactionDescription = entity.TransactionDescription;
                        Category.TransactionParticulars = entity.TransactionParticulars;
                        Category.Remark                 = entity.Remark;
                        Category.ModeOfTransaction      = entity.ModeOfTransaction;
                        Category.InstrumentNumber       = entity.InstrumentNumber;
                        Category.InstrumentDate         = entity.InstrumentDate;
                        Category.Active                 = true;
                        Category.Deleted                = false;
                        Category.UpdatedBy              = entity.UpdatedBy;
                        Category.UpdatedOn              = DateTime.Now;
                    }
                }
                else
                {
                    Category = new deposit_depositform
                    {
                        DepositFormId          = entity.DepositFormId,
                        Structure              = entity.Structure,
                        Operation              = (int)OperationsEnum.DepositFormSubmit,
                        TransactionId          = entity.TransactionId,
                        AccountNumber          = entity.AccountNumber,
                        Amount                 = entity.Amount,
                        ValueDate              = entity.ValueDate,
                        TransactionDate        = DateTime.Now,
                        TransactionDescription = entity.TransactionDescription,
                        TransactionParticulars = entity.TransactionParticulars,
                        Remark                 = entity.Remark,
                        ModeOfTransaction      = entity.ModeOfTransaction,
                        InstrumentNumber       = entity.InstrumentNumber,
                        InstrumentDate         = entity.InstrumentDate,
                        Active                 = true,
                        Deleted                = false,
                        CreatedBy              = entity.CreatedBy,
                        CreatedOn              = DateTime.Now,
                    };
                    _dataContext.deposit_depositform.Add(Category);
                }
                var response = false;

                using (var trans = _dataContext.Database.BeginTransaction())
                {
                    try
                    {
                        response = _dataContext.SaveChanges() > 0;
                        if (response)
                        {
                            var casa = _dataContext.credit_casa.FirstOrDefault(x => x.AccountNumber == entity.AccountNumber);
                            if (casa != null)
                            {
                                casa.AvailableBalance = casa.AvailableBalance + entity.Amount;
                                casa.LedgerBalance    = casa.LedgerBalance + entity.Amount;
                                _dataContext.SaveChanges();
                            }
                        }
                        //_finTrans.BuildCustomerDepositFormPosting(entity);

                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw new Exception(ex.Message);
                    }
                }
                return(response);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }