Ejemplo n.º 1
0
 //[DisableCors]
 public IHttpActionResult Post([FromBody] Student val)
 {
     //return StudentsDB.GetStudentByEmailAndPassword(val.Email, val.Password);
     try
     {
         Student res = StudentsDB.InsertStudentToDb(val);
         if (res == null)
         {
             return(Content(HttpStatusCode.BadRequest, $"could not insert student {val.ToString()} or already exists !"));
         }
         return(Created(new Uri(Url.Link("GetStudentById", new { id = res.ID })), res));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }