Example #1
0
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            string uname       = txt_emailid.Text;
            string oldpassword = CLASS.PasswordEncryption.EncryptIt(txt_oldpwd.Text);
            string newpassword = CLASS.PasswordEncryption.EncryptIt(txt_newpwd.Text);

            try
            {
                IUser checkuser = new UserItems();

                //returns a table if given email id and password are matched
                dt = checkuser.checklogin(uname, oldpassword);
                if (dt != null)
                {
                    string userid       = dt.Rows[0]["Uid"].ToString();
                    bool   ispwdupdated = checkuser.UpdatePassword(userid, newpassword);
                    if (ispwdupdated)
                    {
                        lbl_submit.Text = HardCodedValues.BuddaResource.PwdChangeSuccess;
                    }
                    else
                    {
                        lbl_submit.Text = HardCodedValues.BuddaResource.Error;
                    }
                }
                else
                {
                    lbl_submit.Text = HardCodedValues.BuddaResource.LoginFail;
                }
            }
            catch (Exception ex)
            {
                lbl_submit.Text = HardCodedValues.BuddaResource.CatchBlockError + ex.Message;
            }
        }
Example #2
0
        public bool UpdatePassword(string oldpwd, string newpwd)
        {
            dt = (DataTable)this.Session["currentuser"];
            string emailid   = dt.Rows[0]["Email"].ToString();
            string userid    = dt.Rows[0]["Uid"].ToString();
            string validuser = LoginUser(emailid, oldpwd);

            if (validuser != "nouser")
            {
                string newpassword = CLASS.PasswordEncryption.EncryptIt(newpwd);
                try
                {
                    IUser updatepassword = new UserItems();
                    bool  ispwdupdated   = updatepassword.UpdatePassword(userid, newpassword);
                    return(ispwdupdated);
                }
                catch
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Example #3
0
 private void InitListViewModel(UserItemsViewModel viewModel, UserItems list)
 {
     foreach (var item in viewModel.Items)
     {
         InitBaseItemViewModel(item);
     }
 }
Example #4
0
        public string LoginUser(string emailid, string password)
        {
            //string flag = string.Empty;
            string encryptedpwd = CLASS.PasswordEncryption.EncryptIt(password);

            try
            {
                IUser checkuser = new UserItems();

                //returns datatable if username and password are matched
                dt = checkuser.checklogin(emailid, encryptedpwd);
                if (dt != null)
                {
                    //flag = "Existing User";
                    this.Session["currentuser"] = dt;
                    return(emailid);
                }
                else
                {
                    //flag = "Invalid User";
                    return("nouser");
                }
            }
            catch (Exception ex)
            {
                //flag = "Error: " + ex;
                return("nouser");
            }

            //return flag;
        }
Example #5
0
        /// <summary> Удалить пользователя. </summary>
        /// <param name="user"> Пользователь для удаления. </param>
        private void RemoveUser(User user)
        {
            var userItem = UserItems.Where(u => u.Content == user).SingleOrDefault();

            Users.Remove(user);
            UserItems.Remove(userItem);
        }
        protected void btn_login_Click(object sender, EventArgs e)
        {
            string luname    = txt_lusername.Text;
            string lpassword = CLASS.PasswordEncryption.EncryptIt(txt_lpassword.Text);

            try
            {
                IUser checkuser = new UserItems();

                //returns datatable if username and password are matched
                dt = checkuser.checklogin(luname, lpassword);
                if (dt != null)
                {
                    this.Session["currentuser"] = dt;
                    //lbl_login.Text = "Log In Successfull";
                    Response.Redirect("~/homepage.aspx");
                    //txt_lusername.Enabled = txt_lpassword.Enabled = false;
                }
                else
                {
                    lbl_login.Text = HardCodedValues.BuddaResource.LoginFail;
                }
            }
            catch (Exception ex)
            {
                lbl_login.Text = HardCodedValues.BuddaResource.CatchBlockError + ex.Message;
            }
        }
        public static int checkPid(int Pid)
        {
            IUser checkPid = new UserItems();
            int   count    = checkPid.checkPurchaseId(Pid);

            return(count);
        }
        public IActionResult List(String Act, int ItemId, int CategoryId)
        {
            UserItems uI = new UserItems();

            uI.MyItems = _context.Items.OrderBy(x => x.ItemId).ToList();

            uI.TheName = HttpContext.Session.GetString("UserName");
            uI.TheRole = HttpContext.Session.GetString("UserRole");


            if (uI.TheName != null)
            {
                Item item = _context.Items.FirstOrDefault(x => x.ItemId == ItemId);

                int userId = Convert.ToInt32(HttpContext.Session.GetString("UserId"));

                bool has = _iLikedListRepository.HasList(userId, ItemId);

                if (Act == "Like")
                {
                    LikedList likedList = new LikedList
                    {
                        CategoryId = CategoryId,
                        ItemId     = ItemId,
                        likedItems = new List <Item> {
                            item
                        },
                        UserId = userId
                    };

                    _context.LikedItems.Add(likedList);
                    _context.SaveChanges();
                }

                if (Act == "Buy")
                {
                    BuyList BuyList = new BuyList
                    {
                        CategoryId   = CategoryId,
                        ItemId       = ItemId,
                        BuyItemLists = new List <Item> {
                            item
                        },
                        UserId = userId
                    };

                    _context.BuyListItems.Add(BuyList);
                    _context.SaveChanges();
                }
            }
            else
            {
                return(RedirectToAction("Login", "Main"));
            }



            return(View(uI));
        }
Example #9
0
        public DataManager()
        {
            UserItems   = _LoadJsonFile <UserItem>("australian_users_items.json");
            Bundles     = _LoadJsonFile <Bundle>("bundle_data.json");
            UserReviews = _LoadJsonFile <UserReview>("australian_user_reviews.json");

            UserItems = UserItems.GroupBy(x => x.user_id).Select(x => x.First()).ToList();
        }
Example #10
0
        private static void GetUserInformation()
        {
            IsGettedUserInfo = true;

            string json = Methods.GetJsonText("https://api.github.com/users/" + Username);

            User = JsonConvert.DeserializeObject <UserItems>(json);
        }
 public IActionResult Delete(UserItems userItemList)
 {
     //delete function
     //Delete Row
     //Add cost of item back to user funds (Updating Database)
     //db.SaveChanges();
     return(View());
 }
Example #12
0
 /// <summary>
 /// 页面加载或是导航显示的时候 需要执行的初始化操作
 /// </summary>
 /// <param name="parsObjects"></param>
 public void NavOnLoad(params object[] parsObjects)
 {
     UserItems.Clear();
     CurrentSelectUser = new UserInfoViewModel();
     NavOnLoadUserInfo();
     NavOnLoadPrivilege();
     RequestAllUserInfomation();
 }
        protected void btn_reg_Click(object sender, EventArgs e)
        {
            if (lbl_checkemail.Text == HardCodedValues.BuddaResource.EmailIdAvailable)
            {
                //Check whether the Captcha text is correct or not
                if (this.txt_captcha.Text == this.Session["CaptchaImageText"].ToString())
                {
                    string uname        = txt_username.Text;
                    string emailid      = txt_emailid.Text;
                    string encryptedpwd = CLASS.PasswordEncryption.EncryptIt(txt_password.Text);

                    bool verfyDomain = verifyDomain(emailid);
                    bool chkEmail    = sendEmail(emailid);

                    if (verfyDomain && chkEmail)
                    {
                        BusinessEntitiesBS.UserEntities.userobj userObj = new BusinessEntitiesBS.UserEntities.userobj();

                        userObj.uname   = uname;
                        userObj.emailid = emailid;
                        userObj.pwd     = encryptedpwd;
                        try
                        {
                            IUser userInsert = new UserItems();

                            //insert new user details in database with given values
                            userInsert.insertUser(userObj);

                            dt = userInsert.checklogin(emailid, encryptedpwd);
                            this.Session["currentuser"] = dt;

                            //lbl_register.Text = "Registration Successfull";
                            Response.Redirect("~/USER/ProfilePage.aspx");
                        }
                        catch (Exception exp)
                        {
                            lbl_register.Text = HardCodedValues.BuddaResource.CatchBlockError + exp.Message;
                        }
                    }
                    else
                    {
                        lbl_register.Text = "Registration Incomplete! Invalid email id or domain. Please provide valid email for regitration.";
                    }
                }
                else
                {
                    txt_captcha.Text = "";
                    lbl_captcha.Text = HardCodedValues.BuddaResource.CaptchaError;
                    // Create a random Captcha and store it in the Session object.
                    this.Session["CaptchaImageText"] = Captcha.CaptchaImage.GenerateRandomCode(7);
                    txt_captcha.Focus();
                }
            }
            else
            {
                txt_emailid.Focus();
            }
        }
Example #14
0
        public IActionResult PurchaseItem(Items item)
        {
            ShopDBContext  db                 = new ShopDBContext();
            Users          founduser          = new Users();
            Items          foundItem          = new Items();
            PurchasedItems foundPurchasedItem = new PurchasedItems();

            foreach (Users u in db.Users)
            {
                if (u.Id == HttpContext.Session.GetInt32("current"))
                {
                    founduser = u;
                }
            }
            foreach (Items i in db.Items)
            {
                if (i.ProductName == item.ProductName)
                {
                    foundItem = i;
                }
            }
            foreach (PurchasedItems d in db.PurchasedItems)
            {
                if (d.ProductName == item.ProductName && d.UserId == founduser.Id)
                {
                    foundPurchasedItem = d;
                }
            }
            if (founduser.Funds > foundItem.Price)
            {
                founduser.Funds    -= foundItem.Price;
                foundItem.Quantity -= 1;
                PurchasedItems purchasedItem = new PurchasedItems()
                {
                    UserId = founduser.Id, ProductName = foundItem.ProductName, Description = foundItem.Description, ItemType = foundItem.ItemType, Quantity = 1
                };
                UserItems useritem = new UserItems()
                {
                    ItemId = foundItem.ProductName, UserId = founduser.Id,
                };

                db.Add(useritem);
                if (foundPurchasedItem.ProductName != null)
                {
                    foundPurchasedItem.Quantity += 1;
                }
                else
                {
                    db.Add(purchasedItem);
                }
                db.SaveChanges();
                return(View("Shop", db));
            }
            else
            {
                return(InsufficientFunds(founduser.Funds.ToString(), foundItem.Price.ToString()));
            }
        }
Example #15
0
        protected void btn_fsubmit_Click(object sender, EventArgs e)
        {
            //check whether the entered captcha text is matched or not
            if (this.txt_captcha.Text == this.Session["CaptchaImageText"].ToString())
            {
                string emailid = txt_femailid.Text;
                try
                {
                    IUser checkuser = new UserItems();

                    //returns table if given email id exists
                    dt = checkuser.checkavailability(emailid);
                    if (dt == null)
                    {
                        lbl_femailid.Text = HardCodedValues.BuddaResource.EmailIdNull;
                        // Create a random Captcha and store it in the Session object.
                        this.Session["CaptchaImageText"] = Captcha.CaptchaImage.GenerateRandomCode(HardCodedValues.BudhaConstants.RandomPasswordLength);
                        lbl_captcha.Text = string.Empty;
                    }
                    else
                    {
                        //if email id exists, then generate a new random password
                        string newpwd = GenerateRandomPassword(HardCodedValues.BudhaConstants.RandomPasswordLength);

                        //encrypt the given password to store in database
                        string encryptedpwd = CLASS.PasswordEncryption.EncryptIt(newpwd);

                        //update the new password in database
                        bool ispwdupdated = checkuser.UpdatePassword(emailid, encryptedpwd);
                        if (ispwdupdated)
                        {
                            //send the new password to the user email id
                            sendEmail(emailid, newpwd);

                            lbl_fsubmit.Text      = HardCodedValues.BuddaResource.PwdForgotSuccess;
                            lbl_fsubmit.Font.Bold = true;
                        }
                        else
                        {
                            lbl_fsubmit.Text = HardCodedValues.BuddaResource.Error;
                        }
                    }
                }
                catch (Exception ex)
                {
                    lbl_fsubmit.Text = HardCodedValues.BuddaResource.CatchBlockError + ex.Message;
                }
            }
            else
            {
                txt_captcha.Text = "";
                lbl_captcha.Text = HardCodedValues.BuddaResource.CaptchaError;
                // Create a random Captcha and store it in the Session object.
                this.Session["CaptchaImageText"] = Captcha.CaptchaImage.GenerateRandomCode(7);
                txt_captcha.Focus();
            }
        }
Example #16
0
 public void AddVideoView(VideoViewModel vm)
 {
     //UserItemsにVideoViewが無かったら追加する
     if (!UserItems.Contains(VideoView))
     {
         AddUserTab(VideoView);
     }
     VideoView.Add(vm);
     SelectedTab = VideoView;
 }
Example #17
0
    public int GetItemAmount(int cid)
    {
        UserItems item = this.GetItem(cid);

        if (item != null)
        {
            return(item.num);
        }
        return(0);
    }
Example #18
0
        public IActionResult ToSaveDrink(UserItems Items, string dCategory)
        {
            string recipeCuisine = string.Empty;

            newItems.DrinkId = Items.DrinkId;
            string drinkCategory = dCategory;

            recipeCuisine = newCuisine.Cuisine1;
            return(RedirectToAction("GetRec", "Recommendations", drinkCategory, recipeCuisine));
        }
        public IActionResult GetById(string id)
        {
            var user = UserItems.Find(id);

            if (user == null)
            {
                return(NotFound());
            }
            return(new ObjectResult(user));
        }
        private static void GetUserInformation()
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            IsGettedUserInfo = true;

            string json = Methods.GetJsonText("https://api.github.com/users/" + Username);

            User = JsonConvert.DeserializeObject <UserItems>(json);
        }
Example #21
0
        public void RemoveUserItem()
        {
            var item = UserItems.FirstOrDefault();

            if (item != null)
            {
                item.Count++;
                UserItems.Remove(item);
            }
        }
Example #22
0
        private void CreateDefaultUser()
        {
            var userItem = new User();

            userItem.Name     = "Администратор";
            userItem.Password = "******";
            userItem.IsAdmin  = true;

            UserItems.Add(userItem);
            _userModel.Save();
        }
Example #23
0
        private void Btn_Save_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(Txt_UserName.Text))
            {
                MessageBox.Show("请输入员工姓名");
                return;
            }
            else if (Com_DepartmentID.SelectedIndex < 0)
            {
                MessageBox.Show("请选择所属部门");
                return;
            }


            try
            {
                var item = new UserItems()
                {
                    ObjectID         = Txt_UserID.Text,
                    UserName         = Txt_UserName.Text,
                    UserDepartmentID = Com_DepartmentID.SelectedValue.ToString(),
                    IsEnable         = Rbtn_Yes.Checked ? "Y" : "N"
                };

                var result = IsEdit ? new UserQuery().UpdateUser(item) : new UserQuery().InsertUser(item);

                if (result)
                {
                    MessageBox.Show("保存成功");

                    if (IsEdit)
                    {
                        this.Close();
                    }
                    else
                    {
                        var unitId = Guid.NewGuid().ToString();

                        while (new UserQuery().GetUser(unitId) != null)
                        {
                            unitId = Guid.NewGuid().ToString();
                        }

                        Txt_UserID.Text = unitId;

                        Txt_UserName.Text = String.Empty;
                    }
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("保存失败," + exp.Message);
            }
        }
Example #24
0
        public async Task <IActionResult> Create([Bind("UserItemId,UserId,ItemId")] UserItems userItems)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userItems);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(userItems));
        }
Example #25
0
        public ActionResult List(UserFilterViewModel filterViewModel)
        {
            InitUserFilterViewModel(ref filterViewModel, true);
            var                filter    = Mapper.Map <UserFilter>(filterViewModel);
            UserItems          list      = _userRepository.GetUserItems(UserContext.User.Id, UserContext.User.OrganizationId, filter);
            UserItemsViewModel viewModel = Mapper.Map <UserItemsViewModel>(list);

            viewModel.Filter = filterViewModel;
            InitListViewModel(viewModel, list);

            return(View(Mvc.View.User.List, viewModel));
        }
        public IActionResult BuyList(String Act, int ItemId, int CategoryId)
        {
            UserItems uI = new UserItems();

            uI.MyItems = _context.Items.OrderBy(x => x.ItemId).ToList();

            uI.TheName = HttpContext.Session.GetString("UserName");
            uI.TheRole = HttpContext.Session.GetString("UserRole");


            if (uI.TheName != null)
            {
                Item item = _context.Items.FirstOrDefault(x => x.ItemId == ItemId);

                int userId = Convert.ToInt32(HttpContext.Session.GetString("UserId"));

                bool has = _iBuyListReository.HasList(userId, ItemId);



                if (Act == "Like" && !has)
                {
                    LikedList LikedList = new LikedList
                    {
                        CategoryId = CategoryId,
                        ItemId     = ItemId,
                        likedItems = new List <Item> {
                            item
                        },
                        UserId = userId
                    };

                    _context.LikedItems.Add(LikedList);
                    _context.SaveChanges();
                }

                if (Act == "Delete")
                {
                    BuyList items = _context.BuyListItems.Where(x => x.UserId == userId && x.ItemId == ItemId).FirstOrDefault();


                    _context.BuyListItems.Remove(items);
                    _context.SaveChanges();
                }
            }



            return(RedirectToAction("BuyList"));
        }
Example #27
0
        public IActionResult TransactionError(UserItems userItem)
        {
            string  itemName        = userItem.Item.Name;
            string  itemDescription = userItem.Item.Description;
            decimal itemPrice       = userItem.Item.Price;
            decimal?funds           = userItem.User.Funds;

            ViewBag.ItemName        = itemName;
            ViewBag.ItemPrice       = itemPrice;
            ViewBag.UserFunds       = funds;
            ViewBag.ItemDescription = itemDescription;

            return(View());
        }
Example #28
0
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool UpdateUser(UserItems user)
        {
            string sql = "Update table_user  set UserName=@UserName, DepartmentID=@DepartmentID,IsEnable=@IsEnable where ObjectID=@ObjectID";

            SQLiteParameter[] sqlparamter = new SQLiteParameter[]
            {
                new SQLiteParameter("@ObjectID", user.ObjectID),
                new SQLiteParameter("@DepartmentID", user.UserDepartmentID),
                new SQLiteParameter("@UserName", user.UserName),
                new SQLiteParameter("@IsEnable", user.IsEnable),
            };

            return(SqlHelper.ExecuteNonQuery(sql, sqlparamter) == 1);
        } /// <summary>
        public async Task UserProfile(IUser user = null)
        {
            ulong userID = 0;

            if (user == null)
            {
                userID = (Context.Message.Author as IUser).Id; user = (Context.Message.Author as IUser);
            }
            else
            {
                userID = user.Id;
            }
            EmbedBuilder embed = new EmbedBuilder();

            using (var DBContext = new SqliteDbContext())
            {
                MyUser        current   = DBContext.myUser.Where(x => x.UserID == userID).FirstOrDefault();
                UserItems     userItems = DBContext.userItems.Where(x => x.UserID == userID).FirstOrDefault();
                var           allitems  = DBContext.userItems.AsEnumerable().Where(x => x.UserID == userID).Select(x => x.ItemID);
                List <string> list      = new List <string>();

                var itemInfo = from x in DBContext.userItems.AsEnumerable()
                               where x.UserID == userID
                               select new
                {
                    id     = x.ItemID,
                    amount = x.Amount
                };

                foreach (var item in itemInfo)
                {
                    string name = DBContext.items.Where(x => x.ItemID == item.id).Select(x => x.IName).FirstOrDefault();
                    list.Add("---" + name + " " + item.amount + "x");
                }

                embed.WithColor(Color.LightGrey);
                embed.WithAuthor("Profile");
                string ret;
                ret = "**Name:** " + user.Username + "\n **Coins:** " + current.Coins + "\n **Items:** \n";

                for (int i = 0; i < list.Count; i++)
                {
                    ret += list[i] + "\n";
                }

                embed.WithDescription(ret);
                await Context.Channel.SendMessageAsync("", false, embed.Build());
            }
        }
Example #30
0
        /// <summary>
        /// 新增用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool InsertUser(UserItems user)
        {
            string sql = "INSERT into table_user (ObjectID,DepartmentID,UserName,IsEnable,IsDelete) VALUES(@ObjectID,@DepartmentID,@UserName,@IsEnable,@IsDelete)";

            SQLiteParameter[] sqlparamter = new SQLiteParameter[]
            {
                new SQLiteParameter("@ObjectID", user.ObjectID),
                new SQLiteParameter("@DepartmentID", user.UserDepartmentID),
                new SQLiteParameter("@UserName", user.UserName),
                new SQLiteParameter("@IsEnable", user.IsEnable),
                new SQLiteParameter("@IsDelete", "N")
            };

            return(SqlHelper.ExecuteNonQuery(sql, sqlparamter) == 1);
        }
Example #31
0
        public Inventory(int Userid)
        {
            DataTable Data = Engine.dbManager.ReadTable("SELECT * FROM members_furniture WHERE userid = '" + Userid + "'");

            foreach (DataRow Row in Data.Rows)
            {
                UserItems Items = new UserItems()
                {
                    ID = (int)Row["id"],
                    FurniID = (int)Row["furniid"],
                    Room = (int)Row["room"],
                    Wall = Row["wall"].ToString(),
                    X = (int)Row["x"],
                    Y = (int)Row["y"],
                    Z = (int)Row["z"]
                };

                All.Add(Items.ID, Items);
            }
        }
Example #32
0
 public void UpdateUserItems(UserItems[] items)
 {
     if (items != null)
     {
         if (this._userItemsDic == null)
         {
             this._userItemsDic = new Dictionary<int, UserItems>();
         }
         foreach (UserItems items2 in items)
         {
             if (this._userItemsDic.ContainsKey(items2.itemCid))
             {
                 this._userItemsDic[items2.itemCid] = items2;
             }
             else
             {
                 this._userItemsDic.Add(items2.itemCid, items2);
             }
         }
     }
 }