Ejemplo n.º 1
0
        public void AddCustomerWallet(CustomerWalletDTO customerWalletDTO)
        {
            CustomerWallet customerWallet = new CustomerWallet();

            CustomerWalletConvertor.ConvertToCustomerWalletEntity(ref customerWallet, customerWalletDTO, false);
            unitOfWork.CustomerWalletRepository.Add(customerWallet);
        }
Ejemplo n.º 2
0
 public void Add(CustomerWallet customerWallet)
 {
     if (customerWallet != null)
     {
         _repository.CustomerWallets.Add(customerWallet);
         //    _repository.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public void Update(CustomerWallet customerPaymentTransaction)
 {
     if (customerPaymentTransaction != null)
     {
         _repository.Entry <Sql.CustomerWallet>(customerPaymentTransaction).State = System.Data.Entity.EntityState.Modified;
         //   _repository.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public static void ConvertToCustomerWalletEntity(ref CustomerWallet customerWallet, CustomerWalletDTO customerWalletDTO, bool isUpdate)
 {
     if (isUpdate)
     {
         customerWallet.WalletId = customerWalletDTO.WalletId;
     }
     customerWallet.CustomerId    = customerWalletDTO.CustomerId;
     customerWallet.WalletBalance = customerWalletDTO.WalletBalance;
     customerWallet.AmountDueDate = customerWalletDTO.AmountDueDate;
 }
Ejemplo n.º 5
0
        public static CustomerWalletDTO ConvertToCustomerWalletDto(CustomerWallet customerWallet)
        {
            CustomerWalletDTO customerWalletDTO = new CustomerWalletDTO();

            customerWalletDTO.WalletId      = customerWallet.WalletId;
            customerWalletDTO.CustomerId    = customerWallet.CustomerId;
            customerWalletDTO.WalletBalance = customerWallet.WalletBalance;
            customerWalletDTO.AmountDueDate = customerWallet.AmountDueDate;
            return(customerWalletDTO);
        }
Ejemplo n.º 6
0
        public CustomerWallet GetById(int customerWalletId)
        {
            CustomerWallet customerWallet = new CustomerWallet();

            customerWallet = _repository.CustomerWallets.FirstOrDefault(x => x.WalletId == customerWalletId);



            return(customerWallet);
        }
        /// <summary>
        /// Забрать сдачу
        /// </summary>
        private void GetCashBack()
        {
            var cashBack = VendingMachine.Wallet.GetCashBack();

            if (cashBack == null || cashBack.Count < 1)
            {
                messageNotifyer.ShowErrorMessage("Нет сдачи");
                return;
            }

            CustomerWallet.AddCahsBack(cashBack);
        }
        private void AddOrUpdateCustomerWallet(ProductOrderDtlDTO productOrderDtlDTO)
        {
            var customerWallet = unitOfWork.CustomerWalletRepository.GetByCustomerId(productOrderDtlDTO.CustomerId);

            if (customerWallet != null)
            {
                customerWallet.WalletBalance += productOrderDtlDTO.TotalPrice;
                unitOfWork.CustomerWalletRepository.Update(customerWallet);
            }
            else
            {
                customerWallet               = new CustomerWallet();
                customerWallet.WalletId      = unitOfWork.DashboardRepository.NextNumberGenerator("CustomerWallet");
                customerWallet.CustomerId    = productOrderDtlDTO.CustomerId;
                customerWallet.WalletBalance = productOrderDtlDTO.TotalPrice;
                customerWallet.AmountDueDate = DateTime.Now.AddDays(10);
                unitOfWork.CustomerWalletRepository.Add(customerWallet);
            }
        }
Ejemplo n.º 9
0
        public void AddCustomer(CustomerDto customerDto)
        {
            //  this.CheckForExisitngCustomer(customerDto.MobileNumber);
            Customer customer = new Customer();

            customer.CustomerId = unitOfWork.DashboardRepository.NextNumberGenerator("Customer");
            CustomerConvertor.ConvertToCustomerEntity(ref customer, customerDto, false);
            unitOfWork.CustomerRepository.Add(customer);
            //creating customer wallet with customer
            CustomerWallet customerWallet = new CustomerWallet();

            customerWallet.WalletId      = unitOfWork.DashboardRepository.NextNumberGenerator("CustomerWallet");
            customerWallet.CustomerId    = customer.CustomerId;
            customerWallet.WalletBalance = 0;
            customerWallet.AmountDueDate = DateTime.Now.AddDays(10);
            unitOfWork.CustomerWalletRepository.Add(customerWallet);

            unitOfWork.SaveChanges();
        }
Ejemplo n.º 10
0
        public static int SaveWallet(TransactionLog tLog, string narration, int userID, double discountValue, double discountamount = 0)
        {
            int walletID = 0;

            try
            {
                if (userID == 0)
                {
                    return(walletID);
                }

                GlobalTransactEntitiesData pwr = new GlobalTransactEntitiesData();

                var qry = pwr.CustomerWallets
                          .Where(x => x.RefNumber == tLog.ReferenceNumber && x.User_FK == userID).ToList();

                if (qry == null || qry.Count == 0)
                {
                    double         walletPoint = Convert.ToDouble(tLog.Amount) * 0.01 * discountValue;
                    CustomerWallet cwObj       = new CustomerWallet
                    {
                        Credit     = discountamount == 0 ? walletPoint : discountamount,
                        CustomerID = tLog.CustomerID,
                        Debit      = 0,
                        IsVisible  = 1,
                        Narration  = narration,
                        RefNumber  = tLog.ReferenceNumber,
                        TrnDate    = tLog.TrnDate,
                        User_FK    = userID,
                        ValueDate  = Utility.GetCurrentDateTime().ToString("yyyy/MM/dd")
                    };
                    pwr.CustomerWallets.Add(cwObj);
                    pwr.SaveChanges();
                    walletID = cwObj.ID;
                    // return cwObj.ID;
                }
            }
            catch (Exception ex)
            {
                // WebLog.Log(ex.Message + "##", ex.StackTrace);
            }
            return(walletID);
        }
Ejemplo n.º 11
0
        public CustomerWalletRepository AddOrUpdateCustomerWallet(int customerId, double balance)
        {
            //check if customer wallet already exist;
            var customerWallet = unitOfWork.CustomerWalletRepository.GetByCustomerId(customerId);

            if (customerWallet != null)
            {
                customerWallet.WalletBalance += (long)balance * 100;
                unitOfWork.CustomerWalletRepository.Update(customerWallet);
            }
            else
            {
                customerWallet               = new CustomerWallet();
                customerWallet.CustomerId    = customerId;
                customerWallet.WalletBalance = (long)balance * 100;
                customerWallet.AmountDueDate = DateTime.Now.AddDays(10);
                unitOfWork.CustomerWalletRepository.Add(customerWallet);
            }

            return(unitOfWork.CustomerWalletRepository);
        }
Ejemplo n.º 12
0
        private void UpdateCustomerWallet(CustomerPaymentDTO customerPaymentDTO)
        {
            var customerWallet = unitOfWork.CustomerWalletRepository.GetByCustomerId(customerPaymentDTO.CustomerId);

            if (customerWallet != null)
            {
                customerWallet.WalletBalance -= customerPaymentDTO.PaymentCrAmount;
                if (customerWallet.WalletBalance > 0)
                {
                    customerWallet.AmountDueDate = DateTime.Now.AddDays(10);
                }
                unitOfWork.CustomerWalletRepository.Update(customerWallet);
            }
            else
            {
                customerWallet               = new CustomerWallet();
                customerWallet.WalletId      = unitOfWork.DashboardRepository.NextNumberGenerator("CustomerWallet");
                customerWallet.CustomerId    = customerPaymentDTO.CustomerId;
                customerWallet.WalletBalance = customerPaymentDTO.PaymentCrAmount;
                customerWallet.AmountDueDate = DateTime.Now.AddDays(10);
                unitOfWork.CustomerWalletRepository.Add(customerWallet);
            }
        }
        /// <summary>
        /// Внести монету в монетоприемник
        /// </summary>
        /// <param name="coinObject"></param>
        private void DepositCoin(object coinObject)
        {
            if (coinObject == null)
            {
                return;
            }

            int coinValue = ((ICoin)coinObject).CoinValue;

            if (!CustomerWallet.Coins.Single(c => c.CoinValue == coinValue).CanGetCoin)
            {
                messageNotifyer.ShowErrorMessage("В вашем кошельке нет монет таким достоинством");
                return;
            }

            ICoin coin = CustomerWallet.GetCoin(coinValue);

            if (coin == null)
            {
                return;
            }

            VendingMachine.CoinAcceptor.AddCoin(coin);
        }
Ejemplo n.º 14
0
        //[HttpGet]
        //[System.Web.Http.Route("Api/BookRide")]
        public void BookRide(int clat, int clong, Customer cust, int cabtype, string ridetype, int dlat, int dlong)
        {
            CabDriver cd = new CabDriver();

            cd.CabDriverId     = 1800;
            cd.CabDriverName   = "Raju";
            cd.CabDriverRating = 5;
            cd.CabDriverlat    = 4;
            cd.CabDriverlong   = 15;
            cd.CabId           = 2;
            cd.CabType         = 0;
            cd.CityId          = 3;
            cd.DriverStatus    = 1;

            CabDriver cd2 = new CabDriver();

            cd2.CabDriverId     = 12000;
            cd2.CabDriverName   = "Rumesh";
            cd2.CabDriverRating = 5;
            cd2.CabDriverlat    = 2;
            cd2.CabDriverlong   = 6;
            cd2.CabId           = 1;
            cd2.CabType         = 0;
            cd2.CityId          = 3;
            cd2.DriverStatus    = 1;

            cabdriverlist.Add(cd);
            cabdriverlist.Add(cd2);

            DriverWallet d1 = new DriverWallet();

            d1.DriverId = 1800; d1.Amount = 1400;
            DriverWallet d2 = new DriverWallet();

            d2.DriverId = 12000; d2.Amount = 1600;
            dw.Add(d1); dw.Add(d2);
            price.Add(3, 300);
            if (ridetype == "Go")
            {
                CabDriver      selectedcabdriver = null;
                CustomerWallet c1 = new CustomerWallet();
                c1.CustomerId = cust.CustomerId;
                c1.Amount     = 1800;
                cw.Add(c1);
                FindClosestDrivers(clat, clong, cabtype, cust.CityId);
                var closedrivers = from pair in closestdrivers
                                   orderby pair.Value ascending
                                   select pair;
                if (closestdrivers.Count() == 0)
                {
                    Console.WriteLine("No driver found");
                }
                else
                {
                    int i = 0;
                    foreach (KeyValuePair <CabDriver, double> pair in closedrivers)
                    {
                        if (i < 3)
                        {
                            int status = NotifyDriver(pair.Key, dlat, dlong);
                            //Console.WriteLine(pair.Key + " "+ pair.Value);
                            char driverselection = Convert.ToChar(Console.ReadLine());
                            if (driverselection == 'Y')
                            {
                                selectedcabdriver = pair.Key;
                                break;
                            }
                            else
                            {
                                i++;
                            }
                        }
                    }
                    if (selectedcabdriver == null)
                    {
                        Console.WriteLine("No driver found"); return;
                    }
                    Console.WriteLine("Cab driver selected " + selectedcabdriver.CabDriverName);
                    Console.ReadLine();
                    Bookings pbook = new Bookings();
                    pbook.BookingId            = 1567;
                    pbook.BookingType          = ridetype;
                    pbook.CityId               = cust.CityId;
                    pbook.CustomerId           = cust.CustomerId;
                    pbook.Destinationlatitude  = dlat;
                    pbook.Destinationlongitude = dlong;
                    pbook.Price         = (CalculateDistance(clat, clong, dlat, dlong) / 10000) * price[cust.CityId];
                    pbook.BookingStatus = 1;
                    pbook.CabDriverId   = selectedcabdriver.CabDriverId;

                    Console.WriteLine("Trip booked");

                    // Keep polling if trip has completed
                    //if trip has completed

                    foreach (var DriverWallt in dw)
                    {
                        if (DriverWallt.DriverId == selectedcabdriver.CabDriverId)
                        {
                            DriverWallt.Amount += pbook.Price;
                            Console.WriteLine("Drivers wallet : " + DriverWallt.Amount);
                        }
                    }


                    foreach (var CustomerWallt in cw)
                    {
                        if (CustomerWallt.CustomerId == cust.CustomerId)
                        {
                            CustomerWallt.Amount -= pbook.Price;
                            Console.WriteLine("Customers wallet : " + CustomerWallt.Amount);
                        }
                    }
                    pbook.BookingStatus = 2;
                    Console.WriteLine("Trip completed");
                }
            }
        }
        public static void RegisterOld(Models.Input <WalletProfile> obj)
        {
            PayitMerchantsnWalletsEntities db = new PayitMerchantsnWalletsEntities();
            var isWalletExist = (from a in db.Customers
                                 join b in db.CustomerDevices on a.ID equals b.CustomerID
                                 where a.MobileNo == obj.input.mobileno && b.DeviceUDID == obj.param.deviceuniqueid
                                 select a).FirstOrDefault();

            if (isWalletExist == null)
            {
                Customer cus = new Customer();

                cus.CountryCode     = string.IsNullOrEmpty(obj.input.countrycode) ? "" : obj.input.countrycode;
                cus.CustomerCode    = string.IsNullOrEmpty(obj.input.userid) ? "" : obj.input.userid;
                cus.Password        = string.IsNullOrEmpty(obj.input.password) ? "" : obj.input.password;
                cus.MobileNo        = string.IsNullOrEmpty(obj.input.mobileno) ? "" : obj.input.mobileno;
                cus.MobileActivated = false;
                cus.OTP             = 0;
                cus.Email           = string.IsNullOrEmpty(obj.input.email) ? "" : obj.input.email;
                cus.EmailActivated  = false;
                //cus.AppIdentifier="";
                cus.TranDate = DateTime.Now;
                cus.Status   = false;
                db.Customers.Add(cus);
                db.SaveChanges();


                var CID = cus.ID;

                CustomerDevice CusD = new CustomerDevice();

                CusD.CustomerID = CID;
                CusD.DeviceUDID = obj.param.deviceuniqueid;
                CusD.Status     = false;
                CusD.CreatedDae = DateTime.Now;
                db.CustomerDevices.Add(CusD);
                db.SaveChanges();

                var DeviceID = CusD.ID;

                CustomerWallet CusW = new CustomerWallet();
                CusW.CustomerID  = CID;
                CusW.Balance     = 0;
                CusW.CreatedDate = DateTime.Now;
                CusW.Status      = true;

                db.CustomerWallets.Add(CusW);
                db.SaveChanges();

                CustomerOTP CusO = new CustomerOTP();
                CusO.CusomerID       = CID;
                CusO.DeviceID        = DeviceID;
                CusO.WalletServiceID = 1;
                CusO.OTP             = "";
                CusO.CreatedDate     = DateTime.Now;
                CusO.Status          = true;
                CusO.isUsed          = false;
                db.CustomerOTPs.Add(CusO);
                db.SaveChanges();
            }
        }