public HttpResponseMessage addvolunteer(Volunteer_table Vti) { try { // Your code... // Could also be before try if you know the exception occurs in SaveChanges dbe.Volunteer_table.Add(Vti); dbe.SaveChanges(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); throw; } return(Request.CreateResponse(HttpStatusCode.Accepted, "Volunteer Added Sucessfully")); }
public HttpResponseMessage volunteerlogin(string name, string password) { // var user = db.Logins.Where(x => x.Username == username && x.Password == password).FirstOrDefault(); Volunteer_table volunteer = dbe.Volunteer_table.Where(x => x.name == name && x.password == password).FirstOrDefault(); if (volunteer == null) { return(Request.CreateResponse(HttpStatusCode.OK, "notfound")); } else { try { return(Request.CreateResponse(HttpStatusCode.Accepted, volunteer)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); return(null); } } }