Exemplo n.º 1
0
        /// <summary>
        /// Obtiene los movimientos según el filtro PaymentValues.
        /// </summary>
        /// <param name="paymentValues">Filtro aplicar a los movimientos.</param>
        /// <param name="configPage">Configuración de la paginación.</param>
        /// <returns></returns>
        public IEnumerable <Entity.PaymentValue> GetPaymentValues(PaymentValues paymentValues, PagedQueryObject configPage)
        {
            IList <Entity.PaymentValue> ret = new List <Entity.PaymentValue>();
            DateTime day      = DateTime.Now.Date;
            DateTime week     = DateTime.Now.AddDays(-7).Date;
            DateTime month    = DateTime.Now.AddMonths(-1).Date;
            DateTime quarter  = DateTime.Now.AddMonths(-3).Date;
            DateTime semester = DateTime.Now.AddMonths(-6).Date;
            DateTime annual   = DateTime.Now.AddYears(-1).Date;

            var query = from q in _context.Payments
                        where q.User.Id == this._user.Id &&
                        (q.Date >= (paymentValues == PaymentValues.Month ? month :
                                    paymentValues == PaymentValues.Quarter ? quarter :
                                    paymentValues == PaymentValues.Semester ? semester :
                                    paymentValues == PaymentValues.Week ? week :
                                    paymentValues == PaymentValues.Annual ? annual :
                                    day) &&
                         q.Date <= day)
                        group q by q.PaymentType into g
                        select new Entity.PaymentValue
            {
                PaymentType = (PaymentTypes)g.Key,
                Value       = g.Sum(v => v.Value)
            };

            ret = query.Page(configPage).ToArray();
            return(ret);
        }
Exemplo n.º 2
0
        public OpertionResult Create(PaymentValues pValue)
        {
            try
            {
                #region Parameters
                var parameters = new List <OracleParameter> {
                    new OracleParameter {
                        ParameterName = "retVal", OracleDbType = OracleDbType.Int32, Direction = ParameterDirection.ReturnValue
                    },
                    new OracleParameter {
                        ParameterName = "v_pvalue", OracleDbType = OracleDbType.Double, Value = pValue.PayValue
                    },
                    new OracleParameter {
                        ParameterName = "v_createdby", OracleDbType = OracleDbType.Varchar2, Value = pValue.CreatedBy.Id
                    },
                    new OracleParameter {
                        ParameterName = "v_created_acc", OracleDbType = OracleDbType.Int32, Value = pValue.CreatedBy.Account
                    },
                    new OracleParameter {
                        ParameterName = "v_profile_id", OracleDbType = OracleDbType.Int32, Value = pValue.ProfileId
                    }
                };
                #endregion
                _db.ExecuteStoredProc("pk_infra.fn_create_pay_values", parameters);
                var result = int.Parse(parameters.Find(x => x.ParameterName == "retVal").Value.ToString());

                if (result > 0)
                {
                    return(new OpertionResult {
                        AffectedCount = result, Success = true, Error = string.Empty
                    });
                }
                else
                {
                    return(new OpertionResult {
                        AffectedCount = result, Success = false, Error = string.Empty
                    });
                }
            }
            catch (Exception ex)
            {
                return(new OpertionResult {
                    AffectedCount = -1, Success = false, Error = ex.Message
                });
            }
        }
Exemplo n.º 3
0
        private PaymentValues ConvertDataRowToPaymentValues(DataRow row)
        {
            var appObj = new PaymentValues();

            appObj.Seq       = row["seq"] == DBNull.Value ? -1 : int.Parse(row["seq"].ToString());
            appObj.PayValue  = row["pvalue"] == DBNull.Value ? -1 : double.Parse(row["pvalue"].ToString());
            appObj.ProfileId = row["profile_id"] == DBNull.Value ? -1 : double.Parse(row["profile_id"].ToString());
            appObj.CreatedOn = row["createdon"] == DBNull.Value ? DateTime.MinValue : DateTime.Parse(row["createdon"].ToString());
            var creatorAccount = row["created_acc"] == DBNull.Value ? -1 : int.Parse(row["created_acc"].ToString());

            var creator = _partnerManager.GetPartnerByAccount(creatorAccount);

            appObj.CreatedBy.Account = creatorAccount;
            appObj.CreatedBy.Id      = creator.Id;
            appObj.CreatedBy.Name    = creator.Name;

            return(appObj);
        }
Exemplo n.º 4
0
        public IActionResult CreatePVs(PaymentValuesDto model)
        {
            if (ModelState.IsValid)
            {
                if (model.PayValue <= 0)
                {
                    _toastNotification.AddErrorToastMessage("المبلغ غير صحيح", new ToastrOptions {
                        Title = ""
                    });
                    return(View());
                }
                if (model.ProfileId <= 0)
                {
                    _toastNotification.AddErrorToastMessage("رقم المعرف غير صحيح", new ToastrOptions {
                        Title = ""
                    });
                    return(View());
                }
                var created = new PaymentValues();
                created.PayValue          = model.PayValue;
                created.ProfileId         = model.ProfileId;
                created.CreatedBy.Id      = _partnerManager.GetCurrentUserId(httpContext: this.HttpContext);
                created.CreatedBy.Account = _partnerManager.GetCurrentUserAccount(httpContext: this.HttpContext);
                var result = new PaymentValuesRepo(_db, _partnerManager).Create(created);
                if (!result.Success)
                {
                    if (result.AffectedCount == -504)
                    {
                        _toastNotification.AddErrorToastMessage($"المبلغ {model.PayValue.ToString("N2")} موجود مسبقا", new ToastrOptions {
                            Title = ""
                        });
                        return(Redirect(Request.Headers["Referer"].ToString()));
                    }
                }

                PValues();
                return(View("PValues"));
            }
            else
            {
                return(View());
            }
        }