void SetUpPage(JobsAvailable job) { lblJobTitle.Text = job.Title; lblLocation.Text = job.Location; lblReference.Text = job.ReferenceID; lblDescription.Text = job.JobDescription; Title = job.Title; }
protected void Page_Load(object sender, EventArgs e) { if (Session["Name"] != null) { isLoggedIn = true; panLoggedIn.Visible = true; panNotLoggedIn.Visible = false; panSuccess.Visible = false; panEditSuccess.Visible = false; panEditFailure.Visible = false; panAddLocation.Visible = false; panAddSector.Visible = false; jobToEdit = FindJob(Request.QueryString["Id"]); FillLocations(); FillSectors(); if (jobToEdit != null) { isEditMode = true; btnAdd.Text = "Save"; lblTitle.Text = "Edit " + jobToEdit.Title; SetLocationDDL(jobToEdit.Location); SetSectorDDL(jobToEdit.JobSector); } else { btnAdd.Text = "Add Job"; lblTitle.Text = "Add a new job listing"; } if (!IsPostBack && isEditMode) { SetControlValues(); } } else { isLoggedIn = false; panLoggedIn.Visible = false; panNotLoggedIn.Visible = true; panSuccess.Visible = false; panEditSuccess.Visible = false; panEditFailure.Visible = false; panAddLocation.Visible = false; panAddSector.Visible = false; } }
void GetJob(int id) { DataClassesDataContext dc = new DataClassesDataContext(); job = null; foreach (JobsAvailable j in dc.JobsAvailables) { if (id == j.Id) { job = j; } } }
public bool CreateJob(JobCreate model) { var entity = new JobsAvailable() { OwnerId = _userId, TitleOfJob = model.TitleOfJob, Description = model.Description, Pay = model.Pay, EquipmentAvailable = model.EquipmentAvailable, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Jobs.Add(entity); return(ctx.SaveChanges() == 1); } }
protected void Page_Load(object sender, EventArgs e) { id = Convert.ToInt32(Request.QueryString["id"]); DataClassesDataContext dc = new DataClassesDataContext(); job = null; foreach (JobsAvailable j in dc.JobsAvailables) { if (id == j.Id) { job = j; } } if (job == null) { lblJobTitle.Text = "Job does not exist!"; } else { SetUpPage(job); } foreach (User user in dc.Users) { if (user.Id.ToString() == job.ConsultantID) { lblName.Text = user.FirstName + " " + user.LastName; lnkEmail.Text = user.Email; lnkEmail.NavigateUrl = "mailto:" + user.Email; lblNumber.Text = user.PhoneNo; } } }
protected void btnAdd_Click(object sender, EventArgs e) { if (isLoggedIn) { if (!isEditMode) { DataClassesDataContext dc = new DataClassesDataContext(); JobsAvailable job = new JobsAvailable() { Title = txtTitle.Text, ReferenceID = txtRefNo.Text, Location = ddlLocation.SelectedItem.ToString(), JobSector = ddlSectors.SelectedItem.ToString(), ShortDescription = txtShortDescription.Text, JobDescription = FreeTextBox1.Text, ConsultantID = Session["Name"].ToString(), ListedDate = DateTime.Now.Date }; dc.JobsAvailables.InsertOnSubmit(job); try { dc.SubmitChanges(); lblSuccess.Text = "Listing added successfully."; panSuccess.Visible = true; panLoggedIn.Visible = false; panNotLoggedIn.Visible = false; panEditSuccess.Visible = false; panEditFailure.Visible = false; panAddLocation.Visible = false; panAddSector.Visible = false; } catch (Exception ex) { lblSuccess.Text = "An error ocurred. Please try again."; panSuccess.Visible = true; panLoggedIn.Visible = false; panNotLoggedIn.Visible = false; panEditSuccess.Visible = false; panEditFailure.Visible = false; panAddLocation.Visible = false; panAddSector.Visible = false; } } else { // Update the job listing DataClassesDataContext dc = new DataClassesDataContext(); var result = from r in dc.JobsAvailables where r.Id == jobToEdit.Id select r; foreach (JobsAvailable j in result) { if (j.Id == jobToEdit.Id) { j.Title = txtTitle.Text; j.ReferenceID = txtRefNo.Text; j.Location = ddlLocation.SelectedItem.ToString(); j.JobSector = ddlSectors.SelectedItem.ToString(); j.ShortDescription = txtShortDescription.Text; j.JobDescription = FreeTextBox1.Text; j.ConsultantID = Session["Name"].ToString(); j.ListedDate = DateTime.Now.Date; } } try { dc.SubmitChanges(); lblEditSuccess.Text = "Listing updated successfully."; panSuccess.Visible = false; panLoggedIn.Visible = false; panNotLoggedIn.Visible = false; panEditSuccess.Visible = true; panEditFailure.Visible = false; panAddSector.Visible = false; } catch (Exception ex) { lblEditError.Text = ex.Message; panSuccess.Visible = false; panLoggedIn.Visible = false; panNotLoggedIn.Visible = false; panEditSuccess.Visible = false; panEditFailure.Visible = true; panAddSector.Visible = false; } } } }
partial void DeleteJobsAvailable(JobsAvailable instance);
partial void UpdateJobsAvailable(JobsAvailable instance);
partial void InsertJobsAvailable(JobsAvailable instance);