コード例 #1
0
        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);
        }
コード例 #2
0
       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);
            
       }
コード例 #3
0
        public IHttpActionResult PostProjects(Projects projects)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            _ProjectsService.Create(projects);

            return CreatedAtRoute("DefaultApi", new { id = projects.Id}, projects);
        }