Exemplo n.º 1
0
 public void AddDropdownItem(IDropdownItem <T> dropdownItem)
 {
     if (null == dropdownItem)
     {
         throw new ArgumentNullException("dropdownItem");
     }
     dropdownItem.TransitionObject = TransitionObject;
     DropdownItems.Add(dropdownItem);
 }
        public ActionResult UserProfile(UserProfileModel up)
        {
            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Authentication", new { ReturnUrl = "/RegisteredUser/UserProfile" }));
            }

            int UserID = Convert.ToInt32(User.Identity.Name);

            if (ModelState.IsValid)
            {
                DateTime Birthdate = up.DOB == null ? DateTime.MinValue : (System.DateTime)up.DOB;

                if (up.ProfilePictureFile != null && !MimeMapping.GetMimeMapping(up.ProfilePictureFile.FileName).Contains("image"))
                {
                    ModelState.AddModelError("ProfilePictureFile", "Only Images Are Allowed");
                    up.ProfilePicture = UserRepository.GetUserData(Convert.ToInt32(User.Identity.Name)).ProfilePicture;
                }
                else if (up.DOB != null && (DateTime.Compare(Birthdate, DateTime.Now.AddYears(-130)) < 0 || DateTime.Compare(Birthdate, DateTime.Now) > 0))
                {
                    ModelState.AddModelError("DOB", "Please Enter Valid Date");
                    up.ProfilePicture = UserRepository.GetUserData(Convert.ToInt32(User.Identity.Name)).ProfilePicture;
                }
                else
                {
                    UserProfileModel updated = UserRepository.addUserProfile(up, UserID, Server.MapPath(@"~/"));

                    if (updated != null)
                    {
                        ViewBag.Message = "User Profile Updated";
                        up = updated;
                        return(RedirectToAction("Login", "Authentication", new { ReturnURL = @"/RegisteredUser/UserProfile" }));
                    }
                    else
                    {
                        ViewBag.Message = "Something went wrong please try again";
                    }
                }
            }


            ViewBag.Genders              = DropdownItems.Genders();
            ViewBag.CountryCodes         = DropdownItems.CountryCodes();
            ViewBag.Countries            = NotesFilters.Countries();
            ViewBag.LoadValidationScript = true;
            ViewBag.Title      = "UserProfile";
            ViewBag.Authorized = true;
            return(View(up));
        }
        public ActionResult UserProfile()
        {
            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Authentication", new { ReturnUrl = "/RegisteredUser/UserProfile" }));
            }

            UserProfileModel userProfile = UserRepository.GetUserData(Convert.ToInt32(User.Identity.Name));

            ViewBag.Genders              = DropdownItems.Genders();
            ViewBag.CountryCodes         = DropdownItems.CountryCodes();
            ViewBag.Countries            = NotesFilters.Countries();
            ViewBag.LoadValidationScript = true;
            ViewBag.Title      = "UserProfile";
            ViewBag.Authorized = true;
            return(View(userProfile));
        }
Exemplo n.º 4
0
        public TuiDropdownSpread(int Xpostion, int Ypostion, List <String> options, TuiWindow parentTuiWindow, TuiDropdown root)
            : base(Xpostion, Ypostion, 20, options.Count, parentTuiWindow, ConsoleColor.Gray)
        {
            for (var i = 0; i < options.Count(); i++)
            {
                var item = new TuiDropdownItem(options[i], Xpostion + i, "option" + i, this);

                item.Action = delegate() {
                    root.Text = ((TuiDropdownItem)CurrentlySelected).Text;
                    root.Draw();
                };

                DropdownItems.Add(item);
            }

            _controls.AddRange(DropdownItems);

            CurrentlySelected = DropdownItems.FirstOrDefault(x => x.Text == root.Text);

            BackgroundColor = ConsoleColor.DarkGray;
            Draw();
        }
Exemplo n.º 5
0
        async Task LoadCategoriesDropdown()
        {
            try
            {
                DropdownItems.Clear();
                var CategoryListArr = new List <string>();
                using (SQLiteConnection con = new SQLiteConnection(@"Data Source=|DataDirectory|\Database.db"))
                {
                    con.Open();
                    SQLiteCommand    cmd      = new SQLiteCommand("SELECT * FROM Categories", con);
                    SQLiteDataReader reader   = cmd.ExecuteReader();
                    string[]         vnvalues = { "Category" };
                    while (reader.Read())
                    {
                        int i = 0;
                        foreach (string value in vnvalues)
                        {
                            if (!reader.IsDBNull(reader.GetOrdinal(value)))
                            {
                                CategoryListArr.Add(reader[value].ToString());
                            }
                            i++;
                        }
                    }
                    con.Close();
                }

                DropdownItems.AddRange(CategoryListArr);


                //return;

                //
                AddCategory.Clear();
                List <MenuItem> menuitmList = new List <MenuItem>();
                foreach (string categoryName in CategoryListArr)//this loop adds the text to the dropdown menu
                {
                    if (categoryName.ToString() != "All")
                    {
                        MenuItem menuitm2 = new MenuItem();
                        menuitm2.Header = categoryName;
                        menuitm2.Click += VisualNovelsListBox.ListInstance.AddToCategory;
                        //menuitm2.Command = AddToCategoryCommand;
                        //menuitm2.Click += VisualNovelsListbox.ListInstance.AddToCategory_Click;
                        menuitmList.Add(menuitm2);
                    }
                }
                AddCategory.AddMenuItemRange(menuitmList);


                RemoveCategory.Clear();
                menuitmList.Clear();
                foreach (string categoryName in CategoryListArr)//this loop adds the text to the dropdown menu
                {
                    if (categoryName.ToString() != "All")
                    {
                        MenuItem menuitm2 = new MenuItem();
                        menuitm2.Header = categoryName;
                        menuitm2.Click += VisualNovelsListBox.ListInstance.RemoveFromCategory;
                        menuitmList.Add(menuitm2);
                    }
                }
                RemoveCategory.AddMenuItemRange(menuitmList);
            }
            catch (Exception ex)
            {
                using (StreamWriter sw = File.AppendText(StaticClass.CurrentDirectory + @"\debug.log"))
                {
                    sw.WriteLine(DateTime.Now);
                    sw.WriteLine("Exception Found:\tType: {0}", ex.GetType().FullName);
                    sw.WriteLine("Class File: VnListBoxViewModel.cs");
                    sw.WriteLine("Method Name: LoadCategoriesDropdown");
                    sw.WriteLine("\nMessage: {0}", ex.Message);
                    sw.WriteLine("Source: {0}", ex.Source);
                    sw.WriteLine("StackTrace: {0}", ex.StackTrace);
                    sw.WriteLine("Target Site: {0}", ex.TargetSite);


                    sw.WriteLine("\n\n");
                }
                throw;
            }
        }
Exemplo n.º 6
0
 public void Clear()
 {
     SelectedItem = default(T);
     DropdownItems.Clear();
 }