public async Task <IActionResult> Post([FromBody] site_housing entity) { try { if (!isValid(entity)) { return(new BadRequestResult()); } var loggedInMember = LoggedInUser(); if (loggedInMember == null) { return(new BadRequestObjectResult("Invalid input parameters")); } entity.last_updated = DateTime.Now; entity.last_updated_by = loggedInMember.member_id; //sm(agent.Messages); return(Ok(await agent.Add <site_housing>(entity))); } catch (Exception ex) { //sm(agent.Messages); return(await HandleExceptionAsync(ex)); } }
public async Task Post() { //Arrange var entity = new site_housing() { site_housing_id = 3, site_id = 654, housing_type_id = 1 }; //Act var response = await controller.Post(entity); // Assert var okResult = Assert.IsType <OkObjectResult>(response); var result = Assert.IsType <site_housing>(okResult.Value); Assert.Equal(654, result.site_id); }