コード例 #1
0
 public IHttpActionResult Put(Employee employee)
 {
     //if (ModelState.IsValid)
     //{
     //    employeeObjBs.Update(employee);
     //    return Ok(employee);
     //}
     //else
     //    return BadRequest(ModelState);
     if (ModelState.IsValid)
     {
         if (employeeObjBs.Update(employee))
         {
             return(Ok(employee));
         }
         else
         {
             foreach (var error in employeeObjBs.Errors)
             {
                 ModelState.AddModelError("", error);
             }
             return(BadRequest(ModelState));
         }
     }
     else
     {
         return(BadRequest(ModelState));
     }
 }
コード例 #2
0
        public IHttpActionResult Put(Employee employee)
        {
            if (!(ModelState.IsValid && _employeeObjBs.Update(employee)))
            {
                return(SendBadRequest());
            }

            return(Ok(employee));
        }