Example #1
0
        public List <UserPin> GetPinListByFrenchiseID(string franchiseIncomeTypeID)
        {
            try
            {
                var _userPinList = new List <UserPin>();
                try
                {
                    // Open connection to the database
                    string ConnectionString = _connection;
                    con = new SqlConnection(ConnectionString);
                    con.Open();
                    string CommandText = "SELECT * FROM UserPins where FranchiseIncomeID ='" + franchiseIncomeTypeID + "'";
                    cmd            = new SqlCommand(CommandText);
                    cmd.Connection = con;
                    // Execute the query
                    rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        UserPin _upin = new UserPin();
                        _upin.UserID    = rdr["UserID"].ToString();
                        _upin.Pin       = Convert.ToInt32(rdr["Pin"].ToString());
                        _upin.IsUsed    = Convert.ToBoolean(rdr["IsUsed"].ToString());
                        _upin.CreatedOn = Convert.ToDateTime(rdr["CreatedOn"].ToString());
                        _userPinList.Add(_upin);
                    }
                    return(_userPinList);
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }
                finally
                {
                    // Close data reader object and database connection
                    if (rdr != null)
                    {
                        rdr.Close();
                    }

                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
                return(_userPinList);
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
                return(new List <UserPin>());
            }
        }
Example #2
0
        private void GenratePins(FranchiseIncome franchiseIncome, FranchiseIncomeReq model)
        {
            var _totalPins = model.Pins + model.FreePins;

            for (int i = 0; i < _totalPins; i++)
            {
                var _userPin = new UserPin();
                _userPin.ID = Guid.NewGuid();
                _userPin.FranchiseIncomeID = franchiseIncome.ID.ToString();
                _userPin.Pin       = _franchiseUtilities.GetRandomPin();
                _userPin.IsUsed    = false;
                _userPin.CreatedOn = DateTime.Now;
                _userPinRepository.Add(_userPin);
            }
        }
        public static UserPin BindUserPin(this IBaseRepository <UserPin> userPinRepository, string userID)
        {
            var obj = userPinRepository.GetAll().FirstOrDefault(x => x.UserID == userID);

            if (obj == null)
            {
                obj           = new UserPin();
                obj.ID        = Guid.NewGuid();
                obj.UserID    = userID;
                obj.CreatedOn = DateTime.Now;
                obj.IsUsed    = true;
                obj.Pin       = GenratePin();
                userPinRepository.Add(obj);
            }
            return(obj);
        }
Example #4
0
        public void CreateNewFrenchisePins(IBaseRepository <UserPin> userPinRepository, FranchiseIncomeReq model, Guid FranchiseIncomeID, Guid UserID)
        {
            var _totalPins = model.Pins + model.FreePins;

            for (int i = 0; i <= _totalPins; i++)
            {
                var _userPin = new UserPin();
                _userPin.ID = Guid.NewGuid();
                _userPin.FranchiseIncomeID = FranchiseIncomeID.ToString();
                _userPin.UserID            = string.Empty;
                _userPin.Pin       = GetRandomPin();
                _userPin.IsUsed    = false;
                _userPin.CreatedOn = DateTime.Now;
                userPinRepository.Add(_userPin);
            }
        }
Example #5
0
 public static void AddTokenNumber(this IBaseRepository <UserPin> userPinRepository, Guid userID, int tokenNumber)
 {
     try
     {
         Guid Id      = Guid.NewGuid();
         var  userPin = new UserPin()
         {
             ID = Id,
             FranchiseIncomeID = "0",
             UserID            = userID.ToString(),
             Pin       = tokenNumber,
             IsUsed    = false,
             CreatedOn = DateTime.Now
         };
         userPinRepository.Add(userPin);
     }
     catch (Exception e)
     {
         Console.Write(e.Message);
     }
 }
Example #6
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }

            var title       = Input.Title;
            var description = Input.Description;
            var pinCategory = Input.PinCategory;
            var pinType     = Input.PinType;

            var userPin = new UserPin()
            {
                UserId      = user.Id,
                Title       = title,
                Description = description,
                PinCategory = pinCategory,
                PinType     = pinType
            };

            _db.UserPins.Add(userPin);
            await _db.SaveChangesAsync();

            await _userManager.UpdateAsync(user : user);

            await _signInManager.RefreshSignInAsync(user);

            StatusMessage = "You have successfully added a drop pin";

            return(RedirectToPage());
        }
 public UserPin AddTokenNumber(Guid userID, int tokenNumber)
 {
     try
     {
         Guid Id   = Guid.NewGuid();
         var  user = new UserPin()
         {
             ID = Id,
             FranchiseIncomeID = string.Empty,
             UserID            = userID.ToString(),
             Pin       = tokenNumber,
             IsUsed    = false,
             CreatedOn = DateTime.Now
         };
         _userPinRepository.Add(user);
         _unitOfWork.Commit();
         return(user);
     }
     catch (Exception ex)
     {
         Console.Write(ex.Message);
         return(new UserPin());
     }
 }