public HttpResponseMessage AddWorker([FromBody] User value)
 {
     if (ModelState.IsValid || ModelState["ManagerId"] == null)
     {
         return((ManagerLogic.AddUser(value)) ?
                new HttpResponseMessage(HttpStatusCode.Created)
         {
             Content = new ObjectContent <bool>(true, new JsonMediaTypeFormatter())
         } :
                new HttpResponseMessage(HttpStatusCode.BadRequest)
         {
             Content = new ObjectContent <String>("Can not add to DB", new JsonMediaTypeFormatter())
         });
     }
     return(Global.ErrorList(ModelState));
 }
Esempio n. 2
0
 public HttpResponseMessage AddWorker([FromBody] User value)
 {
     //curl -v -X POST -H "Content-type: application/json" -d "{\"Name\":\"Gila\",\"UserName\":\"gggg\",\"Password\":\"gggggg\",\"JobId\":\"4\",\"EMail\":\"safdsa@fdsaf\",\"ManagerId\":\"11\"}"  http://localhost:59628/api/addWorker
     //
     if (ModelState.IsValid)
     {
         return((ManagerLogic.AddUser(value)) ?
                new HttpResponseMessage(HttpStatusCode.Created)
         {
             Content = new ObjectContent <bool>(true, new JsonMediaTypeFormatter())
         }:
                new HttpResponseMessage(HttpStatusCode.BadRequest)
         {
             Content = new ObjectContent <String>("Can not add to DB", new JsonMediaTypeFormatter())
         });
     }
     return(Global.ErrorList(ModelState));
 }