Ejemplo n.º 1
0
 public void Init(BottleType type,CollectionUI parent)
 {
     string key = "";
     mParent = parent;
     mType = type;
     switch (type)
     {
         case BottleType.OIL_STREET:
             key = "OIL STREET";
             break;
         case BottleType.OIL_STREET_EVENTS:
             key = "OIL STREET EVENTS";
             break;
         case BottleType.PMQ:
             key = "PMQ";
             break;
         case BottleType.PMQ_EVENTS:
             key = "PMQ EVENTS";
             break;
         case BottleType.PMQ_GALLERY:
             key = "PMQ GALLERY";
             break;
         case BottleType.PMQ_RESTAURANT:
             key = "PMQ RESTAURANT";
             break;
         case BottleType.VA:
             key = "VA!";
             break;
     }
     mSprite.spriteName = key;
     mDragChild.Init(this);
     SetMyFragments(Random.Range(1,4),(FragmentType)Random.Range(1,4));
 }
Ejemplo n.º 2
0
 public void SaveOwnBottle(BottleType bottleType)
 {
     int intType = (int)bottleType;
     List<int> mOwnBottle = GetOwnBottle();
     if (!mOwnBottle.Contains(intType))
         mOwnBottle.Add(intType);
     SaveKey(mOwnBottle);
 }
Ejemplo n.º 3
0
        private void New(BottleTypeId typeId, BottleRarity rarity, BottleSize size)
        {
            var userExperience = ExperienceByRarity[rarity]
                                 + ExperienceBySize[size];

            var type = new BottleType(typeId, rarity, size, userExperience);

            Types.Add(typeId, type);
        }
Ejemplo n.º 4
0
 private void AddNewIngredient(BottleType bottleType)
 {
     if (m_BottleTypes.Contains(bottleType))
     {
         return;
     }
     m_BottleTypes.Add(bottleType);
     m_IngredientList.Add(bottleType.m_Type);
 }
Ejemplo n.º 5
0
    private void SetMixedIngredient(string mixedIgredient)
    {
        BottleType MixedIngredient = BottleType.CreateInstance <BottleType>();

        m_BottleTypes.Add(MixedIngredient);
        MixedIngredient.name     = mixedIgredient;
        MixedIngredient.m_Type   = mixedIgredient;
        MixedIngredient.m_Amount = m_Fill;
    }
Ejemplo n.º 6
0
        public async Task <BottleType> AddBottleType(CreateBottleTypeVM bottleType)
        {
            try
            {
                var newBottleType = new BottleType()
                {
                    Color              = bottleType.Color,
                    YearVintage        = bottleType.YearVintage,
                    Winery             = bottleType.Winery,
                    Varietal           = bottleType.Varietal,
                    Vinyard            = bottleType.Vinyard,
                    Name               = bottleType.Name,
                    PurchaseDate       = bottleType.PurchaseDate,
                    PurchasePrice      = bottleType.PurchasePrice,
                    StorageDate        = bottleType.StorageDate,
                    StorageTemparature = bottleType.StorageTemparature,
                    CreatedById        = bottleType.CreatedById,
                    OpenedDate         = bottleType.OpenedDate,
                    Notes              = bottleType.Notes
                };

                for (var i = 0; i < bottleType.NewBottleCount; i++)
                {
                    var newBottle = new Bottle()
                    {
                        Color              = bottleType.Color,
                        YearVintage        = bottleType.YearVintage,
                        Winery             = bottleType.Winery,
                        Varietal           = bottleType.Varietal,
                        Vinyard            = bottleType.Vinyard,
                        Name               = bottleType.Name,
                        PurchaseDate       = bottleType.PurchaseDate,
                        PurchasePrice      = bottleType.PurchasePrice,
                        StorageDate        = bottleType.StorageDate,
                        StorageTemparature = bottleType.StorageTemparature,
                        CreatedById        = bottleType.CreatedById,
                        CreatedDateTime    = bottleType.CreatedDateTime,
                        OpenedDate         = bottleType.OpenedDate,
                        Notes              = bottleType.Notes
                    };

                    newBottleType.Bottles.Add(newBottle);
                }

                _ctx.BottleTypes.Add(newBottleType);

                await _ctx.SaveChangesAsync();

                return(newBottleType);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 7
0
        internal static float CursorShifting(BottleType type)
        {
//			switch(type)
//			{
//				case BottleType.Big: return (float)1;
//				case BottleType.Medium: return (float)1.25;
//				case BottleType.Small: return (float)1.5;
//				case BottleType.Ether: return (float)2;
//				default: return 0;
//			}
            return((float)type);
        }
        public override void Solve()
        {
            var NandL = ReadArrString().Select(int.Parse).ToArray();
            var costs = ReadArrString().Select(int.Parse).ToArray();

            BottleType[] bottles = new BottleType[costs.Length];
            for (int i = 1; i <= costs.Length; i++)
            {
                bottles[i - 1] = new BottleType
                {
                    Volume = (int)Math.Pow(2, i - 1),
                    Cost   = costs[i - 1]
                };
            }
            Console.Write(MinPossibleCost(bottles, NandL[1]).ToString());
        }
Ejemplo n.º 9
0
 public DeadWaterBottle(BottleType type) : base(false, 0)
 {
     Type = type;
 }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            //// first, explain main, console.writeline and console.read
            //// explain comments

            //// simple string
            //string my_string = "hello world!";
            //Console.WriteLine(my_string);
            //Console.ReadLine();

            //// do 99 beers exercise. explain how to write a function and what the static does - ie makes it so doesn't need instatiation
            //NintyNineBottles();

            //// console input
            //Console.WriteLine("Enter Your Name:");

            //// Create a string variable and get user input from the keyboard and store it in the variable
            //string user_name = Console.ReadLine();

            //// Print the value of the variable (userName), which will display the input value
            //Console.WriteLine("Your username is: " + user_name);
            //Console.ReadLine();

            //// messing with strings
            //// explain concatentaion
            //string my_string_c = "hello there, PAL teacher (" + user_name + ")";
            //Console.WriteLine(my_string_c);
            //Console.ReadLine();

            //string my_string_concat_1 = "first part of sentence";
            //string my_string_concat_2 = "second part of sentence";

            //Console.WriteLine(my_string_concat_1 + " - " + my_string_concat_2);
            //Console.ReadLine();

            //// explain indexof, split, 1 and 0 space
            //bool has_space = user_name.IndexOf(" ") > -1;
            //string[] reversed_name = user_name.Split(' ');
            //Console.WriteLine(has_space ? reversed_name[1] + ", " + reversed_name[0] : reversed_name[0]);
            //Console.ReadLine();

            //// how many spaces? introduce array length
            //int num_spaces = my_string_concat_1.Split(' ').Length;
            //Console.WriteLine("'" + my_string_concat_1 + "' has " + num_spaces + " spaces in it.");
            //Console.ReadLine();

            ////arrays and lists of strings
            //string[] my_split = my_string_c.Split(',');

            //// explain array 0
            //Console.WriteLine("First half of sentence split by comma: " + my_split[0]);
            //Console.WriteLine("Second half of sentence split by comma: " + my_split[1]);
            //Console.ReadLine();

            //// explain arrays + lists of string
            //string[] my_string_array = new string[] { "First", "Second", "Third" };
            //List<string> my_string_list = new List<string>() { "First List Item", "Second List Item", "Third List Item", "Fourth List Item" };

            //foreach (string item in my_string_array) {
            //    Console.WriteLine(item);
            //}
            //Console.WriteLine("This array had " + my_string_array.Length + " items in it.");
            //Console.ReadLine();


            //foreach (string item in my_string_list) {
            //    Console.WriteLine(item);
            //}
            //Console.WriteLine("This array had " + my_string_list.Count + " items in it.");
            //Console.ReadLine();

            //// messing with numbers
            //int my_number = 4;
            //int my_second_number = 10;

            //// explain that everything within quotes is a string
            //Console.WriteLine(my_number + " + " + my_second_number + " = " + (my_number + my_second_number));
            //Console.ReadLine();

            //int[] my_int_array = new int[] { 1, 2, 3 };
            //List<int> my_int_list = new List<int>() { 1, 2, 3 };

            //foreach (int item in my_int_array) {
            //    Console.WriteLine(item);
            //}

            //foreach (int item in my_int_list) {
            //    Console.WriteLine("List item #:" + item);
            //}

            //// reading files - explain the @
            //string text = File.ReadAllText(@"C:\Source\Workspaces\PALProgramming\PALConsoleTest\text\test.txt");

            //// display. explain params.
            //Console.WriteLine("Contents of test.txt = {0}", text);
            //Console.ReadLine();

            //// ease into string interpolation
            //Console.WriteLine($"Contents of test.txt {text}");
            //Console.ReadLine();

            //// make new class then explain namespace, class, add nn function to that
            //NintyNineBottles nn = new NintyNineBottles();
            //nn.Run99();

            //// finish with get99
            //string from_class = nn.Get99();
            //Console.WriteLine(from_class);
            //Console.ReadLine();

            List <Bottle> bl = new List <Bottle>();

            for (int i = 0; i <= 99; i++)
            {
                Array      values = Enum.GetValues(typeof(BottleType));
                Random     random = new Random();
                BottleType type   = (BottleType)values.GetValue(random.Next(values.Length));
                bl.Add(new Bottle()
                {
                    Number = i, Type = type
                });
            }
            bl = bl.OrderByDescending(x => x.Number).ToList();

            foreach (Bottle b in bl)
            {
                Console.WriteLine($"{b.Number} bottles of {b.Type}, {b.Number} bottles of {b.Type}, take one down and pass it around, {b.Number - 1} bottles of {b.Type} on the wall!");
            }

            // different kind of loop
            bl.ForEach(x => {
                Console.WriteLine($"{x.Number} bottles of {x.Type}, {x.Number} bottles of {x.Type}, take one down and pass it around, {x.Number - 1} bottles of {x.Type} on the wall!");
            });

            // show how to instatiate object
            Bottle bottle = bl.Where(x => x.Number == 45).FirstOrDefault() ?? new Bottle()
            {
                Number = 0, Type = null
            };

            Console.WriteLine($"Bottle type for bottle #{bottle.Number} - {bottle.Type}");

            Beer beer = new Beer()
            {
                Number = 700, ABV = "15%", Size = 40
            };

            Console.WriteLine($"Bottle type for bottle #{beer.Number} - {beer.Type}");

            // messing with dates
            DateTime now = DateTime.Now;

            Console.WriteLine(now);
            Console.WriteLine(now.ToShortDateString());
            Console.WriteLine(now.ToShortTimeString());
            Console.WriteLine(now.ToString("MM/dd/yyyy"));
            Console.WriteLine(now.AddDays(30));
            Console.ReadLine();

            // lists of dates
            List <DateTime> ld = new List <DateTime>()
            {
            };

            for (var i = DateTime.Today.Month; i >= 1; i--)
            {
                ld.Add(DateTime.Today.AddMonths(-i));
            }
            Console.WriteLine(string.Join(",", ld.ToArray()));
            Console.WriteLine(ld.First());
            Console.ReadLine();

            // into the database
            //// EF:
            //// 1) add appsettings.json 2) create models class 3) create users model

            //// explain calling the dbcontext

            PALModels db = new PALModels();

            // get list of users - explain ?? for nullable stuff
            List <Users> u = (from user in db.Users select user).ToList() ?? new List <Users>();

            u.ForEach(x => {
                Console.WriteLine($"User Name: {x.FirstName} {x.LastName}");
            });

            // get list teachers
            List <Users> t = (from user in db.Users where (user.IsTeacher ?? false) select user).ToList() ?? new List <Users>();

            t.ForEach(x => {
                Console.WriteLine($"Teacher Name: {x.FirstName} {x.LastName}");
            });

            // get individual
            Users teacher = (from user in db.Users where (user.IsTeacher ?? false) select user).FirstOrDefault() ?? new Users();

            Console.WriteLine($"Individual Teacher Name: {teacher.FirstName} {teacher.LastName}");

            // explain include and theninclude
            List <Users> lu = (from user in db.Users.Include(x => x.UsersAttendance).Include(x => x.UsersGrades).ThenInclude(x => x.Class) select user).ToList() ?? new List <Users>();

            lu.ForEach(x => {
                Console.WriteLine($"User Name: {x.FirstName} {x.LastName}");
                x.UsersGrades.ForEach(y => {
                    Console.WriteLine($"Grade: {y.Class.Name}: {y.Grade}");
                });
            });

            // get user
            Users user1 = (from user in db.Users where user.UserID == 1 select user).FirstOrDefault() ?? new Users();

            Console.WriteLine($"Enter a new password for: {user1.FullName}");
            string new_password = Console.ReadLine();

            // update password
            user1.Password = new_password;
            db.Users.Update(user1);
            db.SaveChanges();

            // delete
            user1 = (from user in db.Users where user.UserID == 6 select user).FirstOrDefault() ?? new Users();
            if (user1.UserID > 0)
            {
                db.Users.Remove(user1);
                db.SaveChanges();
            }

            // insert new + split combined
            Console.WriteLine($"Enter a name user like this: firstname|lastname|email|password|isteacher");
            string new_user = Console.ReadLine();

            string[] new_user_split = new_user.Split("|");

            // install this for hashing - install-package Microsoft.Extensions.Identity.Core
            user1 = new Users()
            {
                FirstName = new_user_split[0], LastName = new_user_split[1], Email = new_user_split[2], Password = new PasswordHasher <object?>().HashPassword(null, new_user_split[3]), IsTeacher = Convert.ToBoolean(new_user_split[4])
            };
            db.Users.Update(user1);
            db.SaveChanges();
            Console.WriteLine($"New user ID: {user1.UserID} - Password: {user1.Password}");

            Console.ReadLine();
        }
Ejemplo n.º 11
0
        // the Main() function is the entryway to the component. string[] is the array of arguments you can pass if running this via Windows command prompt.
        static void Main(string[] args)
        {
            // TODO: this is a todo
            // FIXME: this is a fixme

            // simple hello world write to console
            //Console.WriteLine("Hello World!");
            //Console.ReadLine();

            // make the message into a string variable than we then output
            //string my_string = "Hello World, this is my first C# app! ";
            //Console.WriteLine(my_string);
            //Console.ReadLine();

            // run 99 bottles function, on line 62
            NintyNineBottles();

            // do we have arguments? if yes, output the argument
            if (args.Length > 0)
            {
                Console.WriteLine(args[0]);
                Console.ReadLine();
            }

            // cause an error by trying to divide by zero, and catching said error to deal with gracefully
            try {
                int error_zero = 0;
                int error      = 100 / error_zero;
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }

            // input - have user enter name
            Console.WriteLine("Enter Your Name:");
            string user_name = Console.ReadLine();

            Console.ReadLine();

            // insert the input name into a sentence
            string my_string_c = $"hello there, PAL student ({user_name})";

            Console.WriteLine(my_string_c);
            Console.ReadLine();

            // mash two sentences together using string interpolation -$"{variable_name} some text"; (dollar sign, quotes, variables inside brackets)
            string first_sentence  = "This is the first part";
            string second_sentence = "This is the second part";

            Console.WriteLine($"{first_sentence} - {second_sentence}");
            Console.ReadLine();

            // does the username the user input have a space in it ? if yes, reverse it and put a comma in it.reversed_name[0] is first name since arrays are 0 based, reversed_name[1] is last name
            bool has_space = user_name.IndexOf(" ") > -1;

            string[] reversed_name = user_name.Split(" ");
            Console.WriteLine(has_space ? $"{reversed_name[1]}, {reversed_name[0]}" : user_name);
            Console.ReadLine();

            // replace the space in the username gathered with a period
            string period_name = user_name.Replace(" ", ".");

            Console.WriteLine(period_name);
            Console.ReadLine();

            // split the first_sentence string variable into an array object and show how many spaces it has in it
            string[] s          = first_sentence.Split(" ");
            int      num_spaces = s.Length;

            Console.WriteLine($"'{first_sentence}' has {num_spaces} in it.");
            Console.ReadLine();

            // loop through every word in first_sentence
            for (int i = 0; i <= s.Length - 1; i++)
            {
                Console.WriteLine(s[i]);
            }
            Console.ReadLine();

            // create a new string array and a new list of strings, two ways of dealing with multiple strings in a single object that you can loop through
            string[]      my_array       = new string[] { "First", "Second", "Third" };
            List <string> my_string_list = new List <string>()
            {
                "First List Item", "Second List Item", "Third List Item"
            };

            // loop through my_array
            foreach (string item in my_array)
            {
                Console.WriteLine(item);
            }
            Console.ReadLine();

            // display length for my_array
            Console.WriteLine($"That array had {my_array.Length} items in it");
            Console.ReadLine();

            // loop through list of strings variable my_string_list
            foreach (string item in my_string_list)
            {
                Console.WriteLine(item);
            }
            Console.ReadLine();

            // display length for list of strings my_string_list
            Console.WriteLine($"That array had {my_string_list.Count} items in it");
            Console.ReadLine();

            Console.WriteLine(string.Join(",", my_array));
            Console.ReadLine();

            // declare number variables 4 and 10
            int my_number        = 4;
            int my_second_number = 10;

            // show sentence 4 + 10 = 14 - first part is formatting, second part does the math and formats
            Console.WriteLine($"{my_number} + {my_second_number} = {(my_number + my_second_number)}");
            Console.ReadLine();

            // doubles are numbers with decimals
            double my_third_number  = 4.32;
            double my_fourth_number = .8;

            // show 4.32 * 80% (.8) = 3.456
            Console.WriteLine($"{my_third_number} * {(my_fourth_number * 100)}% = {Math.Round(my_third_number * my_fourth_number, 2)}");
            Console.ReadLine();

            // turn my_third_number negative, but then use math.abs to show without negative
            my_third_number = -4.32;
            Console.WriteLine($"{my_third_number} * {(my_fourth_number * 100)}% = {Math.Abs(Math.Round(my_third_number * my_fourth_number, 2))}");
            Console.ReadLine();

            // create array and list of int data types
            int[]      my_int_array = new int[] { 1, 2, 3 };
            List <int> my_int_list  = new List <int>()
            {
                4, 5, 6
            };

            // one way to sum items, += adds numbers together to get variable 'result'
            int result = 0;

            foreach (int item in my_int_array)
            {
                result += item;
            }
            Console.WriteLine(result);

            // alternatively - use .Sum() from Linq to add numbers together
            int new_result = my_int_list.Sum();

            Console.WriteLine(new_result);
            Console.ReadLine();

            // we opened windows explorer and created file c:\temp\test.txt filled with 8 lines of words seperated by commas like below:

            /*
             *  this,is,text,from,the,external,file1
             *  this,is,text,from,the,external,file2
             *  this,is,text,from,the,external,file3
             *  this,is,text,from,the,external,file4
             *  this,is,text,from,the,external,file5
             *  this,is,text,from,the,external,file6
             *  this,is,text,from,the,external,file7
             *  this,is,text,from,the,external,file8
             */

            // this line reads all of those lines into the 'from_text' string variable
            string from_text = File.ReadAllText(@"c:\temp\test.txt");

            // output file contents
            Console.WriteLine(from_text);
            Console.ReadLine();

            // write to c:\temp\test1.txt
            string to_text = "write this to external file";

            File.WriteAllText(@"c:\temp\test1.txt", to_text);


            // split the file contents into 8 lines
            string[] next_text = from_text.Split(Environment.NewLine);

            // loop each line
            foreach (string line in next_text)
            {
                // split each line by commas
                string[] split_line = line.Split(",");

                // display each item in comma list
                foreach (string item in split_line)
                {
                    Console.WriteLine(item);
                }
            }
            Console.ReadLine();

            // ACTION: right click on the project (PALProgramming) and click "add  --> class". Call it "NinetyNineBottles.cs". Go into the file after created and follow along from there

            // call the object we created with whatever number (I used 45), it will run it that many times
            // put a breakpoint on the nn.Run99 so you can see the properties of the 'nn' object
            NinetyNineBottles nn = new NinetyNineBottles(45);

            nn.Run99();

            // this will show you what you passed in the number field and the halfway there point
            Console.WriteLine($"{nn.Number} - halfwaythere = {nn.HalfWayThere}");
            Console.ReadLine();

            // ACTION: right click on the project (PALProgramming) and click "add --> class". Call it "Bottle.cs". Go into the file and follow along from there.

            //create 'bl' variable which is a complex list, a list of the new Bottle class we created in Bottle.cs
            List <Bottle> bl = new List <Bottle>();

            // loop 99 times
            for (int i = 0; i <= 99; i++)
            {
                // get random type from BottleType enum - so either Beer, Soda, Juice, Water
                Array      values = Enum.GetValues(typeof(BottleType));
                Random     random = new Random();
                BottleType type   = (BottleType)values.GetValue(random.Next(values.Length));

                // insert new Bottle object into 'bl' list with the number from i and the random type from above
                bl.Add(new Bottle()
                {
                    Number = i, Type = type
                });
            }

            // since we looped 0-99 instead of 99-0, let's sort by number descending. Using Lambda expression (x => x.Number) is the ability to access properties of objects inside the list and use to sort, loop, etc
            bl = bl.OrderByDescending(x => x.Number).ToList();

            // loop bl and display the number and type
            foreach (Bottle b in bl)
            {
                Console.WriteLine($"{b.Number} bottles of {b.Type}, {b.Number} bottles of {b.Type}, take one down and pass it around, {b.Number - 1} bottle of {b.Type} on the wall");
            }
            Console.ReadLine();

            // a different way to loop - ForEach loops through every Bottle in the List of Bottles with the variable 'b' as a lambda expression
            bl.ForEach(b => {
                Console.WriteLine($"{b.Number} bottles of {b.Type}, {b.Number} bottles of {b.Type}, take one down and pass it around, {b.Number - 1} bottle of {b.Type} on the wall");
            });
            Console.ReadLine();

            // get the bottle with the Number propery equal 100. since it doesn't exist since we only added 99, it will use the Bottle object after the "??", which is called a null coalesce operator. if something is null, use a default instead.
            Bottle bottle = bl.Where(x => x.Number == 100).FirstOrDefault() ?? new Bottle()
            {
                Number = 0, Type = null
            };

            Console.WriteLine($"Bottle type for #{bottle.Number} - {bottle.Type}");
            Console.ReadLine();

            // create one of the child objects of Bottle, beer.
            Beer beer = new Beer()
            {
                Number = 700, ABV = "15%", Size = 40
            };

            Console.WriteLine($"Bottle type for #{beer.Number} - {beer.Type} - {beer.ABV}");
            Console.ReadLine();

            // now, fun with dates. create a new date object
            DateTime now = DateTime.Now;

            Console.WriteLine(now);

            // format in various ways
            Console.WriteLine(now.ToShortDateString());
            Console.WriteLine(now.ToShortTimeString());
            Console.WriteLine(now.ToString("MM/dd/yyyy hh:mm tt"));
            now = now.AddMonths(20);
            Console.WriteLine(now.Date.Year);
            Console.ReadLine();

            // create list of DateTime objects with the dates from this day from the previous 12 months
            List <DateTime> ld = new List <DateTime>();

            for (int i = 0; i <= 11; i++)
            {
                ld.Add(DateTime.Today.AddMonths(-i));
            }
            Console.WriteLine(string.Join(",", ld.ToArray()));
            Console.WriteLine(ld.First());
            Console.WriteLine(ld.Last());
            Console.ReadLine();

            // ACTION: right click project, click add new --> class, create PALModels.cs, then go into the class and follow along from there

            // once finished all of that, create instance of newly created dbcontext PALModels.
            PALModels db = new PALModels();

            // query the PALModels Users dbset for all treachers, return as a list of users.
            List <Users> lu = (from u in db.Users where u.IsTeacher == true orderby u.LastName select u).ToList() ?? new List <Users>();

            // loop the above results and output the full name
            lu.ForEach(u => {
                Console.WriteLine($"{u.FullName} - {u.UserID}");
            });

            Console.Read();

            // try to select a user that doesn't exist
            Users user = (from u in db.Users where u.UserID == 666 select u).FirstOrDefault() ?? new Users()
            {
                FirstName = "No", LastName = "User"
            };

            if (user.UserID == 0)
            {
                Console.WriteLine($"Does not exist");
            }
            else
            {
                Console.WriteLine($"{user.FullName} - {user.UserID}");
            }
            Console.Read();

            // re-use lu variable.
            // using Include - and ThenInclude - to populate child objects.
            lu = (from u in db.Users.Include(x => x.UsersAttendance).ThenInclude(x => x.Class).Include(x => x.UsersGrades).ThenInclude(x => x.Class) where u.IsTeacher == false select u).ToList();

            if (lu.Count() > 0)
            {
                // loop through all students
                lu.ForEach(x => {
                    Console.WriteLine($"{x.FullName} -  {x.UserID}");

                    // loop the UsersAttendance List on the Users Object that was included on line 290
                    if (x.UsersAttendance.Count() > 0)
                    {
                        // if any records exist, show attended date and class name (included using ThenInclude on line 290)
                        x.UsersAttendance.ForEach(y => {
                            Console.WriteLine($"Attended {y.Class.Name}: {y.AttendanceDate}");
                        });
                    }
                    else
                    {
                        Console.WriteLine($"No records for attendance");
                    }

                    // loop the UsersGrades List on the Users Object that was included on line 290
                    if (x.UsersGrades.Count() > 0)
                    {
                        // if any records exist, show class grade and class name (included using ThenInclude on line 290)
                        x.UsersGrades.ForEach(y => {
                            Console.WriteLine($"Grade for {y.Class.Name}: {y.Grade}");
                        });

                        // show sum for all grades if user has grades
                        Console.WriteLine($"Sum for grades: {x.UsersGrades.Sum(y => y.Grade)}");

                        // show average for grades
                        Console.WriteLine($"Average for grades: {x.UsersGrades.Average(y => y.Grade)}");
                    }
                    else
                    {
                        Console.WriteLine($"No records for grades");
                    }
                });
            }
            else
            {
                Console.WriteLine($"No records for users.");
            }

            // update user with ID of 3 to a new user that you enter in console
            Users user1 = (from u in db.Users where u.UserID == 3 select u).FirstOrDefault() ?? new Users();

            Console.WriteLine($"Enter a new password for: {user1.FullName}");
            string new_password = Console.ReadLine();

            user1.Password = new_password;
            db.Users.Update(user1);
            db.SaveChanges();

            // remove user with ID of 3 you declared on line 330
            db.Users.Remove(user1);
            db.SaveChanges();

            // remove user with ID of 4 using .Find
            db.Users.Remove(db.Users.Find(4));
            db.SaveChanges();

            // prompt yourself to enter five fields for user separated by pipe (|) character
            Console.WriteLine($"Enter a new user like this: firstname|lastname|email|password|isteacher");
            string new_user = Console.ReadLine();

            // split object you just input by pipe (|)
            string[] new_user_split = new_user.Split("|");

            // populate new users object with new_user_split, a 5 item array that you entered into terminal
            user1 = new Users()
            {
                FirstName = new_user_split[0], LastName = new_user_split[1], Email = new_user_split[2], Password = new_user_split[3], IsTeacher = Convert.ToBoolean(new_user_split[4])
            };

            // since this has UserID = 0, .Update will add a new record.
            db.Users.Update(user1);
            db.SaveChanges();

            // ACTION: view slideshow @ https://docs.google.com/presentation/d/1Ew4dCbDwd2UDAGdOTFK0RAbDZ0cHP9R4F2d74RFowyE/edit?usp=sharing
            // ACTION: open notepad and create the following document - everything from <html> to <html>:

            /*
             *   <html>
             *     <head>
             *         <title>this is my simple page</title>
             *         <style>
             *             body {
             *                 background-color: red;
             *                 color: white;
             *                 text-align: center;
             *             }
             *             div#first_div {
             *                 background-color: white;
             *                 border: 1px solid black;
             *                 color: red;
             *                 padding:15px;
             *                 margin:10px;
             *             }
             *         </style>
             *     </head>
             *
             *     <body>
             *         <div id="first_div">this is my first html page!</div>
             *         <a href="http://google.com">google.com</a> | <a href="http://facebook.com">facebook.com</a>
             *     </body>
             *  </html>
             */
            // ACTION: save as Your Documents/test.html. Open browser. Hit ctrl+0 and open your documents/test.html
            // Watch video for breakdown of how to build above document and what it all does
            // ACTION: go to github, repositories --> create new repository, per video. Call it PALProgrammingWeb. click the code dropdown and copy the clone URL.
            // ACTION: in visual studio, either open new copy or file --> new project, if new copy use create new project. Give it the name PALProgrammingWeb.
            // ACTION: choose project type ASP.NET Core Web Application -- > then Model Vide Controller (MVC)
            // ACTION: click git changes - if git changes isn't open hit view --> git changes, click create new repository, existing remote, then paste the github clone URL there.
            // We will pick up there next time.

            Console.ReadLine();
        }
Ejemplo n.º 12
0
 public LivingWaterBottle(BottleType type) : base(false, 0)
 {
     Type = type;
 }
Ejemplo n.º 13
0
 private void PourIngredient(BottleType bottleType)
 {
     bottleType.m_Amount += Time.deltaTime * 10f;
 }