示例#1
0
        /// <summary>
        /// This event fires when the user click on the Cancel Button
        ///     It turns off all the controls to make up Crews
        ///     It deletes the crew that is currently being formed
        ///     It refreshes the Current Crews List
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Cancel_Click(object sender, EventArgs e)
        {
            EmployeeGridView.Visible = false;
            SelectUnitDDL.Visible    = false;
            FleetCategory.ClearSelection();
            Done.Visible          = false;
            Cancel.Visible        = false;
            CreateCrew.Visible    = false;
            MakeCrew.Visible      = true;
            LastCrews.Visible     = true;
            FleetCategory.Visible = false;

            //Deletes the crew in formation.
            InfoUserControl.TryRun(() =>
            {
                if (!string.IsNullOrEmpty(CrewID.Text))
                {
                    int crewId = int.Parse(CrewID.Text);
                    CrewController crewManager = new CrewController();
                    crewManager.DeleteCrew(crewId);
                    CrewID.Text = "";
                    RefreshCurrentCrews();
                }
            });
        }
        public async Task ShouldUpdateCrewName()
        {
            // Create 2 crews
            await CreateCrew(_crewName2);
            await CreateCrew(_crewName3);

            // Update one
            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            CrewVm crewNewData = new CrewVm
            {
                CrewId   = 2,
                CrewName = "New Name"
            };

            await crewController.UpdateCrewAsync(crewNewData);

            // Check that only one has been changed
            Crew crew1 = _dbContext.Crews.Find(2);

            Assert.AreEqual(crewNewData.CrewName, crew1.Name);

            Crew crew2 = _dbContext.Crews.Find(3);

            Assert.AreEqual(crew2.Name, _crewName3);
        }
示例#3
0
        private void deleteCrewButton_Click(object sender, EventArgs e)
        {
            if (crewsDataGridView.SelectedRows.Count == 0)
            {
                crewWarningLabel.Visible = true;
            }
            else
            {
                crewWarningLabel.Visible = false;
                DataGridViewRow selectedRow = crewsDataGridView.SelectedRows[0];
                int             crewId      = (int)selectedRow.Cells["crewidDataGridViewTextBoxColumn"].Value;

                DialogResult dialogResult = MessageBox.Show("Удалить выбранный экипаж?", "Подтверждение удаления", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    CrewController crewController = new CrewController(crewId);
                    int            result         = crewController.Delete();
                    if (result == 0)
                    {
                        MessageBox.Show("Ошибка выполнения удаления");
                    }

                    FillTables();
                    ShowRowsCountEverywhere();
                }
            }
        }
示例#4
0
        /// <summary>
        /// This event fires when the user clicks on save unit report
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UnitReoprtGV_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string command = e.CommandName;

            if (command == "SaveUnitReport")
            {
                int         crewId = int.Parse(e.CommandArgument.ToString());
                GridViewRow row    = ((e.CommandSource as LinkButton).NamingContainer) as GridViewRow; //Gets hold of the GridViewRow
                string      KS     = ((row.FindControl("KM_Start") as TextBox).Text);
                string      KE     = ((row.FindControl("KM_End") as TextBox).Text);

                int    KmStart = string.IsNullOrEmpty(KS) ? 0 : int.Parse(KS);
                int    KmEnd   = string.IsNullOrEmpty(KE) ? 0 : int.Parse(KE);
                string comment = (row.FindControl("Comment") as TextBox).Text;

                string crew = (row.FindControl("Unit") as Label).Text;

                InfoUserControl.TryRun(() =>
                {
                    CrewController crewManager = new CrewController();
                    crewManager.UpdateCrew(crewId, KmStart, KmEnd, comment);

                    PopulateUnitReport();
                }, crew + " was updated successfully!");
            }
        }
示例#5
0
        /// <summary>
        /// This event fires when the user clicks on the calendar image or the save icon
        ///     It populates the calendar control
        ///     It updates a job card
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void JobCardStatusGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string command = e.CommandName.ToString();

            switch (command)
            {
            case "ChangeDate":

                GridViewRow row      = ((e.CommandSource as ImageButton).NamingContainer) as GridViewRow;
                Calendar    calendar = row.FindControl("Calendar") as Calendar;
                calendar.Visible = true;
                ImageButton image = row.FindControl("CalendarImage") as ImageButton;
                image.Visible = false;
                break;

            case "SaveJobCard":
                GridViewRow gridRow       = ((e.CommandSource as LinkButton).NamingContainer) as GridViewRow; //Gets hold of the GridViewRow
                int         jobCardId     = int.Parse(e.CommandArgument.ToString());
                string      completedDate = (gridRow.FindControl("CompletedDate") as TextBox).Text;

                CrewController crewManager = new CrewController();
                crewManager.UpdateJobCard(jobCardId, completedDate);

                PopulateRouteStatus();
                RefreshCurrentCrews();
                break;
            }
        }
        public async Task LocalSetup()
        {
            var serviceProvider = new ServiceCollection().AddLogging().BuildServiceProvider();
            var logger          = serviceProvider.GetService <ILoggerFactory>().CreateLogger <UserManager <ApplicationUser> >();

            UserStore <ApplicationUser> store = new UserStore <ApplicationUser>(_dbContext);

            _userManager = new UserManager <ApplicationUser>(store, null, new PasswordHasher <ApplicationUser>(), null, null, null, null, null, logger);

            _securityService    = new SecurityService(_dbContext, _userManager, _roleManager);
            _securityController = new SecurityController(_securityService);
            SetUser(_securityController, _createdUser2.Entity.Id);
            _crew = _dbContext.Crews.Find(1);

            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);
            await crewController.AddCrewLeaderAsync(_crew.Id, _createdUser2.Entity.Id);

            await _securityController.SetPoliciesAsync(
                new List <CrewPermissionsVm> {
                new CrewPermissionsVm {
                    Name = "CheckInAdmin", Value = 0, CrewHasPermission = true
                },
                new CrewPermissionsVm {
                    Name = "CrewAdmin", Value = 1, CrewHasPermission = true
                }
            },
                _crew.Id
                );
        }
        public void StartUp()
        {
            var optionsBuilder = new DbContextOptionsBuilder <AirportContext>();

            optionsBuilder.UseSqlServer(@"Server = (localdb)\mssqllocaldb; Database = AirportDB; Trusted_Connection = True; ConnectRetryCount = 0");
            _context = new AirportContext(optionsBuilder.Options);
            _mapper  = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <TicketDTO, Ticket>()
                .ForMember(x => x.Id, opt => opt.Ignore());
                cfg.CreateMap <Ticket, TicketDTO>();
                cfg.CreateMap <CrewDTO, Crew>()
                .ForMember(i => i.Id, opt => opt.Ignore())
                .ForMember(i => i.Stewardesses, opt => opt.Ignore())
                .ForMember(i => i.Pilot, opt => opt.Ignore());
                cfg.CreateMap <Crew, CrewDTO>()
                .ForMember(i => i.StewardessesId, opt => opt.MapFrom(m => m.Stewardesses.Select(s => s.Id)))
                .ForMember(i => i.PilotId, opt => opt.MapFrom(m => m.Pilot.Id));
                cfg.CreateMap <Ticket, TicketDTO>();
            }).CreateMapper();
            _uow              = new UnitOfWork(_context);
            _ticketService    = new TicketService(_uow, _mapper);
            _crewService      = new CrewService(_uow, _mapper);
            _crewController   = new CrewController(_crewService);
            _ticketController = new TicketController(_ticketService);
        }
        public async Task ShouldDeleteCrew()
        {
            // Create 2 crews
            await CreateCrew(_crewName2);
            await CreateCrew(_crewName3);

            // Delete the first
            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            CrewVm crewVm = new CrewVm
            {
                CrewId = 2
            };

            await crewController.DeleteCrewAsync(crewVm);

            // Check that we have deleted only one
            // Check that the others still has data
            Crew crew1 = _dbContext.Crews.Find(1);

            Assert.IsNotNull(crew1);
            Crew crew2 = _dbContext.Crews.Find(2);

            Assert.IsNull(crew2);
            Crew crew3 = _dbContext.Crews.Find(3);

            Assert.IsNotNull(crew3);
            Assert.AreEqual(_crewName3, crew3.Name);
        }
示例#9
0
        protected void AssignDriver()
        {
            string category = (FleetCategory.SelectedIndex < 0) ? "" : FleetCategory.SelectedItem.Text.Trim();

            int driverId = 0;

            //Retrieve the selected DriverID
            foreach (GridViewRow row in EmployeeGridView.Rows)
            {
                if ((row.FindControl("SelectedDriver") as RadioButton).Checked == true)
                {
                    driverId = int.Parse((row.FindControl("EmployeeID") as Label).Text);
                }
            }

            //Checks that a driver is selecetd. then proceed
            if (driverId == 0)
            {
                InfoUserControl.ShowInfo("Please select a driver");
            }
            else
            {
                CrewController crewManager = new CrewController();
                InfoUserControl.TryRun(() =>
                {
                    crewManager.CreateCrew(int.Parse(SelectUnitDDL.SelectedValue), driverId, category);
                    List <CurrentCrews> crews = crewManager.GetCurrentCrews(int.Parse(YardID.Text));
                    crews.Sort((x, y) => y.CrewID.CompareTo(x.CrewID));
                    CrewID.Text = crews.Count <= 0 ? "" : (crews[0].CrewID).ToString();
                    CloseCrewPane();
                });

                PopulateUnitReport();
            }
        }
示例#10
0
 // Start is called before the first frame update
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
示例#11
0
        // Helper methods
        private async Task <ActionResult> CreateCrew(string crewName)
        {
            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            SetUser(crewController, _createdUser1.Entity.Id);

            return(await crewController.CreateCrewAsync(crewName));
        }
示例#12
0
    public List <GameObject> GetSlots(CrewController controller)
    {
        List <GameObject> list = new List <GameObject>();

        foreach (var item in controller.characters)
        {
            list.Add(item.gameObject);
        }
        return(list);
    }
示例#13
0
 void SetupPlayer()
 {
     MainChar       = false;
     crewController = FindObjectOfType <CrewController>();
     moveController = FindObjectOfType <MoveController>();
     anim           = GetComponent <Animator>();
     aIDestination  = GetComponent <AIDestinationSetter>();
     aiPath         = GetComponent <AIPath>();
     position       = crewController.GetNextFreePosition(gameObject);
     Debug.Log("Player");
 }
示例#14
0
        /// <summary>
        /// This event fires when the user add a job site to a crew or click on the Finish button
        ///     When adding a job site to a crew, it first verifies that a crew is selected
        ///         Then add the Job site
        ///     When user click on the Finish button, it turns off the site menu and the Routes
        ///     It turns on the Job Cards GridView
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RouteListView_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            string message = "";
            string command = e.CommandName;

            switch (command)
            {
            case "AddSite":
                //Get hold of the row that fired the event
                ListViewDataItem item = RouteListView.Items[e.Item.DisplayIndex];
                DropDownList     list = item.FindControl("SelectTask") as DropDownList;

                InfoUserControl.TryRun(() =>
                {
                    if (string.IsNullOrEmpty(CrewID.Text))
                    {
                        InfoUserControl.ShowWarning("You must first create or select a Crew before adding a job site!");
                    }
                    else
                    {
                        int crewId = int.Parse(CrewID.Text);
                        int siteId = int.Parse(e.CommandArgument.ToString());
                        int taskId = int.Parse(list.SelectedValue);

                        CrewController crewManager = new CrewController();
                        message = crewManager.AddJobCard(crewId, siteId, taskId);
                        RefreshCurrentCrews();
                    }
                });

                if (!string.IsNullOrEmpty(message))
                {
                    InfoUserControl.ShowInfo("The following Crew(s) are already assigned to this same Site:  " + message);
                    RefreshCurrentCrews();
                }
                break;

            case "Finish":
                SiteMenu.Visible      = false;
                RouteListView.Visible = false;
                PopulateRouteStatus();
                PopulateUnitReport();
                MakeCrew.Visible      = true;
                LastCrews.Visible     = true;
                FleetCategory.Visible = false;

                ARoute.CssClass = "default-tab";
                BRoute.CssClass = "default-tab";
                GRoute.CssClass = "default-tab";
                WRoute.CssClass = "default-tab";
                PRoute.CssClass = "default-tab";
                break;
            }
        }
示例#15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void AllCurrentCrews_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string caller = e.CommandName;

            switch (caller)
            {
            case "SelectedCrew":
                CrewID.Text = e.CommandArgument.ToString();
                string crew = "";
                SiteMenu.Visible = true;
                Done.Visible     = true;
                JobCardStatusGridView.Visible = false;
                JobcardTitle.Visible          = false;
                UnitReoprtGV.Visible          = false;
                UnitReportHeader.Visible      = false;
                InfoUserControl.TryRun(() =>
                {
                    FleetController fleet = new FleetController();
                    crew = fleet.GetUnitDescription(int.Parse(CrewID.Text));
                });
                InfoUserControl.ShowInfo("You are updating crew " + crew + "");
                RefreshCrewMember();
                break;

            case "RemoveMember":
                InfoUserControl.TryRun(() =>
                {
                    CrewController crewManager = new CrewController();
                    crewManager.RemoveCrewMember(int.Parse(e.CommandArgument.ToString()), int.Parse(CrewID.Text));
                    RefreshCurrentCrews();
                });
                break;

            case "DeleteJobCard":
                InfoUserControl.TryRun(() =>
                {
                    CrewController crewManager = new CrewController();
                    crewManager.DeleteJobCardCrew(int.Parse(e.CommandArgument.ToString()));
                    RefreshCurrentCrews();
                });
                break;

            case "DeleteCrew":
                MessageUserControl.TryRun(() =>
                {
                    CrewController crewManager = new CrewController();
                    crewManager.DeleteCrew(int.Parse(e.CommandArgument.ToString()));
                    RefreshCurrentCrews();
                    PopulateUnitReport();
                    PopulateRouteStatus();
                });
                break;
            }
        }
示例#16
0
 /// <summary>
 /// This methods Populates/Refreshes the list of all Current Crews
 ///     It also returns the ID of the last crew created and set on a Label control
 /// </summary>
 protected void RefreshCurrentCrews()
 {
     InfoUserControl.TryRun(() =>
     {
         CrewController crewManager = new CrewController();
         List <CurrentCrews> crews  = crewManager.GetCurrentCrews(int.Parse(YardID.Text));
         crews.Sort((x, y) => y.CrewID.CompareTo(x.CrewID));
         AllCurrentCrews.DataSource = crews;
         AllCurrentCrews.DataBind();
     });
 }
示例#17
0
        public void GetById_Negative_ArgumentException()
        {
            //Arrange
            ICrewRepository crewRepository = new CrewRepository();
            ICrewService    crewService    = new CrewService(crewRepository);
            CrewController  crewController = new CrewController(crewService);

            const int NegativeId = -1;

            //Act & Assert
            Assert.ThrowsExceptionAsync <ArgumentException>(() => crewController.GetById(NegativeId));
        }
示例#18
0
 public void Awake()
 {
     if (Instance == null)
     {
         Instance    = this;
         crewMembers = new List <CrewMember>();
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
示例#19
0
        public void ShouldNotGetCrewMembersFromCrewWithInvalidId()
        {
            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            var ex = Assert.ThrowsAsync <HttpException>(async() =>
            {
                ActionResult <List <CrewMembersListVm> > result = await crewController.GetCrewMembersAsync(123);
            });

            Assert.That(ex.Message == "Fant ikke arbeidslaget med ID: 123");
        }
示例#20
0
 /// <summary>
 /// This event add a new member to a given crew
 ///     It calls the method that adds a new crew member to a crew
 ///     It refreshes the list of current crews
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void EmployeeGridView_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "AddMember")
     {
         InfoUserControl.TryRun(() =>
         {
             CrewController crewManager = new CrewController();
             crewManager.AddCrewMember(int.Parse(CrewID.Text), int.Parse(e.CommandArgument.ToString()));
             RefreshCurrentCrews();
         });
     }
 }
示例#21
0
        public void ShouldNotGetCrewByIdIfDoesntExist()
        {
            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            var ex = Assert.ThrowsAsync <HttpException>(async() =>
            {
                ActionResult <CrewVm> result = await crewController.GetCrewAsync(123);
            });

            Assert.That(ex.Message == "Fant ikke arbeidslaget med id 123");
        }
示例#22
0
        public async Task ShouldGetCrewLeders()
        {
            Crew crew1 = _dbContext.Crews.Find(1);

            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            ActionResult <List <CrewMembersListVm> > result = await crewController.GetCrewLeadersAsync(crew1.Id);

            List <CrewMembersListVm> returnedCrewLeaders = (List <CrewMembersListVm>)((OkObjectResult)result.Result).Value;

            Assert.AreEqual(1, returnedCrewLeaders.Count);
            Assert.AreEqual(_createdUser2.Entity.Id, returnedCrewLeaders[0].Id);
        }
示例#23
0
        public void ShouldNotUpdateCrewIfDoesntExist()
        {
            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            var ex = Assert.ThrowsAsync <HttpException>(async() =>
            {
                ActionResult <CrewVm> result = await crewController.UpdateCrewAsync(new CrewVm {
                    CrewId = 123, CrewName = "New Name"
                });
            });

            Assert.That(ex.Message == "Fant ikke arbeidslaget: New Name");
        }
示例#24
0
        public async Task ShouldCheckIfAUserIsAMemberOfACrew()
        {
            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            SetUser(crewController, _createdUser1.Entity.Id);

            ActionResult <List <CrewListVm> > result = await crewController.GetCrewsUserIsMemberOfAsync();

            List <CrewListVm> returnedCrewLeaders = (List <CrewListVm>)((OkObjectResult)result.Result).Value;

            Assert.AreEqual(1, returnedCrewLeaders.Count);
            Assert.AreEqual(1, returnedCrewLeaders[0].Id);
        }
示例#25
0
        public async Task ShouldNotCreateCrewIfNameAlreadyUsed()
        {
            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            await CreateCrew(_crewName2);

            var ex = Assert.ThrowsAsync <HttpException>(async() =>
            {
                ActionResult <CrewVm> result = await CreateCrew(_crewName2);
            });

            Assert.That(ex.Message == "Arbeidslaget: Test Crew 2 eksisterer allerede");
        }
    public void GetProjectCrewsBySpecTest()
    {
        // arrange
        const String ExpectedOutput = "";
        int          projectId      = 1;
        int          seasonId       = 2;
        int          episodeId      = 3;

        // act
        var crewController = new CrewController();
        var resultList     = crewController.GetProjectCrewsBySpec(1, 2, 3) as DataSourceResult;
        var someInsideData = resultlist.FirstOrDefault().GetType().GetProperty("PropertyName").GetValue(resultList.FirstOrDefault(), null);

        // assert
        Assert.AreEqual(someInsideData, ExpectedOutput);
    }
示例#27
0
    // Start is called before the first frame update
    void Start()
    {
        crewController  = FindObjectOfType <CrewController>();
        crewSlots       = GetSlots(crewController);
        segmentV        = new Vector3[crewSlots.Count];
        segmentPoses    = new Vector3[crewSlots.Count];
        segmentPoses[0] = crewSlots[0].transform.position;
        for (int i = 1; i < segmentPoses.Length; i++)
        {
            Vector3 targetPos = segmentPoses[i - 1] + (segmentPoses[i] - segmentPoses[i - 1]).normalized * targetDist;



            segmentPoses[i] = Vector3.SmoothDamp(segmentPoses[i], targetPos, ref segmentV[i], smoothSpeed);
            //segmentPoses[i] = Vector3.SmoothDamp(segmentPoses[i], segmentPoses[i-1] + (-targetDir.right) * targetDist, ref segmentV[i], smoothSpeed);
        }
        //UpdatePositions(segmentPoses);
    }
示例#28
0
        private void addCrewButton_Click(object sender, EventArgs e)
        {
            int      maxId    = dataController.GetMaxId(crewsDataTable, "crew_id");
            CrewForm crewForm = new CrewForm(crewsDataTable.NewRow(), false, maxId);

            if (crewForm.ShowDialog() == DialogResult.OK)
            {
                CrewController crewController = new CrewController(crewForm.Row);
                int            result         = crewController.Insert();
                if (result == 0)
                {
                    MessageBox.Show("Ошибка выполнения вставки");
                }

                FillTables();
                ShowRowsCountEverywhere();
            }
        }
示例#29
0
 /// <summary>
 /// This method populates JobCards
 /// </summary>
 public void PopulateRouteStatus()
 {
     InfoUserControl.TryRun(() =>
     {
         CrewController crewManager       = new CrewController();
         List <JobCardStatus> cardStatus  = crewManager.Get_JobCardStatus();
         JobCardStatusGridView.DataSource = cardStatus;
         JobCardStatusGridView.DataBind();
         if (cardStatus.Count > 0)
         {
             JobCardStatusGridView.Visible = true;
             JobcardTitle.Visible          = true;
         }
         else
         {
             JobCardStatusGridView.Visible = false;
             JobcardTitle.Visible          = false;
         }
     });
 }
示例#30
0
        public async Task ShouldGetCrews()
        {
            // Create 2 crews
            await CreateCrew(_crewName2);
            await CreateCrew(_crewName3);

            // Check that the list contains both
            CrewService    crewService    = new CrewService(_dbContext, _mainEventProvider);
            CrewController crewController = new CrewController(crewService);

            ActionResult <List <CrewListVm> > result = await crewController.GetCrewsAsync();

            List <CrewListVm> returnedCrews = (List <CrewListVm>)((OkObjectResult)result.Result).Value;

            // There was already 1 crew from BaseTest + we have created 2 crews
            Assert.AreEqual(3, returnedCrews.Count);
            Assert.AreEqual(2, returnedCrews[1].Id);
            Assert.AreEqual(_crewName2, returnedCrews[1].Name);
            Assert.AreEqual(3, returnedCrews[2].Id);
            Assert.AreEqual(_crewName3, returnedCrews[2].Name);
        }