protected void AddNewJob(object sender, EventArgs e) { int empId = currentEmployer.Id_Employer; string jobType = JobbTyp.Value; string jobDesc = JobbBeskrivning.Value; string jobReg = Community.Value; string path = ""; if (FileUpload.PostedFile.ContentType == "image/jpeg") { path = "~/Images/JobPics/"; path += jobType + Convert.ToString(empId); path += Path.GetExtension(FileUpload.PostedFile.FileName); FileUpload.SaveAs(Server.MapPath(path)); StatusLbl.Text = "Upload status: File uploaded!"; }; Jobs job = new Jobs() { Id_Employer = empId, Type = jobType, Description = jobDesc, Region = jobReg, Image = path }; LuffarJobbDBEntities db = new LuffarJobbDBEntities(); db.Jobs.Add(job); db.SaveChanges(); StatusLbl.Text = "Jobbet är upplagt"; }
public static void AddBid(Bids bid) { using (LuffarJobbDBEntities db = new LuffarJobbDBEntities()) { db.Bids.Add(bid); db.SaveChanges(); } }
public static string RetEmpUsername(int id) { using (LuffarJobbDBEntities db = new LuffarJobbDBEntities()) { var q = from e in db.Employers where e.Id_Employer == id select e.UserName; return q.FirstOrDefault(); } }
public static int RetEmpId(string username) { using (LuffarJobbDBEntities db = new LuffarJobbDBEntities()) { var q = from e in db.Employers where e.UserName == username select e.Id_Employer; return q.FirstOrDefault(); } }
public static int GetLowestBid(int jobId) { using (LuffarJobbDBEntities db = new LuffarJobbDBEntities()) { var q = from b in db.Bids where b.Id_Job == jobId orderby b.Bid ascending select b.Bid; return q.FirstOrDefault(); } }
public static List<JobComments> GetJobComments(int jobId) { List<JobComments> jc = new List<JobComments>(); using (LuffarJobbDBEntities db = new LuffarJobbDBEntities()) { var q = from j in db.JobComments where j.Id_Job == jobId select j; jc.AddRange(q); } return jc; }
protected void RegLuffare(object sender, EventArgs e) { if (RegPasswordUser.Value == RegPasswordRptUser.Value) { WrongPwLblUser.Visible = false; Workers worker = new Workers(){ UserName = RegEmailUser.Value, Password = RegPasswordUser.Value }; LuffarJobbDBEntities db = new LuffarJobbDBEntities(); db.Workers.Add(worker); db.SaveChanges(); ConfirmationLblUser.Visible = true; Session["user"] = RegEmailUser.Value; Response.Redirect("Wrk_ViewJobs.aspx"); } else if (RegPasswordUser.Value != RegPasswordRptUser.Value) WrongPwLblUser.Visible = true; }
protected void SubmitRegEmployerBtn_OnServerClick(object sender, EventArgs e) { if (RegPasswordEmployer.Value == RegPasswordRptEmployer.Value) { WrongPwLblEmployer.Visible = false; Employers emp = new Employers(){ UserName = RegEmailEmployer.Value, Password = RegPasswordEmployer.Value }; LuffarJobbDBEntities db = new LuffarJobbDBEntities(); db.Employers.Add(emp); db.SaveChanges(); ConfirmationLblEmployer.Visible = true; Session["user"] = emp; Response.Redirect("Emp_AddJob.aspx"); } else if (RegPasswordEmployer.Value != RegPasswordRptEmployer.Value) WrongPwLblEmployer.Visible = true; }
public static Workers RetWork(string username) { using (LuffarJobbDBEntities db = new LuffarJobbDBEntities()) { var q = from w in db.Workers where w.UserName == username select w; return q.FirstOrDefault(); } }
public static Jobs RetJob(int id) { using (LuffarJobbDBEntities db = new LuffarJobbDBEntities()) { var q = from j in db.Jobs where j.Id_Job == id select j; return q.FirstOrDefault(); } }
public static void UpdateCurrentbid(int jobId, int bid) { using (LuffarJobbDBEntities db = new LuffarJobbDBEntities()) { Jobs q = (from j in db.Jobs where j.Id_Job == jobId select j).FirstOrDefault(); q.CurrentBid = bid; db.SaveChanges(); } }
protected void SubmitCommentBtn_OnClick(object sender, EventArgs e) { if (CommentTextArea.Value != null) { currentWorker = (Workers)Session["user"]; string comment = CommentTextArea.Value; string author = currentWorker.UserName; jobId = (int)Session["theJob"]; JobComments jc = new JobComments() { Comment = comment, Author = author, Id_Job = jobId }; LuffarJobbDBEntities db = new LuffarJobbDBEntities(); db.JobComments.Add(jc); db.SaveChanges(); CommentTextArea.Value = ""; Response.Redirect(Request.RawUrl); } else { ErrorInBidLbl.Text = "Kan inte göra en tom kommentar"; } }