public async Task<IHttpActionResult> PutProjects(string id, Projects projects) { if (!ModelState.IsValid) { return BadRequest(ModelState); } try { await _ProjectsService.Update( id,projects ); } catch (Exception exp) { //if (!await ProjectsExists(id)) //{ // return NotFound(); //} //else //{ throw exp; //} } return StatusCode(HttpStatusCode.NoContent); }
public void should_succeed_if_projects_id_is_set_to_Mongodb_objectId() { var pservice = new ProjectsService(); var pcontroller = new ProjectsController(pservice); pcontroller.Request = new HttpRequestMessage(); pcontroller.Configuration = new HttpConfiguration(); var p = new Projects { title= "eTimeSheet3", code="ET3" }; var res = pcontroller.PostProjects(p); //Projects project; //Assert.IsTrue(res.TryGetContentValue<Projects>(out project)); // Assert.AreEqual(project.Id , ! null); }
public IHttpActionResult PostProjects(Projects projects) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _ProjectsService.Create(projects); return CreatedAtRoute("DefaultApi", new { id = projects.Id}, projects); }