Ejemplo n.º 1
0
    void Awake()
    {
        model = new World();

        view = ViewService.CreateWorldView();

        inputModel = input.GetModel();

        inputModel.shootAction += (touchUpPos) =>
        {
            if (model.gameState == GameState.PlayerTurn)
            {
                if (inputModel.distance > 1f)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        Position shootDir = input.GetShootDir();
                        Position leftDir  = (shootDir + Position.RotateLeft(shootDir) * Config.SPREAD).Normalize();
                        Position rightDir = (shootDir + Position.RotateRight(shootDir) * Config.SPREAD).Normalize();

                        LogicService.ShootBullet(model, shootDir);
                        LogicService.ShootBullet(model, leftDir);
                        LogicService.ShootBullet(model, rightDir);
                    }

                    AudioController.Instance.PlaySound(AudioController.Sound.Shot);
                }
            }
        };
    }
Ejemplo n.º 2
0
    void DrawBulletPrediction()
    {
        World clone = LogicService.CloneWorldWithoutBullets(model);

        LogicService.ShootBullet(
            clone,
            input.GetShootDir()
            );

        int steps = 0;

        for (int i = 0; i < steps; i++)
        {
            for (int j = 0; j < 1; j++)
            {
                LogicService.Tick(clone);
            }

            foreach (var b in clone.bullets.Values)
            {
                Gizmos.color = new Color(0f, 0f, 1f, 1f - (float)i / steps);
                Gizmos.DrawWireSphere(b.pos.Vector3(), b.radius);
                Gizmos.DrawLine(b.pos.Vector3(), b.pos.Vector3() + (b.dir * b.speed).Vector3());
            }
            foreach (var g in clone.gizmos)
            {
                Gizmos.color = Color.black;
                Gizmos.DrawSphere(g.Vector3(), 0.1f);
            }
        }
    }
Ejemplo n.º 3
0
        public ActionResult SearchClient(string clientName)
        {
            DashboardViewModel model = new DashboardViewModel();

            string       UserId  = User.Identity.GetUserId();
            LogicService cmLogic = new LogicService();

            //Get clients for the user that match the search string
            var allClientsForUser            = cmLogic.GetClientsForUser(UserId);
            List <ClientDTO> matchingClients = new List <ClientDTO>();

            foreach (ClientDTO client in allClientsForUser)
            {
                //Only return search result if the search term is 2 characters or more
                if (clientName.Length >= 2)
                {
                    //Make case insensitive
                    //Return client if client name matches or the search term contains the client name
                    if ((client.Name.ToLower().Contains(clientName.ToLower())) || (client.Name.ToLower() == clientName.ToLower()))
                    {
                        matchingClients.Add(client);
                    }
                }
            }

            model.ClientsForUser.ClientsToDisplay = matchingClients;

            return(View(model));
        }
Ejemplo n.º 4
0
        public ActionResult CompleteJobSubmit(CompleteJobViewModel model)
        {
            string       userId  = User.Identity.GetUserId();
            LogicService cmLogic = new LogicService();

            bool jobUpdated = cmLogic.UpdateJobForUser(model.JobId, userId, model.Hours);

            if (jobUpdated)
            {
                bool jobCompleted = cmLogic.CompleteJobForUser(model.JobId, userId);

                if (jobCompleted)
                {
                    return(RedirectToAction("ViewJob", "Jobs", new { jobId = model.JobId }));
                }

                else
                {
                    return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Failed To Complete Job" }));
                }
            }

            else
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Failed To Update Job" }));
            }
        }
Ejemplo n.º 5
0
        public ActionResult UpdateUser(UpdateUserViewModel model)
        {
            string UserId = User.Identity.GetUserId();

            LogicService cmLogic = new LogicService();

            bool addedSucessfully = cmLogic.UpdateUser(
                model.CompanyName,
                model.Email,
                model.PhoneNumber,
                UserId,
                model.Street,
                model.City,
                model.State,
                model.Zip);


            if (addedSucessfully)
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 0, message = "Updated User Sucessfully" }));
            }
            else
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "User Not Updated Sucessfully" }));
            }
        }
Ejemplo n.º 6
0
        public ActionResult AddClient(AddClientViewModel model)
        {
            string UserId = User.Identity.GetUserId();

            LogicService cmLogic = new LogicService();

            bool addedSucessfully = cmLogic.AddClient(
                model.Name,
                model.Email,
                model.PhoneNumber,
                UserId,
                model.StreetAddress,
                model.City,
                model.State,
                model.Zip);


            if (addedSucessfully)
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 0, message = "Client Added Sucessfully" }));
            }
            else
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Client Not Added Sucessfully" }));
            }
        }
Ejemplo n.º 7
0
        public ActionResult CompleteJob(string jobId)
        {
            var          model   = new CompleteJobViewModel();
            LogicService cmLogic = new LogicService();

            //Generate list of expenses to display
            var matchingExpenseAssignments            = cmLogic.GetAllExpenseAssignmentsForJob(jobId);
            List <ExpenseViewModel> expensesToDisplay = new List <ExpenseViewModel>();

            foreach (JobExpenseDTO ea in matchingExpenseAssignments)
            {
                ExpenseViewModel expense = new ExpenseViewModel();
                expense.ExpenseName = ea.Expense.Name;
                expense.ExpenseCost = ea.Expense.Cost.ToString();

                expensesToDisplay.Add(expense);
            }

            model.AllExpensesForJob = expensesToDisplay;

            //Pass in job id from URL
            model.JobId = jobId;

            return(View(model));
        }
Ejemplo n.º 8
0
        public ActionResult Result(int statusCode, string message)
        {
            DashboardViewModel model = new DashboardViewModel();

            string       UserId  = User.Identity.GetUserId();
            LogicService cmLogic = new LogicService();

            //Get jobs for user for dashboard view model
            model.ClientsForUser.ClientsToDisplay = cmLogic.GetClientsForUser(UserId);
            var jobsForUser = cmLogic.GetJobsForUser(UserId);

            //Remove any completed jobs
            var incompleteJobs = jobsForUser.Where(j => j.Complete == false).ToList();

            //Remove any jobs with a start date greater than 30 days from now
            var upcomingJobs = incompleteJobs.Where(j => ((j.StartDate >= DateTime.Now) && (j.StartDate < DateTime.Now.AddDays(30)))).ToList();

            //Sort jobs by start date
            List <jobDTO> sortedJobsForUser = new List <jobDTO>();

            sortedJobsForUser = upcomingJobs.OrderBy(j => j.StartDate).ToList();
            model.JobsForUser.JobsToDisplay = sortedJobsForUser;
            model.statusCode = statusCode;
            model.message    = message;

            return(View(model));
        }
Ejemplo n.º 9
0
        public ActionResult CompleteJob(CompleteJobViewModel model)
        {
            string       userId  = User.Identity.GetUserId();
            LogicService cmLogic = new LogicService();

            //Send expense to logic
            bool expenseAdded = cmLogic.AddExpense(model.ExpenseToAdd.ExpenseName, model.ExpenseToAdd.ExpenseCost);

            if (expenseAdded)
            {
                //Add assign new expense to current job
                string expenseId       = cmLogic.GetExpenseIdByName(model.ExpenseToAdd.ExpenseName);
                bool   expenseAssigned = cmLogic.AssignExpense(model.JobId, expenseId, userId);

                if (expenseAssigned)
                {
                    return(RedirectToAction("CompleteJob", "Jobs", new { jobId = model.JobId }));
                }

                else
                {
                    return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Failed To Assign Expense" }));
                }
            }

            else
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Failed To Add Expense" }));
            }
        }
Ejemplo n.º 10
0
        public ActionResult ScheduleJob(AddJobViewModel model)
        {
            string userId = User.Identity.GetUserId();

            //Construct date time to send to logic
            DateTime startDateTime = new DateTime(
                int.Parse(model.JobData.Year),
                int.Parse(model.JobData.Month),
                int.Parse(model.JobData.Day),
                int.Parse(model.JobData.Hour),
                int.Parse(model.JobData.Minute),
                0
                );

            //Send new data to logic layer
            LogicService cmLogic          = new LogicService();
            bool         addedSucessfully = cmLogic.ScheduleJob(
                startDateTime,
                int.Parse(model.JobData.Duration),
                model.JobData.Notes,
                userId,
                model.JobOptions.SelectedClient,
                model.JobOptions.SelectedServiceType);

            //Redirect back to dashbaord, print results to screen
            if (addedSucessfully)
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 0, message = "Job Added Successfully" }));
            }
            else
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Failed To Add Job" }));
            }
        }
Ejemplo n.º 11
0
        public MainWindow()
        {
            InitializeComponent();
            _startGameService = new StartGameService();
            _logicService     = new LogicService(_startGameService.TableDominoCollection,
                                                 _startGameService.MyDominosCollection, _startGameService.BankService);

            _startGameService.MyDominosCollection.Dominos.ForEach(d =>
            {
                d.ImageResource = $"Images/_{d.First}v{d.Second}_.png";
            });
            MyHandListView.ItemsSource = _startGameService.MyDominosCollection.Dominos;
            var startDomino = _startGameService.TableDominoCollection.Dominos.First();

            ////////////////////
            TopTableListView.ItemsSource   = _startGameService.TableDominoCollection.TopDominos;
            LeftTableListView.ItemsSource  = _startGameService.TableDominoCollection.LeftDominos;
            RightTableListView.ItemsSource = _startGameService.TableDominoCollection.RightDominos;
            BotTableListView.ItemsSource   = _startGameService.TableDominoCollection.BottomDominos;
            ////////////////////
            OpponentHandListView.ItemsSource = _startGameService.OpponentDominosCollection.Dominos;
            BankListView.ItemsSource         = _startGameService.AllDominos;

            _aIService = new AIService(new LogicService(_startGameService.TableDominoCollection,
                                                        _startGameService.OpponentDominosCollection, _startGameService.BankService));
            _aIService.AiTurnFinished += AiService_AiTurnFinished;

            RefreshAllItemSources();
        }
Ejemplo n.º 12
0
        public ActionResult ViewJob(int jobId)
        {
            string UserId = User.Identity.GetUserId();

            var          model   = new JobViewModel();
            LogicService cmLogic = new LogicService();

            //Check if job is completed
            bool jobCompleted = cmLogic.JobCompletionStatus(jobId.ToString(), UserId);

            if (!jobCompleted)
            {
                //Acquire job from logic
                var jobsForUser = cmLogic.GetJobsForUser(UserId);
                var matchingJob = jobsForUser.Where(j => j.Id == jobId);

                if (matchingJob.Count() > 0)
                {
                    var job = matchingJob.First();

                    model.ServiceType = job.type.Name;
                    model.ClientName  = job.client.Name;
                    model.Duration    = job.EstimatedDuration.ToString();
                    model.Notes       = job.Notes;
                    model.Completed   = job.Complete ? "Complete" : "Incomplete";
                    model.StartDate   = job.StartDate;
                    model.JobId       = job.Id.ToString();

                    return(View(model));
                }

                else
                {
                    return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Unable To Access Job Information" }));
                }
            }

            else
            {
                //Generate invoice for job
                Invoice jobInvoice = cmLogic.GetJobInvoice(jobId.ToString(), UserId);

                if (jobInvoice != null)
                {
                    //Display invoice for job
                    model.JobInvoice = jobInvoice;

                    return(View(model));
                }

                else
                {
                    return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Unable To Access Job Information" }));
                }
            }
        }
Ejemplo n.º 13
0
        private static async void MakePlanes()
        {
            for (int i = 0; i < 100000; i++)
            {
                await Task.Delay(2000);

                Plane a = _simulator.MakeNewPlanes();
                LogicService.SetStation(_station);
                _station.AddingNewPlane(a);
            }
        }
Ejemplo n.º 14
0
        public void Init()
        {
            var kernel = new StandardKernel();

            kernel.Load <LogicModule>();
            kernel.RegisterEasyNetQ("host=localhost");

            var lService = new LogicService(
                kernel.Get <IServiceFactory>(),
                kernel.Get <IMapper>(),
                kernel.Get <IValidator <SearchRequest> >());

            srController = new SearchRequestController(lService, kernel.Get <IBus>());
        }
Ejemplo n.º 15
0
        public OwnedAppInfoViewModel Load(long steamID, long appID, LogicService logicService)
        {
            SteamUserDetails = logicService.SteamLogic.GetByUserID(steamID, reloadWishlistPrices: true);
            List <UserAppPlaytime> recents = logicService.SteamLogic.GetRecentlyPlayedGames(steamID);

            if (recents.Any())
            {
                UserAppPlaytime recent = recents.SingleOrDefault(x => x.AppID == appID);
                UserAppPlaytime = recent;
            }
            OwnedApp = SteamUserDetails.OwnedApps.SingleOrDefault(x => x.AppID == appID);
            Stats    = logicService.SteamLogic.GetByUserAndAppID(steamID, appID);
            return(this);
        }
Ejemplo n.º 16
0
        private ConsoleAction readMode; // for distinguishing between various ways of reading input

        public DiagnosticConsole()
        {
            InitializeComponent();

            Text = "Prolog diagnostic console";

            stop         = null;
            semaGetInput = new ManualResetEvent(false);
            charBuffer   = new Queue <int>();
            winIO        = new WinIO(this, charBuffer);
            bgwExecuteQuery.ReportProgress((int)ConsoleAction.BtnsOff);
            service  = new LogicService(winIO);
            readMode = ConsoleAction.None;
        }
Ejemplo n.º 17
0
		public static int BetRequest(JObject gameState)
		{
			try
			{
				Game game = gameState.ToObject<Game>();
			
				return LogicService.Bet(game);
			}
			catch (Exception e)
			{
				Console.WriteLine(gameState);
				Console.WriteLine(e);
				return Int32.MaxValue;
			}
		}
Ejemplo n.º 18
0
        private static void Main(string[] args)
        {
            _simulator = new SimulatorPlane.SimulatorPlane();
            _station   = new StationManager();
            StationManager.LoadingLists();
            StationManager.UpdateStations();

            MakePlanes();

            using (ServiceHost hosting = new ServiceHost(typeof(LogicService)))
            {
                hosting.Open();
                LogicService.SetStation(_station);
                Console.WriteLine($"Host started  {DateTime.Now}");
                Console.ReadLine();
            }
        }
Ejemplo n.º 19
0
        public ActionResult ViewClient(int clientId)
        {
            string UserId = User.Identity.GetUserId();

            var          model   = new ClientViewModel();
            LogicService cmLogic = new LogicService();

            //Acquire client
            var clientsForUser = cmLogic.GetClientsForUser(UserId);
            var matchingClient = clientsForUser.Where(cl => cl.Id == clientId);

            //Acquire jobs for client
            var jobsForUser           = cmLogic.GetJobsForUser(UserId);
            var matchingJobsForClient = jobsForUser.Where(j => j.ClientId == clientId);

            //Split list into complete and incomplete lists
            var jobsForClientComplete   = matchingJobsForClient.Where(j => j.Complete == true);
            var jobsForClientIncomplete = matchingJobsForClient.Where(j => j.Complete == false);

            //Sort jobs by start date
            var sortedJobsForClientComplete   = jobsForClientComplete.OrderBy(j => j.StartDate).Reverse().ToList();
            var sortedJobsForClientIncomplete = jobsForClientIncomplete.OrderBy(j => j.StartDate).ToList();

            if (matchingClient.Count() > 0)
            {
                var client = matchingClient.First();

                model.Name                    = client.Name;
                model.Email                   = client.Email;
                model.PhoneNumber             = client.PhoneNumber;
                model.StreetAddress           = client.Address.Street;
                model.City                    = client.Address.City;
                model.State                   = client.Address.State;
                model.Zip                     = client.Address.Zip;
                model.JobsForClientComplete   = sortedJobsForClientComplete;
                model.JobsForClientIncomplete = sortedJobsForClientIncomplete;

                return(View(model));
            }

            else
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Unable To Access Client Information" }));
            }
        }
Ejemplo n.º 20
0
        public void CompareTwoDates_MethodCompareDateAndWriteDatesRange(string[] inputArray, string expected)
        {
            List <DateTime> dateTimes = new List <DateTime>();

            //Arrange
            foreach (var date in inputArray)
            {
                dateTimes.Add(DateTime.ParseExact(date, "dd.MM.yyyy",
                                                  CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal));
            }

            //Act
            ILogicService logicService = new LogicService();
            string        actual       = logicService.CompareTwoDates(dateTimes);

            //Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 21
0
        public ActionResult AddServiceType(ServiceTypeViewModel model)
        {
            string userId = User.Identity.GetUserId();

            //Send new data to logic layer
            LogicService cmLogic          = new LogicService();
            bool         addedSucessfully = cmLogic.AddServiceType(model.ServiceName, decimal.Parse(model.HourlyRate), userId);

            //Redirect back to dashbaord, print results to screen
            if (addedSucessfully)
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 0, message = "Service Type Added Successfully" }));
            }
            else
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Failed To Add Service Type" }));
            }
        }
Ejemplo n.º 22
0
        public ActionResult UpdateUser()
        {
            //Load default data into view model for user
            UpdateUserViewModel model   = new UpdateUserViewModel();
            LogicService        cmLogic = new LogicService();

            string      userId      = User.Identity.GetUserId();
            AspNetUsers currentUser = cmLogic.GetUserById(userId);

            model.CompanyName = currentUser.Name;
            model.Email       = currentUser.Email;
            model.PhoneNumber = currentUser.PhoneNumber;
            model.Street      = currentUser.StreetAddress;
            model.City        = currentUser.City;
            model.State       = currentUser.State;
            model.Zip         = currentUser.Zip;

            return(View(model));
        }
Ejemplo n.º 23
0
        public LogicServiceTest(TestFixture <Startup> fixture)
        {
            mapper = (IMapper)fixture.Server.Host.Services.GetService(typeof(IMapper));
            var configurationBuilder = new ConfigurationBuilder();
            var path = Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json");

            configurationBuilder.AddJsonFile(path, false);

            var root          = configurationBuilder.Build();
            var sqlConnection = root.GetConnectionString("DefaultConnection");

            var optionsBuilder = new DbContextOptionsBuilder <EcovadisContext>();

            optionsBuilder.UseSqlServer <EcovadisContext>(sqlConnection);

            icontext = new EcovadisContext(optionsBuilder.Options);
            var logic = new LogicService();
            var error = new ErrorHandler();

            game = new GameService(logic, mapper, error, icontext);
        }
Ejemplo n.º 24
0
    void Update()
    {
        input.Update();

        if (inputModel.isDragging)
        {
            World clone = LogicService.CloneWorldWithoutBullets(model);

            Position shootDir = input.GetShootDir();
            Position leftDir  = (shootDir + Position.RotateLeft(shootDir) * Config.SPREAD).Normalize();
            Position rightDir = (shootDir + Position.RotateRight(shootDir) * Config.SPREAD).Normalize();

            LogicService.ShootBullet(clone, shootDir);
            LogicService.ShootBullet(clone, leftDir);
            LogicService.ShootBullet(clone, rightDir);

            List <Position> predictionPoints = new List <Position>();
            for (int i = 0; i < Config.PREDICTION_STEPS; i++)
            {
                for (int j = 0; j < 1; j++)
                {
                    LogicService.Tick(clone);
                }

                foreach (var b in clone.bullets.Values)
                {
                    predictionPoints.Add(b.pos);
                }
            }

            ViewService.DrawPredictionPoints(view, predictionPoints);

            var p1 = Camera.main.ScreenToWorldPoint(inputModel.startDragPos);
            p1.y -= 0.5f;
            var p2 = Camera.main.ScreenToWorldPoint(inputModel.currentDragPos);
            p2.y -= 0.5f;

            ViewService.DrawInputUI(view, p1, p2);
        }
    }
Ejemplo n.º 25
0
        public ActionResult ScheduleJob()
        {
            var model = new AddJobViewModel();

            //Populate list box for displaying Service Type selection
            LogicService cmLogic = new LogicService();

            List <SelectListItem> clientSelection = new List <SelectListItem>();
            var clientOptions = cmLogic.GetClientsForUser(User.Identity.GetUserId());

            foreach (ClientDTO c in clientOptions)
            {
                SelectListItem selectItem = new SelectListItem()
                {
                    Text = c.Name, Value = c.Name
                };
                clientSelection.Add(selectItem);
            }
            model.JobOptions.ClientOptions = clientSelection;


            //Populate dropdown for displaying Client selection
            List <SelectListItem> serviceTypeSelection = new List <SelectListItem>();
            var serviceTypeOptions = cmLogic.GetServiceTypes();

            foreach (ServiceTypeDTO st in serviceTypeOptions)
            {
                SelectListItem selectItem = new SelectListItem()
                {
                    Text = st.Name, Value = st.Name
                };
                serviceTypeSelection.Add(selectItem);
            }
            model.JobOptions.ServiceTypeOptions = serviceTypeSelection;


            //Return updated view model with selection lists for service types and clients

            return(View(model));
        }
Ejemplo n.º 26
0
        private MatchController CreateController()
        {
            var imapper              = (IMapper)fixture.Server.Host.Services.GetService(typeof(IMapper));
            var ierrorHandler        = (IErrorHandler)fixture.Server.Host.Services.GetService(typeof(IErrorHandler));
            var configurationBuilder = new ConfigurationBuilder();
            var path = Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json");

            configurationBuilder.AddJsonFile(path, false);

            var root          = configurationBuilder.Build();
            var sqlConnection = root.GetConnectionString("DefaultConnection");

            var optionsBuilder = new DbContextOptionsBuilder <EcovadisContext>();

            optionsBuilder.UseSqlServer <EcovadisContext>(sqlConnection);

            var icontext = new EcovadisContext(optionsBuilder.Options);

            var logic = new LogicService();
            var error = new ErrorHandler();
            var game  = new GameService(logic, imapper, error, icontext);

            return(new MatchController(ierrorHandler, game));
        }
Ejemplo n.º 27
0
 public SteamController(IOptions <AppSettings> appSettings, UnitOfWork uow, LogicService logicService)
 {
     _appSettings  = appSettings.Value;
     _uow          = uow;
     _logicService = logicService;
 }
Ejemplo n.º 28
0
 public LogInFacade()
 {
     _checkingService      = new CheckingService();
     _logicService         = new LogicService();
     _callThePoliceService = new CallThePoliceService();
 }
Ejemplo n.º 29
0
        public static void Main(string[] args)
        {
            LogicService service = new LogicService();

            service.SetUp();
        }
Ejemplo n.º 30
0
 public SteamController(LogicService logicService)
 {
     _logicService = logicService;
 }