/// <summary> /// Updates / Inserts new Employer /// </summary> /// <param name="employer"></param> /// <returns></returns> public int UpsertEmployer(tblEmployer employer) { if (employer.EmployerID == 0) //new record { try { dc.tblEmployers.InsertOnSubmit(employer); dc.SubmitChanges(); var Id = employer.EmployerID; employer.UserID = GenerateUserID(Id, UserType.Employer); UpsertEmployer(employer); //2nd call updates the UserID return(Id); } catch (Exception ex) { throw ex; } } else //update { try { var record = dc.tblEmployers.FirstOrDefault(x => x.EmployerID == employer.EmployerID); record = employer; dc.SubmitChanges(); return(record.EmployerID); } catch (Exception ex) { throw ex; } } }
public void EmployerUpdate(Guid employerId) { try { using (ITIndeedEntities dc = new ITIndeedEntities()) { tblEmployer employer = dc.tblEmployers.Where(e => e.Id == employerId).FirstOrDefault(); tblUser user = dc.tblUsers.Where(u => u.Id == employer.UserId).FirstOrDefault(); if (employer != null && user != null) { employer.RepresentativeFirstName = (this.RepresentativeFirstName == null) ? employer.RepresentativeFirstName : this.RepresentativeFirstName; employer.RepresentativeLastName = (this.RepresentativeLastName == null) ? employer.RepresentativeLastName : this.RepresentativeLastName; employer.Phone = (this.Phone == null) ? employer.Phone: this.Phone; employer.Email = (this.Email == null) ? employer.Email : this.Email; employer.Industry = (this.Industry == null) ? employer.Industry : this.Industry; employer.OrganizationName = (this.OrganizationName == null) ? employer.OrganizationName: this.OrganizationName; user.UserName = (this.UserName == null) ? user.UserName : this.UserName; user.Password = (this.Password == null) ? user.Password: this.Password; employer.ProfilePicture = (this.ProfilePicture == null) ? employer.ProfilePicture: this.ProfilePicture; dc.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
public ActionResult UpdateEmployer(int id) { tblEmployer tbe = _db.tblEmployers.Where(a => a.EmployerId == id).FirstOrDefault(); EmployerViewModel evm = new EmployerViewModel(); evm.EmployerId = tbe.EmployerId; evm.CompanyName = tbe.CompanyName; evm.CompanyDetails = tbe.CompanyDetails; evm.ContactPerson = tbe.ContactPerson; evm.Phone = tbe.Phone; evm.Email = tbe.Email; evm.CompanyWebsite = tbe.CompanyWebsite; evm.Location = tbe.Location; evm.Logo = tbe.Logo; evm.UserId = tbe.UserId; return(View(evm)); }
public ActionResult PostJob(JobViewModel jvm) { string user = User.Identity.Name; tblUser tb = _db.tblUsers.Where(a => a.Username == user).FirstOrDefault(); tblEmployer tbe = _db.tblEmployers.Where(b => b.UserId == tb.UserId).FirstOrDefault(); tblJob tbj = new tblJob(); tbj.CategoryId = jvm.CategoryId; tbj.EmployerId = tbe.EmployerId; tbj.SalaryRange = jvm.SalaryRange; tbj.JobType = jvm.JobType; tbj.JobDetails = jvm.JobDetails; tbj.isFeaturedJob = jvm.isFeaturedJob; tbj.PostedDate = DateTime.Now; tbj.ExpiryDate = jvm.ExpiryDate; _db.tblJobs.Add(tbj); _db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult EmployerProfile() { string usr = User.Identity.Name; int usrid = _db.tblUsers.Where(a => a.Username == usr).FirstOrDefault().UserId; tblEmployer tbe = _db.tblEmployers.Where(a => a.UserId == usrid).FirstOrDefault(); EmployerViewModel evm = new EmployerViewModel(); evm.EmployerId = tbe.EmployerId; evm.CompanyName = tbe.CompanyName; evm.CompanyDetails = tbe.CompanyDetails; evm.ContactPerson = tbe.ContactPerson; evm.Phone = tbe.Phone; evm.Email = tbe.Email; evm.CompanyWebsite = tbe.CompanyWebsite; evm.Location = tbe.Location; evm.Logo = tbe.Logo; evm.UserId = tbe.UserId; return(View(evm)); }
public void EmployerDelete() { try { using (ITIndeedEntities dc = new ITIndeedEntities()) { tblEmployer employer = dc.tblEmployers.Where(e => e.Id == this.EmployerId).FirstOrDefault(); tblUser user = dc.tblUsers.Where(u => u.Id == employer.UserId).FirstOrDefault(); if (employer != null & user != null) { dc.tblEmployers.Remove(employer); dc.tblUsers.Remove(user); dc.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
public bool EmployerInsert() { try { using (ITIndeedEntities dc = new ITIndeedEntities()) { tblUser user = new tblUser(); user.UserName = this.UserName; user.Password = this.Password; this.UserInsert(); tblUser userGetUserId = dc.tblUsers.Where(u => u.UserName == this.UserName).FirstOrDefault(); Guid guidUserId = userGetUserId.Id; tblEmployer employer = new tblEmployer(); employer.Id = Guid.NewGuid(); employer.RepresentativeFirstName = this.RepresentativeFirstName; employer.RepresentativeLastName = this.RepresentativeLastName; employer.Phone = this.Phone; employer.Email = this.Email; employer.OrganizationName = this.OrganizationName; employer.Industry = this.Industry; employer.UserId = guidUserId; employer.ProfilePicture = this.ProfilePicture; dc.tblEmployers.Add(employer); dc.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }
public bool EmployerLoadUserById(Guid userId) { try { using (ITIndeedEntities dc = new ITIndeedEntities()) { tblEmployer employer = dc.tblEmployers.Where(e => e.UserId == userId).FirstOrDefault(); tblUser user = dc.tblUsers.Where(u => u.Id == employer.UserId).FirstOrDefault(); if (employer != null & user != null) { this.EmployerId = employer.Id; this.RepresentativeFirstName = employer.RepresentativeFirstName; this.RepresentativeLastName = employer.RepresentativeLastName; this.Phone = employer.Phone; this.Email = employer.Email; this.OrganizationName = employer.OrganizationName; this.Industry = employer.Industry; this.Password = user.Password; this.UserName = user.UserName; this.UserId = employer.UserId; this.ProfilePicture = employer.ProfilePicture; return(true); } else { return(false); } } } catch (Exception ex) { throw ex; } }
public ActionResult UpdateEmployer(EmployerViewModel evm) { tblEmployer tbe = _db.tblEmployers.Where(a => a.EmployerId == evm.EmployerId).FirstOrDefault(); tbe.CompanyName = evm.CompanyName; tbe.ContactPerson = evm.ContactPerson; tbe.Phone = evm.Phone; tbe.Email = evm.Email; tbe.CompanyWebsite = evm.CompanyWebsite; tbe.Location = evm.Location; tbe.CompanyDetails = evm.CompanyDetails; HttpPostedFileBase fup = Request.Files["Logo"]; if (fup != null) { if (fup.FileName != "") { tbe.Logo = fup.FileName; fup.SaveAs(Server.MapPath("~/CompanyLogo/" + fup.FileName)); } } _db.SaveChanges(); return(RedirectToAction("EmployerProfile", "Home")); }
public ActionResult EmployerSignUp(EmployerViewModel em) { if (ModelState.IsValid) { List <tblUser> lst = _db.tblUsers.Where(u => u.Username == em.Username).ToList(); if (lst.Count == 0) { if (em.Password != null) { if (em.Password != em.RetypePassword) { ViewBag.Message = "Password Mismatch"; } else { string password = encryptpass(em.Password); tblUser tbu = new tblUser(); tbu.Username = em.Username; tbu.Password = password; _db.tblUsers.Add(tbu); _db.SaveChanges(); tblUserRole tbur = new tblUserRole(); tbur.UserId = tbu.UserId; tbur.RoleId = 2; _db.tblUserRoles.Add(tbur); _db.SaveChanges(); tblEmployer tbe = new tblEmployer(); tbe.CompanyName = em.CompanyName; tbe.ContactPerson = em.ContactPerson; tbe.Phone = em.Phone; tbe.Email = em.Email; tbe.CompanyWebsite = em.CompanyWebsite; tbe.Location = em.Location; tbe.CompanyDetails = em.CompanyDetails; tbe.UserId = tbu.UserId; HttpPostedFileBase fup = Request.Files["Logo"]; if (fup != null) { if (fup.FileName != "") { tbe.Logo = fup.FileName; fup.SaveAs(Server.MapPath("~/CompanyLogo/" + fup.FileName)); } } _db.tblEmployers.Add(tbe); _db.SaveChanges(); ViewBag.Message = "Your Account was created successfully"; } } else { ViewBag.Message = "Password Field is empty"; } } else { ViewBag.Message = "Username already exists!!!"; } } return(View()); }