Example #1
0
        public GeneralResponse DeleteNetworkCredit(DeleteRequest request)
        {
            GeneralResponse response = new GeneralResponse();

            NetworkCredit networkCredit = new NetworkCredit();

            networkCredit = _networkCreditRepository.FindBy(request.ID);

            if (networkCredit != null)
            {
                try
                {
                    _networkCreditRepository.Remove(networkCredit);
                    _uow.Commit();

                    ////response.success = true;
                }
                catch (Exception ex)
                {
                    response.ErrorMessages.Add(ex.Message);
                }
            }

            return(response);
        }
Example #2
0
        public GeneralResponse AddNetworkCredit(AddNetworkCreditRequest request, Guid CreateEmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                NetworkCredit networkCredit = new NetworkCredit();
                networkCredit.ID             = Guid.NewGuid();
                networkCredit.CreateDate     = PersianDateTime.Now;
                networkCredit.CreateEmployee = _employeeRepository.FindBy(CreateEmployeeID);
                if (request.Type)
                {
                    networkCredit.Amount = request.Amount;
                }
                else
                {
                    networkCredit.Amount = -request.Amount;
                }
                networkCredit.FromAccount = this._moneyAccountRepository.FindBy(request.FromAccountID);
                networkCredit.InvestDate  = request.InvestDate;

                networkCredit.Network       = this._networkRepository.FindBy(request.NetworkID);
                networkCredit.Note          = request.Note;
                networkCredit.ToAccount     = request.ToAccount;
                networkCredit.TransactionNo = request.TransactionNo;
                networkCredit.RowVersion    = 1;
                networkCredit.Balance      += networkCredit.Network.Balance + networkCredit.Amount;
                _networkCreditRepository.Add(networkCredit);

                Network network = networkCredit.Network;
                network.Balance += request.Amount;
                _networkRepository.Save(network);

                _uow.Commit();

                ////response.success = true;

                // Validation
                if (networkCredit.GetBrokenRules().Count() > 0)
                {
                    foreach (BusinessRule businessRule in networkCredit.GetBrokenRules())
                    {
                        response.ErrorMessages.Add(businessRule.Rule);
                    }

                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
            }

            return(response);
        }
Example #3
0
        public GetGeneralResponse <NetworkCreditView> GetNetworkCredit(Guid ID)
        {
            GetGeneralResponse <NetworkCreditView> response = new GetGeneralResponse <NetworkCreditView>();

            try
            {
                NetworkCredit     networkCredit     = new NetworkCredit();
                NetworkCreditView networkCreditView = networkCredit.ConvertToNetworkCreditView();

                networkCredit = _networkCreditRepository.FindBy(ID);
                if (networkCredit != null)
                {
                    networkCreditView = networkCredit.ConvertToNetworkCreditView();
                }

                response.data = networkCreditView;
            }
            catch (Exception ex)
            {
            }

            return(response);
        }
Example #4
0
        public GetNetworkCreditResponse GetNetworkCredit(GetRequest request)
        {
            GetNetworkCreditResponse response = new GetNetworkCreditResponse();

            try
            {
                NetworkCredit     networkCredit     = new NetworkCredit();
                NetworkCreditView networkCreditView = networkCredit.ConvertToNetworkCreditView();

                networkCredit = _networkCreditRepository.FindBy(request.ID);
                if (networkCredit != null)
                {
                    networkCreditView = networkCredit.ConvertToNetworkCreditView();
                }

                response.NetworkCreditView = networkCreditView;
            }
            catch (Exception ex)
            {
            }

            return(response);
        }
Example #5
0
 public static NetworkCreditView ConvertToNetworkCreditView(this NetworkCredit networkCredit)
 {
     return(Mapper.Map <NetworkCredit, NetworkCreditView>(networkCredit));
 }
Example #6
0
        public GeneralResponse EditNetworkCredit(EditNetworkCreditRequestOld request)
        {
            GeneralResponse response      = new GeneralResponse();
            NetworkCredit   networkCredit = new NetworkCredit();

            networkCredit = _networkCreditRepository.FindBy(request.ID);

            if (networkCredit != null)
            {
                try
                {
                    networkCredit.ModifiedDate     = PersianDateTime.Now;
                    networkCredit.ModifiedEmployee = _employeeRepository.FindBy(request.ModifiedEmployeeID);
                    networkCredit.Amount           = request.Amount;
                    networkCredit.FromAccount      = this._moneyAccountRepository.FindBy(request.FromAccountID);
                    if (request.InvestDate != null)
                    {
                        networkCredit.InvestDate = request.InvestDate;
                    }
                    if (request.NetworkID != null)
                    {
                        networkCredit.Network = this._networkRepository.FindBy(request.NetworkID);
                    }
                    networkCredit.Note          = request.Note;
                    networkCredit.ToAccount     = request.ToAccount;
                    networkCredit.TransactionNo = request.TransactionNo;

                    if (networkCredit.RowVersion != request.RowVersion)
                    {
                        response.ErrorMessages.Add("EditConcurrencyKey");
                        return(response);
                    }
                    else
                    {
                        networkCredit.RowVersion += 1;
                    }

                    if (networkCredit.GetBrokenRules().Count() > 0)
                    {
                        foreach (BusinessRule businessRule in networkCredit.GetBrokenRules())
                        {
                            response.ErrorMessages.Add(businessRule.Rule);
                        }

                        return(response);
                    }

                    _networkCreditRepository.Save(networkCredit);
                    _uow.Commit();

                    ////response.success = true;
                }
                catch (Exception ex)
                {
                    response.ErrorMessages.Add(ex.Message);
                }
            }
            else
            {
                response.ErrorMessages.Add("NoItemToEditKey");
            }
            return(response);
        }