public void Validate_ShouldThrow_ArgumentOutOfRangeException_When_Hackathon_HasNoName() { // Arrange var hackathon = new Hackathon(); // Act & Assert Assert.Throws <ArgumentOutOfRangeException>(() => hackathon.ThrowIfInvalid()); }
//public IActionResult AddProblemStatements() public IActionResult Index(int hid) { ViewData["Name"] = HttpContext.Session.GetString("UName"); ViewData["Type"] = HttpContext.Session.GetString("Type"); TempData["id"] = hid; HackathonContext hackathonContext = HttpContext.RequestServices.GetService(typeof(HackathonContext)) as HackathonContext; Hackathon Selection = hackathonContext.GetByID(hid); ProblemStatementContext problemStatementContext = HttpContext.RequestServices.GetService(typeof(ProblemStatementContext)) as ProblemStatementContext; var SelectionPS = problemStatementContext.GetProblemStatementsById(hid); dynamic JointModel = new ExpandoObject(); JointModel.ProblemStatements = SelectionPS; JointModel.Hackathon = Selection; return(View(JointModel)); }
public async void GetHacakthon_ShouldReturnAnEmptyHackathon_When_HackathonIsNotFound() { var dto = new HackathonDTO(); var newHackathonID = 0; Hackathon hackathon = null; _hackathonRepositoryMock.Setup(x => x.GetHackathon(It.IsAny <int>())) .ReturnsAsync(hackathon); _hackathonService = new HackathonService(_hackathonRepositoryMock.Object, _mapperMock.Object); // Act var hackathonDto = await _hackathonService.GetHackathon(dto.ID); // Assert Assert.Equal(hackathonDto.ID, newHackathonID); }
public bool AddHackathon(dynamic UserHandle, Hackathon hackathon) { string query; if (UserHandle.Profile.Type != 'C') { return(false); } query = $"insert into hackathon(Title,Subtitle,Description,ContactMail,ContactPhone,ContactWebsite,CoverPhoto,ThumbNail,StartDate,EndDate)" + $" values('{hackathon.Title}','{hackathon.Subtitle}','{hackathon.Description}','{hackathon.ContactMail}'," + $"'{hackathon.ContactPhone}','{hackathon.ContactWebsite}','{hackathon.CoverPhoto}','{hackathon.Thumbnail}','{hackathon.StartDate}'" + $",'{hackathon.EndDate}')"; using (var connection = GetConnecton()) { connection.Open(); int id = 0; var command = new MySqlCommand(query, connection); if (command.ExecuteNonQuery() > 0) { query = $"select id from hackathon where Title='{hackathon.Title}'"; command = new MySqlCommand(query, connection); using (var read = command.ExecuteReader()) { while (read.Read()) { id = Convert.ToInt32(read["id"]); } } if (id != 0) { query = $"insert into hackathon_creator (Username,HackathonId) values ('{UserHandle.User.UserName}','{id}')"; command = new MySqlCommand(query, connection); return(command.ExecuteNonQuery() > 0 ? true : false); } return(false); } ; } return(false); }
public string CreateDoc(string databaseName) { string createDocApi = cloudantBaseUri + "/" + databaseName; Hackathon xhacknightHackathon = new Hackathon { Organiser = "XHackerCO", Venue = "", Time = new DateTime(2015, 08, 22), Sponsors = new List<string> { "Xamarin", "IBM" } }; HttpClient client = GetCloudantHttpClient(); StringContent content = new StringContent(JsonConvert.SerializeObject(xhacknightHackathon)); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); var response = client.PostAsync(createDocApi,content); return response.Result.Content.ReadAsStringAsync().Result; }
public async Task <Hackathon> CreateHackathon(Hackathon hackathon) { return(hackathon); }