// The id parameter name should match the DataKeyNames value set on the control public void gvJobPostings_DeleteItem(Posting posting) { using (var context = new CareersContext()) { context.Entry(posting).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } }
public void fvCareerCategory_InsertItem(CareerCategory category) { var item = new bmi.imis.MABanker.Careers.Models.CareerCategory(); var context = new CareersContext(); context.Categories.Add(category); context.SaveChanges(); HttpContext.Current.Session["Categories"] = null; }
// The id parameter name should match the DataKeyNames value set on the control public void gvCareerCategories_UpdateItem(CareerCategory category) { using (var context = new CareersContext()) { context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); HttpContext.Current.Session["Categories"] = null; } }
// The id parameter name should match the DataKeyNames value set on the control public void dgCareerCategories_DeleteItem(int Id) { using (var context = new CareersContext()) { var career = context.Categories.Where(c => c.Id == Id).Select(c => c).FirstOrDefault(); if (career != null) { context.Categories.Remove(career); context.SaveChanges(); HttpContext.Current.Session["Categories"] = null; } } gvCareerCategories.DataBind(); }
// The id parameter name should match the DataKeyNames value set on the control public void gvResumes_DeleteItem(int resumeID) { using (var context = new CareersContext()) { var resume = (from r in context.Resumes where r.ResumeID == resumeID select r).SingleOrDefault(); var resumeBinary = (from r in context.ResumeBinaries where r.ResumeID == resumeID select r).SingleOrDefault(); context.Entry(resumeBinary).State = System.Data.Entity.EntityState.Deleted; context.Entry(resume).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } }
// The id parameter name should match the DataKeyNames value set on the control public void fvResume_UpdateItem(Resume resume) { var fileUploadResume = (FileUpload)fvResume.FindControl("fuResume"); using (var context = new CareersContext()) { Resume retrievedResume; retrievedResume = context.Resumes.Find(resume.ResumeID); ResumeBinary resumeBinary; if (resume.ResumeID != 0) { TryUpdateModel(retrievedResume); if (retrievedResume.ResumeBinary == null) { resumeBinary = new ResumeBinary(); retrievedResume.ResumeBinary = resumeBinary; } else resumeBinary = retrievedResume.ResumeBinary; } else { resume.ResumeBinary = new ResumeBinary(); resumeBinary = resume.ResumeBinary; } if (fileUploadResume.HasFile) { resumeBinary.ResumeBytes = fileUploadResume.FileBytes; resumeBinary.ContentType = fileUploadResume.PostedFile.ContentType; resumeBinary.FileName = System.IO.Path.GetFileName(fileUploadResume.PostedFile.FileName); } if (resume.ResumeID == 0) context.Entry(resume).State = System.Data.Entity.EntityState.Added; else context.Entry(retrievedResume).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } if (IsStaffUser) Response.Redirect(Request.Url.AbsolutePath + "?ResumeId=" + resume.ResumeID.ToString()); else { fvResume.Visible = false; pnlConfirmation.Visible = true; } }
protected void btnFileDelete_Click(object sender, EventArgs e) { using (var context = new CareersContext()) { int id = int.Parse((sender as Button).CommandArgument); var resumeBinary = (from rb in context.ResumeBinaries where rb.ResumeID == id select rb).FirstOrDefault(); if (resumeBinary != null) { context.Entry(resumeBinary).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); ((FileUpload)fvResume.FindControl("fuResume")).Visible = true; ((LinkButton)fvResume.FindControl("lnkDownload")).Visible = false; ((Button)fvResume.FindControl("btnFileDelete")).Visible = false; } } }
private void UpdatePosting(Posting posting) { using (var context = new CareersContext()) { if (posting.JobID == 0 && !IsStaffUser && PostingCredits <= 0) Response.Redirect(Request.Url.AbsoluteUri); bool decrementJobCredits = false; var postDateString = string.Empty; DateTime postDate; var postDateTextbox = (TextBox)fvJobPosting.FindControl("txtPostDate"); if (postDateTextbox.Text != null && DateTime.TryParse(postDateTextbox.Text, out postDate)) posting.PostDate = postDate; else posting.PostDate = null; if (posting.JobID == 0) { context.Entry(posting).State = System.Data.Entity.EntityState.Added; if (!IsStaffUser) decrementJobCredits = true; } else context.Entry(posting).State = System.Data.Entity.EntityState.Modified; if (posting.Approved == false) SendUnapprovedNotification(posting); context.SaveChanges(); if (decrementJobCredits) PostingCredits = PostingCredits - 1; } Response.Redirect(Request.Url.AbsolutePath + "?PostingId=" + posting.JobID.ToString()); }