private static void Main()
        {
            //List<Student> collectionOfStudents = new List<Student>();

            //collectionOfStudents[0] = new Student("Ivan", "Petrov");
            //collectionOfStudents[1] = new Student("Misho", "Geshev");
            //collectionOfStudents[2] = new Student("Volen", "Siderov");
            //collectionOfStudents[3] = new Student("Boiko", "Borisov");
            //collectionOfStudents[4] = new Student("Rosen", "Plevneliev");
            //collectionOfStudents[4] = new Student("Atanas", "Zlatanov");

            //FindItLinqAndLambda(collectionOfStudents);

            //Console.WriteLine();

            //FindItLinq(collectionOfStudents);

            List<Student> students = new List<Student>();

            for (int i = 0; i < 10; i++)
            {
                Student student = new Student(GenerateRandom.Text(15), GenerateRandom.Text(15));
                students.Add(student);
            }

            Console.WriteLine("\nUnsorted:\n");
            students.ForEach(x => Console.WriteLine(x));

            Console.WriteLine("\nSorted:\n");
            FindItLinq(students);
            FindItLinqAndLambda(students);
        }
        private static void Main()
        {
            List<Student> list = new List<Student>();

            for (int i = 0; i < 5; i++)
            {
                Student student = new Student(GenerateRandom.Text(10), GenerateRandom.Text(10));
                list.Add(student);
            }

            Expression(list);
            Linq(list);
        }
예제 #3
0
        public static List<Student> Students(int count, int firstNameLength, int lastNameLength, int fnStart, int fnEnd, int markStart, int markEnd, int groupNumberStart, int groupNumberEnd)
        {
            List<Student> students = new List<Student>();

            for (int i = 0; i < count; i++)
            {
                string firstName = GenerateRandom.Text(firstNameLength);
                string lastName = GenerateRandom.Text(lastNameLength);
                int fn = 0;

                // Hardcore atleast few 2006 students
                if (i % 5 == 0)
                {
                    fn = int.Parse(GenerateRandom.Number(1000, 9999).ToString() + "06");
                }
                else
                {
                    fn = GenerateRandom.Number(fnStart, fnEnd);
                }

                string tel = phonePrefix[GenerateRandom.Number(0, phonePrefix.Count)] + "/" + GenerateRandom.Number(100000, 999999).ToString();
                string email = firstName + "." + lastName + "@" + mailProviders[GenerateRandom.Number(0, mailProviders.Count)];
                int numberOfMarks = GenerateRandom.Number(2, 10);
                int groupNumber = GenerateRandom.Number(groupNumberStart, groupNumberEnd);

                Group group = new Group(groupNumber, departments[GenerateRandom.Number(0, departments.Count)]);

                Student student = new Student(firstName, lastName);
                student.Fn = fn;
                student.Tel = tel;
                student.Email = email;
                student.GroupNumber = groupNumber;
                student.Group = group;

                for (int j = 0; j < numberOfMarks; j++)
                {
                    student.Marks.Add(GenerateRandom.Number(markStart, markEnd));
                }

                students.Add(student);
            }

            return students;
        }
예제 #4
0
        private static void Main()
        {
            List<Student> list = new List<Student>();

            for (int i = 0; i < 20; i++)
            {
                Student student = new Student(GenerateRandom.Text(10), GenerateRandom.Text(10));
                student.Age = GenerateRandom.Number(15, 35);

                list.Add(student);
            }

            Console.WriteLine("\nAll:\n");
            list.ForEach(x => Console.WriteLine(x));

            Console.WriteLine("\nFilterd 1:\n");
            var sorted1 = list.Where(x => x.Age >= 18 && x.Age <= 24)
                              .Select(x => new
                              {
                                  FirstName = x.FirstName,
                                  LastName = x.LastName,
                                  Age = x.Age
                              }).ToList();

            sorted1.ForEach(x => Console.WriteLine(x.FirstName + " " + x.LastName + " " + x.Age));

            Console.WriteLine("\nFilterd 2:\n");
            var sorted2 = from s in list
                          where s.Age >= 18 && s.Age <= 24
                          select new
                          {
                              FirstName = s.FirstName,
                              LastName = s.LastName,
                              Age = s.Age
                          };

            foreach (var x in sorted2)
            {
                Console.WriteLine(x.FirstName + " " + x.LastName + " " + x.Age);
            }
        }
예제 #5
0
        //Accept ID and Name of 5 students and print it in the end
        static void Main(string[] args)
        {
            int totalCount = 3;
            List<Student> listStudent = new List<Student>();
            for (int i = 0; i < 3; i++)
            {
                Student objStudent = new Student();
                Console.Write("Please enter the Student ID: ");
                objStudent.StudentId = Int32.Parse(Console.ReadLine());
                Console.Write("Please enter the Student Name: ");
                objStudent.Name = Console.ReadLine();
                listStudent.Add(objStudent);
            }

            foreach (Student student in listStudent)
            {
                if (student.Name == "Karthik")
                {
                    Console.WriteLine(string.Format("ID: {0} Name: {1}", student.StudentId, student.Name));
                }
            }
        }
예제 #6
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var hasher = new PasswordHasher();
                var user = new ApplicationUser
                {
                    UserName = model.UserName,
                    Email = model.Email,
                    FirstName = model.FirstName,
                    MiddleName = model.MiddleName,
                    LastName = model.LastName,
                    SecurityStamp = Guid.NewGuid().ToString(),
                    PasswordHash = hasher.HashPassword(model.Password),
                };

                var result = await this.UserManager.UserValidator.ValidateAsync(user);
                if (result.Succeeded)
                {
                    var student = new Student()
                    {
                        User = user
                    };
                    this.students.Create(student);
                    this.UserManager.AddToRole(user.Id, GlobalConstants.StudentRoleName);
                    await this.SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");
                    return this.RedirectToAction("Index", "Home");
                }

                this.AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return this.View(model);
        }