public IHttpActionResult PuttblUser(string id, tblUser tblUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblUser.EmailId) { return(BadRequest()); } db.Entry(tblUser).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tblUserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public HttpResponseMessage RejectFarmer(string message, tblFarmer farmer) { try { EmailModel mail = new EmailModel(); mail.to = farmer.fEmailId; mail.subject = "Application Rejected"; mail.body = "Your account not approved because of follwing reasons" + message + "Kindly register again"; HttpClient http = new HttpClient(); http.BaseAddress = new Uri("http://localhost:61674/api/Email"); var consumewebApi = http.PostAsJsonAsync <EmailModel>("email", mail); entities.Entry(farmer).State = System.Data.Entity.EntityState.Deleted; entities.SaveChanges(); } catch (Exception) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Email Not Found ")); } return(Request.CreateResponse(HttpStatusCode.OK)); }