Example #1
0
        private string CountryName()
        {
            StandardMessages.CountryNamePromptMessage();
            string countryName = standardInput.GetInput();

            return(countryName);
        }
        private static IGrouping <string, IComposting> SelectResourceType(List <IGrouping <string, IComposting> > groups)
        {
            List <string> options = new List <string>();

            groups.ForEach(group =>
            {
                string s    = group.Count() > 1 ? "s" : "";
                string type = group.Key;
                if (type == "Goat")
                {
                    options.Add($"{type}s ({group.Count()} goat{s} available)");
                }
                else
                {
                    options.Add($"{type}s ({group.Count()} row{s} available)");
                }
            });

            int choice = StandardMessages.ShowMenu(options, "What resource should be processed?");

            if (choice == 0)
            {
                return(null);
            }
            else
            {
                return(groups[choice - 1]);
            }
        }
Example #3
0
        public async Task <OutputHandler> DeleteTestimony(int testimonyId)
        {
            try
            {
                var testimony = await _testimonyRepository.GetItemAsync(x => x.TestimonyId == testimonyId);

                await _testimonyRepository.DeleteAsync(testimony);

                var deletionresult = await FileHandler.DeleteFileFromFolder(testimony.ImageUrl, FolderName);

                if (deletionresult.IsErrorOccured)
                {
                    return(deletionresult);
                }
                await _testimonyRepository.SaveChangesAsync();

                return(new OutputHandler {
                    IsErrorOccured = false, Message = "Testimony Deleted Successfully"
                });
            }
            catch (Exception ex)
            {
                return(StandardMessages.getExceptionMessage(ex));
            }
        }
        public static void CollectInput(Farm farm)
        {
            do
            {
                UpdateFacilities(farm);
                if (_facilities.Count == 0)
                {
                    StandardMessages.ShowMessage("No available facilities to process.");
                    return;
                }

                // Select a field
                ICompostProducing selectedField = SelectField();

                // Select a resource type

                var groups = selectedField.CreateCompostList();

                IGrouping <string, IComposting> selectedGroup = SelectResourceType(groups);

                // Select quantity of resources to process
                int quantity = SelectQuantity(farm.Composter.Capacity, selectedGroup);

                // Add selected resources to hopper
                selectedField.SendToComposter(quantity, selectedGroup.Key, farm);

                UpdateFacilities(farm);
            } while (AddMore(farm.Composter.Capacity));

            farm.Composter.Process();
        }
        public static void CollectInput(Farm farm)
        {
            List <string> options = new List <string>();


            //  TODO: Check if facilites can process resources before showing the processor.
            options.Add("Seed Harvester");
            options.Add("Meat Processor");
            options.Add("Egg Gatherer");
            options.Add("Composter");

            int choice = StandardMessages.ShowMenu(options, "Choose Equipment to use...");

            switch (choice)
            {
            case 1:
                HarvestSeeds.CollectInput(farm);
                break;

            case 2:
                ProcessMeat.CollectInput(farm);
                break;

            case 3:
                GatherEggs.CollectInput(farm);
                break;

            case 4:
                Compost.CollectInput(farm);
                break;

            default:
                break;
            }
        }
Example #6
0
        public override void Display()
        {
            base.Display();
            BookBuilder bb = new BookBuilder();

            bb.WithTitle(StandardMessages.GetInputForParam("title"))
            .WithAuthorName(StandardMessages.GetInputForParam("name of the author"))
            .WithYear(StandardMessages.GetInputForParam("year"))
            .WithPages(StandardMessages.GetInputForParam("pages"))
            .WithCountry(StandardMessages.GetInputForParam("country"))
            .WithLink(StandardMessages.GetInputForParam("link"))
            .WithImageLink(StandardMessages.GetInputForParam("link of the image"))
            .WithLanguage(StandardMessages.GetInputForParam("language"));


            Book bk;

            if ((bk = bb.Create()) != null)
            {
                bk.ShowBookProp();
                Catalog.Instance.AddNewBook(bk);
            }
            else
            {
                StandardMessages.TryAgain();
            }
            StandardMessages.PressAnyKey();
            StandardMessages.PressKeyToContinue();
            Program.NavigateBack();
        }
Example #7
0
        static void Main(string[] args)
        {
            bool exit = false;

            Car thisCar = new Car();

            do
            {
                Console.WriteLine(StandardMessages.DisplayMenu());
                switch (Console.ReadLine())
                {
                case "1":
                    CarInformation.CreateCar(thisCar);
                    break;

                case "2":
                    thisCar.Accelerate();
                    break;

                case "3":
                    thisCar.Brake();
                    break;

                case "4":
                    exit = true;
                    break;

                default:
                    StandardMessages.DisplayChoiceError();
                    break;
                }
                Console.WriteLine(StandardMessages.DisplaySpeed(thisCar));
            } while (exit == false);
        }
        public void PrintPlayerStats(GameContext gameContext)
        {
            PlayerAttackCalculator.CalculatePlayerAttack(gameContext);
            Console.WriteLine($"SpacePort Location..{gameContext.Player.SpacePortLocation}");
            Console.WriteLine($"NAME:...............{gameContext.Player.Name}");
            Console.WriteLine($"GENDER:.............{gameContext.Player.Gender}");
            Console.WriteLine($"RACE:...............{gameContext.Player.Race}");
            Console.WriteLine($"JOB:................{gameContext.Player.Job}");
            Console.WriteLine(string.Empty);

            Console.WriteLine($"CREDITS:............{gameContext.Player.Credits}");
            Console.WriteLine($"EXPERIENCE:.........{gameContext.Player.XP}");
            Console.WriteLine($"LEVEL:..............{gameContext.Player.Level}");
            Console.WriteLine(string.Empty);

            Console.WriteLine($"CURRENT HIT POINTS..{gameContext.Player.HitPointsCurrent}");
            Console.WriteLine($"TOTAL HIT POINTS....{gameContext.Player.HitPointsTotal}");
            Console.WriteLine(string.Empty);

            Console.WriteLine($"ATTACK:.............{gameContext.Player.Attack}");
            Console.WriteLine($"WEAPON SKILL:.......{gameContext.Player.WeaponSkill}");
            Console.WriteLine($"WEAPON DAMAGE.......{gameContext.Player.WeaponDamageCurrent}");
            Console.WriteLine(string.Empty);

            Console.WriteLine($"ARMOR SKILL:........{gameContext.Player.ArmorSkill}");
            Console.WriteLine($"NAVIGATION SKILL:...{gameContext.Player.NavigationSkill}");
            Console.WriteLine($"TIME SKILL:.........{gameContext.Player.TimeSkill}");
            StandardMessages.ReturnToContinue();
        }
        public async Task <OutputHandler> DeleteResource(long resourceId)
        {
            try
            {
                var resource = await _resourceRepository.GetItemAsync(x => x.ResourceId == resourceId);

                await _resourceRepository.DeleteAsync(resource);

                var deletionresult = await FileHandler.DeleteFileFromFolder(resource.ImageUrl, FolderName);

                if (deletionresult.IsErrorOccured)
                {
                    return(deletionresult);
                }
                await _resourceRepository.SaveChangesAsync();

                return(new OutputHandler {
                    IsErrorOccured = false, Message = "Qoute Deleted Successfully"
                });
            }
            catch (Exception ex)
            {
                return(StandardMessages.getExceptionMessage(ex));
            }
        }
Example #10
0
        public void Process()
        {
            double compost = 0;

            //  Display message about resources processed.

            _hopper.ForEach(item =>
            {
                if (item is Goat goat)
                {
                    compost += goat.Compost();
                }
                if (item is Sunflower sunflower)
                {
                    compost += sunflower.Compost();
                }
                if (item is Wildflower wildflower)
                {
                    compost += wildflower.Compost();
                }
            });


            string message = "Harvesting resources...\n";

            message += $"{compost} Kilograms of compost were produced.\n";

            StandardMessages.ShowMessage(message);

            _kgCompost += compost;
            _hopper.Clear();
        }
Example #11
0
        public async Task <OutputHandler> DeleteEvent(int eventId)
        {
            try
            {
                var output = await _eventRepository.GetItemAsync(x => x.EventId == eventId);

                await _eventRepository.DeleteAsync(output);

                await _eventRepository.SaveChangesAsync();

                var outputHandler = await FileHandler.DeleteFileFromFolder(output.ImageUrl, FolderName);

                if (outputHandler.IsErrorOccured) // FILE Deletion failed but updated RECORD deleted
                {
                    return(new OutputHandler
                    {
                        IsErrorKnown = true,
                        IsErrorOccured = true,
                        Message = "resource deleted successfully, but deleting of old file failed, please alert Techarch Team"
                    });
                }
                return(new OutputHandler {
                    IsErrorOccured = false, Message = "Event Deleted Successfully"
                });
            }
            catch (Exception ex)
            {
                return(StandardMessages.getExceptionMessage(ex));
            }
        }
Example #12
0
        public override void Display()
        {
            base.Display();
            PersonBuilder pb = new PersonBuilder();

            pb.WithFirstName(StandardMessages.GetInputForParam("first name"))
            .WithLastName(StandardMessages.GetInputForParam("last name"))
            .WithEmailAddress(StandardMessages.GetInputForParam("email address"))
            .WithNationality(StandardMessages.GetInputForParam("nationality"))
            .WithCity(StandardMessages.GetInputForParam("city of residence"))
            .WithStreetName(StandardMessages.GetInputForParam("streetname"))
            .WithStreetnumber(StandardMessages.GetInputForParam("house number"))
            .WithStreetnumberAdd(StandardMessages.GetInputForParam("house number addition (optional)"))
            .WithZipCode(StandardMessages.GetInputForParam("zipcode"))
            .WithPassword(StandardMessages.GetInputForParam("password"))
            .WithTelePhoneNumber(StandardMessages.GetInputForParam("telephone number"))
            ;


            Person newPerson;

            if ((newPerson = pb.Create()) != null)
            {
                CatalogPerson.Instance.AddNewPerson(newPerson);
                newPerson.ShowPersonProps();
            }
            else
            {
                StandardMessages.TryAgain();
            }
            StandardMessages.PressAnyKey();
            StandardMessages.PressKeyToContinue();
            Program.NavigateBack();
        }
Example #13
0
        public async Task <OutputHandler> DeleteprojectArm(int projectArmId)
        {
            try
            {
                var projectArm = await _projectArmRepository.GetItemAsync(x => x.projectArmId == projectArmId);

                await _projectArmRepository.DeleteAsync(projectArm);

                await _projectArmRepository.SaveChangesAsync();

                var outputHandler = await FileHandler.DeleteFileFromFolder(projectArm.Artwork, FolderName);

                if (outputHandler.IsErrorOccured) //Deletion failed but updated saved
                {
                    return(new OutputHandler
                    {
                        IsErrorKnown = true,
                        IsErrorOccured = true,
                        Message = "Resource deleted successfully, but deleting of old file failed, please alert Techarch Team"
                    });
                }
                return(new OutputHandler {
                    IsErrorOccured = false, Message = "project Arm Deleted Successfully"
                });
            }
            catch (Exception ex)
            {
                return(StandardMessages.getExceptionMessage(ex));
            }
        }
        public void LoadStandardMessages()
        {
            StandardMessages Standard = new StandardMessages();

            SocialMediaTitle.Text = Standard.Social_Media_Title;
            Contact_Button.Text   = Standard.Contact_Me_Text;
        }
        private static ICompostProducing SelectField()
        {
            var options = new List <string>();

            _facilities.ForEach(fac =>
            {
                string type = "";
                if (fac is GrazingField gf)
                {
                    type = "goats";
                }
                if (fac is NaturalField nf)
                {
                    type = "plants";
                }
                options.Add($"{fac.Type}: {fac.Name} ({fac.CompostAmount} {type})");
            });

            int selection = StandardMessages.ShowMenu(options, "Select a facility to process compost from...");

            if (selection == 0)
            {
                return(null);
            }
            return(_facilities[selection - 1]);
        }
Example #16
0
        static void Main(string[] args)
        {
            bool exit = false;

            List <RetailItem> Items = new List <RetailItem>()
            {
                new RetailItem("Jacket", 12, 59.05),
                new RetailItem("Jeans", 40, 34.95),
                new RetailItem("Shirt", 20, 24.95)
            };

            do
            {
                Console.WriteLine(StandardMessages.Menu());
                switch (Console.ReadLine())
                {
                case "1":
                    ItemInformation.CreateItemInformation(Items);
                    break;

                case "2":
                    exit = true;
                    break;
                }
                Console.WriteLine();
            } while (exit == false);
        }
Example #17
0
        public async Task <OutputHandler> DeleteQoute(int qouteId)
        {
            try
            {
                var qoute = await _qouteRepository.GetItemAsync(x => x.QouteId == qouteId);

                await _qouteRepository.DeleteAsync(qoute);

                var deletionresult = await FileHandler.DeleteFileFromFolder(qoute.QouteImg, FolderName);

                if (deletionresult.IsErrorOccured)
                {
                    return(deletionresult);
                }
                await _qouteRepository.SaveChangesAsync();

                return(new OutputHandler {
                    IsErrorOccured = false, Message = "Qoute Deleted Successfully"
                });
            }
            catch (Exception ex)
            {
                return(StandardMessages.getExceptionMessage(ex));
            }
        }
        public static void CollectInput(Farm farm)
        {
            if (_facilities.Count == 0)
            {
                StandardMessages.ShowMessage("No available fields to process.");
                return;
            }
            do
            {
                // Select a field
                PlowedField selectedField = SelectField();

                // Select a resource type
                var groups = selectedField.CreateGroup();
                IGrouping <string, ISeedProducing> selectedGroup = SelectResourceType(groups);

                // Select quantity of resources to process
                int quantity = SelectQuantity(farm.SeedHarvester.Capacity, selectedGroup);

                // Add selected resources to hopper
                selectedField.SendToHopper(quantity, selectedGroup.Key, farm);
            } while (AddMore(farm.SeedHarvester.Capacity));

            farm.SeedHarvester.Process();

            // if (selectedGroup.Key == "Sunflower")
            // {
            //   farm.SeedHarvester.SunflowerSeeds += ProcessedSeeds;
            // }
            // else if (selectedGroup.Key == "Sesame")
            // {
            //   farm.SeedHarvester.SesameSeeds += ProcessedSeeds;

            // }
        }
Example #19
0
        public async Task <OutputHandler> GetAllQoutesForAdmin()
        {
            try
            {
                var qoutes = new AutoMapper <Qoute, QouteDTO>().MapToList(await _qouteRepository.GetUnfilteredListAsync());
                foreach (var item in qoutes)
                {
                    var output = await FileHandler.GetFileSize(item.QouteImg);

                    if (output.IsErrorOccured)
                    {
                        item.StorageSize = "Could not retrieve size";
                    }
                    else
                    {
                        item.StorageSize = output.Result.ToString();
                    }
                }
                return(new OutputHandler {
                    Result = qoutes, IsErrorOccured = false
                });
            }
            catch (Exception ex)
            {
                return(StandardMessages.getExceptionMessage(ex));
            }
        }
Example #20
0
 public override void Display()
 {
     Console.WriteLine($"This is the very elaborate information page of the library system.");
     StandardMessages.PressAnyKey();
     StandardMessages.PressKeyToContinue();
     Program.NavigateHome();
 }
        public static void CollectInput(Farm farm)
        {
            IFacility selectedFacility = SelectFacility(farm);

            if (selectedFacility == null)
            {
                return;                            // Back to main menu...
            }
            List <string> options = GetOptions(selectedFacility);

            int choice;

            if (options.Count > 1)
            {
                choice = StandardMessages.ShowMenu(options, "What type of resource are you buying today?");
            }
            else
            {
                choice = 1;   //  Auto selects chickens or ducks.
            }
            if (choice == 0)
            {
                return;              // Go back...
            }
            IResource newResource = GetResourceType(options[choice - 1]);

            StandardMessages.ShowMessage($"Adding a {newResource.Type} to the {selectedFacility.Type}: {selectedFacility.Name}");


            //  TODO: Add multiple resources at the same time...

            selectedFacility.AddResource(newResource);
        }
        public void LoadStandardMessages()
        {
            StandardMessages standard = new StandardMessages();

            Projects_Title.Text    = standard.Main_Projects_Title;
            Brief_Title.Text       = standard.Brief_Title;
            My_Projects_Title.Text = standard.My_Projects_Title;
        }
Example #23
0
 public override void Display()
 {
     base.Display();
     LibraryStandard.Catalog.Instance.GetBookList().OrderByDescending(o => o.Year).ToList().ForEach(b => b.ShowBookProp());
     StandardMessages.PressAnyKey();
     StandardMessages.PressKeyToContinue();
     Program.NavigateHome();
 }
Example #24
0
 public override void Display()
 {
     base.Display();
     Catalog.Instance.AddExistingBook(Console.ReadLine());
     StandardMessages.PressAnyKey();
     StandardMessages.PressKeyToContinue();
     Program.NavigateBack();
 }
 private static void FarmReport(Farm farm)
 {
     StandardMessages.DisplayBanner();
     Console.WriteLine(farm);
     Console.WriteLine("\n\n\n");
     Console.WriteLine("Press return key to go back to main menu.");
     Console.ReadLine();
 }
Example #26
0
        public void LoadStandardMessages()
        {
            StandardMessages Standard = new StandardMessages();

            My_Skills.Text       = Standard.Main_Skills_Title;
            About_Interests.Text = Standard.About_Interests_Title;
            Skills.Text          = Standard.Skills_Title;
        }
 public ViewMessagesGroup(StandardMessages messageType, string messageGroup, bool autoHide, bool allowClose)
 {
     MessageType  = messageType;
     MessageGroup = messageGroup;
     AutoHide     = autoHide;
     AllowClose   = allowClose;
     Messages     = new List <string>();
 }
        static void Main(string[] args)
        {
            StandardMessages.WelcomeMessage();

            // se afiseaza comenzile pe care utilizatorul le poate da
            CommandLine.UserCommandLine();

            // se instantiaza  clasele Brain, UserService si MessageBoard folosind clasa Factory
            // clasa Brain are evenimente care sunt apelate atunci cand utilizatorul scrie o comanda
            Brain startApplication = Factory.CreateBrain();

            // clasa UserService descrie toate actiunile pe care un user le poate face in cadrul aplicatiei
            UserService userService = Factory.CreateUserService();

            // clasa MessageBoard descrie actiunile ce pot fi facute cu postarile existente
            MessageBoard postService = Factory.CreateMessageBoard();

            startApplication.ExitApplication += Exit.ExitApplication;
            startApplication.FakeCommand     += StandardMessages.FakeCommand;
            startApplication.HelpCommand     += CommandLine.UserCommandLine;
            startApplication.CreateAccount   += userService.CreateAccount;
            startApplication.LogOut          += userService.LogOut;
            startApplication.LogIn           += userService.LogIn;
            startApplication.AddPost         += userService.AddPost;
            startApplication.ShowAllPost     += postService.ShowAllPost;
            startApplication.ShowPost        += postService.ShowPost;
            startApplication.WrongId         += StandardMessages.WrongId;
            userService.UserNotConnected     += StandardMessages.UserNotConnected;
            userService.NewMessage           += StandardMessages.NewPost;
            userService.NewPostIsAdded       += postService.AddNewPost;
            postService.UserNotConnected     += StandardMessages.UserNotConnected;
            postService.ShowPostById         += DisplayPost.DisplayPostById;
            postService.ShowAllPosts         += DisplayPost.DisplayAllPosts;

            string command = null;
            string getCommand;

            do
            {
                Console.Write($"  > ");

                // daca exista un user conectat numele lui va fi afisat in consola
                if (UserService.UserConnected != null)
                {
                    Console.Write($"({UserService.UserConnected}): ");
                }

                // se citeste comanda de la tastatura
                getCommand = UserCommand.Read();

                if (!string.IsNullOrEmpty(getCommand))
                {
                    // daca userul introduce o comanda care nu este nula se trimite ca parametru catre Brain
                    startApplication.GetUserCommand(getCommand);
                    command = Brain.Command;
                }
            }while (true);
        }
        protected void AddViewMessage(StandardMessages standardMessage, string message, string messageGroupName = null, bool autoHide = false, bool allowClose = true)
        {
            var messageGroup = !string.IsNullOrWhiteSpace(messageGroupName) ? messageGroupName : "Default";

            HandleAddViewMessage(standardMessage, new List <string>()
            {
                message
            }, messageGroup, autoHide, allowClose);
        }
Example #30
0
 public override void Display()
 {
     base.Display();
     StandardMessages.WriteInputBelow();
     LibraryStandard.Catalog.Instance.SearchBookByID(Console.ReadLine());
     StandardMessages.PressAnyKey();
     StandardMessages.PressKeyToContinue();
     Program.NavigateBack();
 }