public async Task <HttpResponseMessage> PostRegister_dependentAsync_fcp([FromBody] dependant_fcp dependant_obj_fcp) { try { using (hcp_apiEntities6 entities = new hcp_apiEntities6()) { entities.dependant_fcp.Add(dependant_obj_fcp); if (await GetValidateAsync(dependant_obj_fcp.national_id, Convert.ToDateTime(dependant_obj_fcp.dob), dependant_obj_fcp.surname) == "1") { entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, dependant_obj_fcp); message.Headers.Location = new Uri(Request.RequestUri + dependant_obj_fcp.national_id.ToString()); return(message); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Wrong user")); } } } catch (System.Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); // throw; } }
public dependant GetDependent(string national_id) { try { using (hcp_apiEntities6 entities = new hcp_apiEntities6()) { return(entities.dependants.FirstOrDefault(x => x.national_id == national_id)); } } catch (System.Exception ex) { throw; } }
public registered Getprincipals(string national_id) { try { using (hcp_apiEntities6 entities = new hcp_apiEntities6()) { return(entities.registereds.FirstOrDefault(e => e.national_id == national_id)); } } catch (System.Exception ex) { throw; } }
public IHttpActionResult PostRegister_ChurchAsync_fcp([FromBody] registered_fcp regi_obj_fcp) { try { using (hcp_apiEntities6 entities = new hcp_apiEntities6()) { using (SqlConnection sqlCon = new SqlConnection(obj.locate1)) { sqlCon.Open(); string query = "UPDATE registered set church = '" + regi_obj_fcp.church + "' where phone_number = '" + regi_obj_fcp.phone_number.Trim() + "'"; SqlCommand sqlCmd = new SqlCommand(query, sqlCon); sqlCmd.ExecuteNonQuery(); } var message = Request.CreateResponse(HttpStatusCode.Created, regi_obj_fcp); message.Headers.Location = new Uri(Request.RequestUri + regi_obj_fcp.church.ToString()); return(Ok("Registered")); } } catch (System.Exception ex) { return(Ok(ex.ToString())); // throw; } }