public IHttpActionResult PutJob_Type(int id, Job_Type job_Type) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != job_Type.Job_Type_ID) { return(BadRequest()); } db.Entry(job_Type).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Job_TypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetJob_Type(int id) { Job_Type job_Type = db.Job_Type.Find(id); if (job_Type == null) { return(NotFound()); } return(Ok(job_Type)); }
public IHttpActionResult PostJob_Type(Job_Type job_Type) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Job_Type.Add(job_Type); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = job_Type.Job_Type_ID }, job_Type)); }
protected void btnApply_Click(object sender, EventArgs e) { //open connection con.Open(); //Create and return SqlCommand SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; //Write query that selects everything from Add_Jobs Database where the JobId is the same as id cmd.CommandText = "select * from Add_JobsDB where JobId=" + id + ""; //Execute the nonquery cmd.ExecuteNonQuery(); //create a datatable instance DataTable dt = new DataTable(); //create a sql dataAdapter instance SqlDataAdapter da = new SqlDataAdapter(cmd); //add or refresh rows in the database da.Fill(dt); //for loop which gets the values from the database and displays them on to the web page foreach (DataRow dr in dt.Rows) { Job_Name = dr["Job_Name"].ToString(); Job_Type = dr["Job_Type"].ToString(); Job_Description = dr["Job_Description"].ToString(); Job_Address = dr["Job_Address"].ToString(); Job_Postcode = dr["Job_Postcode"].ToString(); Job_Image = dr["Job_Image"].ToString(); } //close connection con.Close(); //if cookies is null if (Request.Cookies["aa"] == null) { //create aa cookies and add cookies into the system from the database seperating with comma Response.Cookies["aa"].Value = Job_Name.ToString() + "," + Job_Type.ToString() + "," + Job_Description.ToString() + "," + Job_Address.ToString() + "," + Job_Postcode.ToString() + "," + Job_Image.ToString(); //clear cookies every 24 hours Response.Cookies["aa"].Expires = DateTime.Now.AddDays(1); } //else if there is a cookie that exists in the system already else { //request the cookies and devide them with pipe sign Response.Cookies["aa"].Value = Request.Cookies["aa"].Value + "|" + Job_Name.ToString() + "," + Job_Type.ToString() + "," + Job_Description.ToString() + "," + Job_Address.ToString() + "," + Job_Postcode.ToString() + "," + Job_Image.ToString(); //clear cookies every 24 hours Response.Cookies["aa"].Expires = DateTime.Now.AddDays(1); } //redirect the page to View_Jobs page Response.Redirect("View_Jobs.aspx"); }
public IHttpActionResult DeleteJob_Type(int id) { Job_Type job_Type = db.Job_Type.Find(id); if (job_Type == null) { return(NotFound()); } db.Job_Type.Remove(job_Type); db.SaveChanges(); return(Ok(job_Type)); }
public IHttpActionResult GetDesignID(int id) { List <dynamic> list = new List <dynamic>(); List <Design_Line> design_Lines = db.Design_Line.Where(x => x.Design_ID == id).ToList(); foreach (var design in design_Lines) { dynamic d = new ExpandoObject(); Job_Type job = db.Job_Type.Where(x => x.Job_Type_ID == design.Job_Type_ID).FirstOrDefault(); d.Template_Position_ID = design.Template_Position_ID; d.Job_Type_ID = job.Description; d.Width = design.Width; d.Height = design.Height; d.Image = design.Image; d.Text = design.Text; list.Add(d); } return(Ok(list)); }
public List <dynamic> getDesignLines(int id) { db.Configuration.ProxyCreationEnabled = false; List <Design_Line> lines = db.Design_Line.Where(x => x.Design_ID == id).ToList(); List <dynamic> list = new List <dynamic>(); foreach (var line in lines) { Template_Position template = db.Template_Position.Where(x => x.Template_Position_ID == line.Template_Position_ID).FirstOrDefault(); Job_Type job = db.Job_Type.Where(x => x.Job_Type_ID == line.Job_Type_ID).FirstOrDefault(); dynamic newObj = new ExpandoObject(); newObj.Position = template.Position_ID; newObj.JobType = job.Description; newObj.Text = line.Text; newObj.Width = line.Width; newObj.Height = line.Height; list.Add(newObj); } return(list); }
protected void Page_Load(object sender, EventArgs e) { //Declare the id vlaue id = Convert.ToInt32(Request.QueryString["id"].ToString()); //create a datatable instance DataTable dt = new DataTable(); //clear datatable rows dt.Rows.Clear(); //create a temporary data coloumn tables so that cookies data's could be stored on to the data coloumn table dt.Columns.AddRange(new DataColumn[7] { new DataColumn("Job_Name"), new DataColumn("Job_Type"), new DataColumn("Job_Description"), new DataColumn("Job_Address"), new DataColumn("Job_Postcode"), new DataColumn("Job_Image"), new DataColumn("id") }); //If there is cookies in the system if (Request.Cookies["aa"] != null) { //the cookies is stored in the s variable s = Convert.ToString(Request.Cookies["aa"].Value); //the records are split using the Pipe sign string[] strArr = s.Split('|'); //for loop to split the records using the comma sign for (int i = 0; i < strArr.Length; i++) { t = Convert.ToString(strArr[i].ToString()); string[] strArr1 = t.Split(','); for (int j = 0; j < strArr1.Length; j++) { //the record is stored in an array variable a[j] = strArr1[j].ToString(); } //the array variable value is passed on to the datatable dt.Rows.Add(a[0].ToString(), a[1].ToString(), a[2].ToString(), a[3].ToString(), a[4].ToString(), a[5].ToString(), i.ToString()); } } //remove record from the datatable dt.Rows.RemoveAt(id); //clear cookies Response.Cookies["aa"].Expires = DateTime.Now.AddDays(-1); //clear cookies Response.Cookies["aa"].Expires = DateTime.Now.AddDays(-1); //for loop table where the values are taken from the datatable and are stored in the variables foreach (DataRow dr in dt.Rows) { Job_Name = dr["Job_Name"].ToString(); Job_Type = dr["Job_Type"].ToString(); Job_Description = dr["Job_Description"].ToString(); Job_Address = dr["Job_Address"].ToString(); Job_Postcode = dr["Job_Postcode"].ToString(); Job_Image = dr["Job_Image"].ToString(); count = count + 1; if (count == 1) { //create aa cookies and add cookies into the system from the database seperating them with comma Response.Cookies["aa"].Value = Job_Name.ToString() + "," + Job_Type.ToString() + "," + Job_Description.ToString() + "," + Job_Address.ToString() + "," + Job_Postcode.ToString() + "," + Job_Image.ToString() + "," + id.ToString(); //clear cookies every 24 hours Response.Cookies["aa"].Expires = DateTime.Now.AddDays(1); } else { //request the cookies and devide them with pipe sign Response.Cookies["aa"].Value = Request.Cookies["aa"].Value + "|" + Job_Name.ToString() + "," + Job_Type.ToString() + "," + Job_Description.ToString() + "," + Job_Address.ToString() + "," + Job_Postcode.ToString() + "," + Job_Image.ToString() + "," + id.ToString(); //clear cookies every 24 hours Response.Cookies["aa"].Expires = DateTime.Now.AddDays(1); } } //redirect page to View_Jobs page Response.Redirect("View_Jobs.aspx"); }