Example #1
0
        public async void CreateAsync(UserCreateDTO user, String azureUId, ResponseLogic expected)
        {
            var existingUser = new User()
            {
                Id = 1, Firstname = "IAlready", Surname = "Exist", Mail = "*****@*****.**", AzureUId = "existingAuzreUId"
            };
            var existingLocation = new Location()
            {
                Id = 1, City = "Sydney", Country = "Australia"
            };

            userRepository     = new UserRepository(setupContextForIntegrationTests());
            skillRepository    = new SkillRepository(context);
            projectRepository  = new ProjectRepository(context);
            locationRepository = new LocationRepository(context);

            var locationLogic = new LocationLogic(locationRepository, userRepository, projectRepository);

            context.Users.Add(existingUser);
            context.Locations.Add(existingLocation);
            context.SaveChanges();

            //SanityCheck
            Assert.Equal(1, await context.Users.CountAsync());
            Assert.Equal(existingUser, await context.Users.FirstAsync());
            Assert.Equal(1, await context.Locations.CountAsync());
            Assert.Equal(existingLocation, await context.Locations.FirstAsync());

            using (var logic = new UserLogic(userRepository, skillLogicMock.Object, sparkLogicMock.Object, locationLogic))
            {
                var result = await logic.CreateAsync(user, azureUId);

                Assert.Equal(expected, result);
            }
        }
        private void loadDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "CSV|*.csv";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                DataTable csvDT = GetDataTabletFromCSVFile(ofd.FileName);
                int       expectedColumnCount = GlobalConfig.Connection.GetCustomQuestionCount(eventId) + 3;

                if (csvDT.Columns.Count < expectedColumnCount)
                {
                    MessageBox.Show($"You don't have enough responses I can only find {csvDT.Columns.Count} columns of data, but i am expecting { expectedColumnCount }");
                    return;
                }
                if (csvDT.Columns.Count > expectedColumnCount)
                {
                    MessageBox.Show("You don't have too many responses, maybe you have blank columns to right of data");
                    return;
                }
                DataTable ResponsesListDT = csvDT.Clone();


                //check csvDT rows
                if (ResponseLogic.CheckCSVData(csvDT, ref ResponsesListDT, eventId) == false)
                {
                    //If there are any errors with the data it will exit outbefore trying to load any data
                    //Error message is show by CheckCSVData
                    return;
                }


                DialogResult dr = MessageBox.Show("This will replace the responses for all clients on the spreadsheet \nThis will NOT affect responses for anyone not on the spreadsheet", "Press Yes to Continue", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    //Now that all the data has been checked
                    //Loop through the DataTable and load the data
                    ResponseLogic.LoadBasicReposnses(ResponsesListDT);
                    ResponseLogic.LoadCustomResponses(ResponsesListDT);
                    callingForm.RefreshAllInvitesListView();
                    MessageBox.Show("Data processed", "Load Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No data processed", "Load aborted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }