Example #1
0
        public tbl_PackagePrice GetPackagePrice(Int64 mobileEVID, decimal?consumedNet)
        {
            try
            {
                if (consumedNet == null || consumedNet == 0)
                {
                    return(null);
                }

                CRUDOperation      cRUDOperation = new CRUDOperation();
                List <tbl_Package> packages      = GetPackageList(mobileEVID);
                Int64 packageID = 0;
                foreach (var item in packages)
                {
                    if (consumedNet < item.PackageSize)
                    {
                        packageID = item.ID;
                        break;
                    }
                }
                tbl_PackagePrice packagePrice = cRUDOperation.GetPackagePriceByID(packageID);
                return(packagePrice);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Example #2
0
        public void AddNetConsumePoint(Int64 userID, string userName, tbl_NetConsumeDetail _netConsumeDetail)
        {
            try
            {
                CRUDOperation        cRUDOperation        = new CRUDOperation();
                decimal              pointValue           = 0;
                decimal              priceValue           = 0;
                int                  operatorEVID         = NetConsumeHelper.GetOperatorValueByKey(_netConsumeDetail.OperatorName.Trim());
                NetConsumeRepository netConsumeRepository = new NetConsumeRepository();
                if (_netConsumeDetail.Source_EVID == 4)
                {
                    tbl_PackagePrice packagePrice = netConsumeRepository.GetPackagePrice(operatorEVID, _netConsumeDetail.Consumed);
                    if (packagePrice != null)
                    {
                        pointValue = 1 * (packagePrice.Point == null ? 0 : (decimal)packagePrice.Point);
                        priceValue = 1 * (packagePrice.Price == null ? 0 : (decimal)packagePrice.Price);
                    }
                }

                AddUserPointAndPrice(userID, _netConsumeDetail.Month, _netConsumeDetail.Year, pointValue, priceValue, (int)ChanelType.NetConsume);
            }
            catch (Exception)
            {
            }
        }
        public async Task <IHttpActionResult> AddPackagePrice(tbl_PackagePrice item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            CRUDOperation    operation = new CRUDOperation();
            tbl_PackagePrice dbitem    = operation.AddPackagePrice(item);

            return(Ok(dbitem));
        }
        public async Task <IHttpActionResult> UpdatePackagePrice(tbl_PackagePrice item)
        {
            CRUDOperation operation = new CRUDOperation();

            if (item == null)
            {
                return(NotFound());
            }
            else
            {
                var dbitem = operation.UpdatePackagePrice(item);
                return(Ok(dbitem));
            }
        }
Example #5
0
        public ActionResult EditPrice(int priceID)
        {
            PackageVM        viewModel  = new PackageVM();
            CRUDOperation    operations = new CRUDOperation();
            tbl_PackagePrice price      = operations.GetPackagePriceByID(priceID);

            viewModel.PackageID      = price.PackageID;
            viewModel.PackagePriceID = price.ID;
            viewModel.Source_EVID    = price.Source_EVID == null?0:(Int64)price.Source_EVID;
            viewModel.BeginDate      = price.BeginDate;
            viewModel.EndDate        = price.EndDate;
            viewModel.Price          = price.Price == null?0:(decimal)price.Price;
            viewModel.Point          = price.Point == null ? 0 : (decimal)price.Point;
            viewModel = populatePriceDropDownList(viewModel);
            return(View(viewModel));
        }
Example #6
0
        public decimal GetDataPrice(decimal itemData, Int64 mobileEV)
        {
            decimal            dataPrice = 0;
            CRUDOperation      operation = new CRUDOperation();
            List <tbl_Package> packages  = operation.GetPackagesByMobileEVID(mobileEV);

            foreach (var item in packages)
            {
                if (item.PackageSize > itemData)
                {
                    tbl_PackagePrice packagePrice = operation.GetPackagePricesByPackageID(item.ID).FirstOrDefault();
                    dataPrice = packagePrice == null ? 0 : (packagePrice.Price == null?0:(decimal)packagePrice.Price);
                    break;
                }
            }
            return(dataPrice);
        }
Example #7
0
        public ActionResult EditPrice(PackageVM viewModel)
        {
            try
            {
                var UserProfile = (UserProfileSessionData)this.Session["UserProfile"];
                if (UserProfile != null)
                {
                    tbl_PackagePrice price = new tbl_PackagePrice()
                    {
                        PackageID   = viewModel.PackageID,
                        ID          = viewModel.PackagePriceID,
                        Source_EVID = viewModel.Source_EVID,
                        BeginDate   = viewModel.BeginDate,
                        EndDate     = viewModel.EndDate,
                        Price       = viewModel.Price,
                        Point       = viewModel.Point,
                        UpdateDate  = DateTime.Now,
                        UpdateUser  = UserProfile.UserId
                    };

                    CRUDOperation    operations = new CRUDOperation();
                    tbl_PackagePrice itemDB     = operations.UpdatePackagePrice(price);
                    if (itemDB != null)
                    {
                        TempData["success"] = "Ok";
                        TempData["message"] = "Məlumatlar uğurla redakte olundu";
                        return(RedirectToAction("PriceIndex", new { packageID = itemDB.PackageID }));
                    }
                    else
                    {
                        TempData["success"] = "notOk";
                        TempData["message"] = "Məlumatlar redakte olunarkən xəta baş verdi";
                        return(RedirectToAction("PriceIndex", new { packageID = itemDB.PackageID }));
                    }
                }
                throw new ApplicationException("Invalid model");
            }
            catch (ApplicationException ex)
            {
                viewModel = populatePriceDropDownList(viewModel);
                return(View(viewModel));
            }
        }
Example #8
0
        public List <NetConsumeReportDTO> SW_GetNetConsumeReports(int userID, string userName, int year)
        {
            var           result   = new List <NetConsumeReportDTO>();
            StringBuilder allQuery = new StringBuilder();
            var           query    = @"select * from  [GetNetUsage](@P_USERID,@P_year) ";

            allQuery.Append(query);

            using (var connection = new SqlConnection(ConnectionStrings.ConnectionString))
            {
                connection.Open();

                using (var command = new SqlCommand(allQuery.ToString(), connection))
                {
                    SqlParameter puserID = new SqlParameter("@P_USERID", SqlDbType.Int);
                    puserID.Value = userID;
                    command.Parameters.Add(puserID);
                    SqlParameter pyear = new SqlParameter("@P_year", SqlDbType.Int);
                    pyear.Value = year;
                    command.Parameters.Add(pyear);
                    var reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        NetConsumeReportDTO netConsumeReportDTO = new NetConsumeReportDTO()
                        {
                            INOUT_EVType = reader.GetInt32OrDefaultValue(0),
                            SourceDesc   = reader.GetStringOrEmpty(1),
                            OperatorName = reader.GetStringOrEmpty(2),
                            Year         = reader.GetInt32OrDefaultValue(3),
                            January      = reader.GetDecimalOrDefaultValue2(4),
                            February     = reader.GetDecimalOrDefaultValue2(5),
                            March        = reader.GetDecimalOrDefaultValue2(6),
                            April        = reader.GetDecimalOrDefaultValue2(7),
                            May          = reader.GetDecimalOrDefaultValue2(8),
                            June         = reader.GetDecimalOrDefaultValue2(9),
                            July         = reader.GetDecimalOrDefaultValue2(10),
                            August       = reader.GetDecimalOrDefaultValue2(11),
                            September    = reader.GetDecimalOrDefaultValue2(12),
                            October      = reader.GetDecimalOrDefaultValue2(13),
                            November     = reader.GetDecimalOrDefaultValue2(14),
                            December     = reader.GetDecimalOrDefaultValue2(15),
                        };


                        netConsumeReportDTO.Average      = GetAverage(netConsumeReportDTO);
                        netConsumeReportDTO.OperatorEVID = NetConsumeHelper.GetOperatorValueByKey(netConsumeReportDTO.OperatorName);

                        if (netConsumeReportDTO.SourceDesc == "Mobil")
                        {
                            if (netConsumeReportDTO.Average == 0)
                            {
                                netConsumeReportDTO.AveragePrice = 0;
                                netConsumeReportDTO.AveragePoint = 0;
                            }
                            else
                            {
                                tbl_PackagePrice packagePrice = GetPackagePrice(netConsumeReportDTO.OperatorEVID, netConsumeReportDTO.Average);
                                if (packagePrice == null)
                                {
                                    netConsumeReportDTO.AveragePrice = null;
                                    netConsumeReportDTO.AveragePoint = null;
                                }
                                else
                                {
                                    netConsumeReportDTO.AveragePrice = packagePrice.Price;
                                    netConsumeReportDTO.AveragePoint = packagePrice.Point;
                                }
                            }
                        }


                        result.Add(netConsumeReportDTO);
                    }
                }
                connection.Close();
            }

            return(result);
        }