public void RegisterResume(MyUser u, MyUserDetail my, MyEducation edu, MyJobExperience exp) { AddEducation(edu); AddJobExp(exp); int eduId = ctx.Educations.Max(e => e.Id); int expId = ctx.JobExperiences.Max(e => e.Id); my.Education = eduId; my.JobExperience = expId; UserDetail detail = new UserDetail(); detail.Header = my.Header; detail.Salary = my.Salary; detail.Description = my.Description; detail.EducationId = my.Education; detail.JobExperienceId = my.JobExperience; ctx.UserDetails.Add(detail); ctx.Users.First(u1 => u1.Id == u.Id).UserDetail = detail; ctx.SaveChanges(); }
public void AddUser(MyUser my, MyCompanyDetail companyDetail, MyUserDetail userDetail) { User u = new User(); u.Email = my.Email; u.Password = my.Password; u.Birthday = my.Birthday; u.Name = my.Name; u.Surname = my.Surname; u.FathersName = my.FathersName; u.Phone = my.Phone; u.CityId = GetCityIdByName(my.City); if (companyDetail != null) { AddCompanyDetail(companyDetail); int count = ctx.CompanyDetails.Count(); u.CompanyDetails = ctx.CompanyDetails.Max(d1 => d1.Id); } if (userDetail != null) { AddUserDetail(userDetail); int count = ctx.UserDetails.Count(); u.UserDetails = ctx.UserDetails.Max(d1 => d1.Id); } ctx.Users.Add(u); ctx.SaveChanges(); u.Id = ctx.Users.Max(user => user.Id); AddUserRoles(my, u); AddUserCategories(my, u); }
public MyUserDetail GetUserDetailById(int id) { UserDetail detail = ctx.UserDetails.First(d => d.Id == id); MyUserDetail my = new MyUserDetail(); my.Id = detail.Id; my.Header = detail.Header; my.Salary = detail.Salary; my.Description = detail.Description; if (detail.EducationId == null) { my.Education = -1; } else { my.Education = detail.EducationId.Value; } if (detail.JobExperienceId == null) { my.JobExperience = -1; } else { my.JobExperience = detail.JobExperienceId.Value; } return(my); }
public void AddUserDetail(MyUserDetail my) { ctx.UserDetails.Add(new UserDetail() { Header = my.Header, Description = my.Description, Salary = my.Salary }); ctx.SaveChanges(); }
public ActionResult Resume(int id) { MyUser my = manager.GetUserById(id); MyUserDetail d = manager.GetUserDetailById(my.UserDetails); ViewBag.User = my; ViewBag.Resume = d; ViewBag.Education = DBManager.DbManager.GetEducationByUserDetailId(d.Id); ViewBag.JobExp = DBManager.DbManager.GetJobExperienceByUserDetailId(d.Id); ViewBag.CurrentUser = this.Session["CurrentUser"]; return(View("Item")); }
public object GetPropertyValue(MyUserDetail my, string name) { PropertyInfo[] properties = my.GetType().GetProperties(); foreach (var i in properties) { if (i.Name == name) { return(i.GetValue(my)); } } return(null); }
protected void btnSubmit_Click(object sender, EventArgs e) { foreach (IValidator i in this.Validators) { i.Validate(); } if (IsValid) { MyUser my = new MyUser(); my.Email = userEmail.Text; my.Password = userPassword.Text; my.Birthday = DateTime.Parse(userBirthay.Value); my.Name = userName.Text; my.Surname = userSurname.Text; my.FathersName = userFathersName.Text; my.Phone = userPhone.Text; my.City = userCity.SelectedValue; my.Roles.Add(userManager.GetRoleIdByName("Employee")); MyUserDetail detail = new MyUserDetail(); List <string> categories = new List <string>(); foreach (ListItem i in userCategories.Items) { if (i.Selected) { categories.Add(i.Text); } } List <int> categoryId = new List <int>(); foreach (var c in categories) { categoryId.Add(userManager.GetCategoryIdByName(c)); } my.Categories = categoryId; userManager.AddUser(my, null, detail); Response.Redirect("~/SignIn.aspx"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { foreach (IValidator i in this.Validators) { i.Validate(); } if (IsValid) { MyUserDetail detail = new MyUserDetail(); MyJobExperience exp = new MyJobExperience(); MyEducation edu = new MyEducation(); detail.Header = txtVacancyHeader.Text; detail.Salary = Convert.ToDecimal(txtSalary.Text); detail.Description = txtDesc.Text; exp.Company = txtCompany.Text; exp.City = txtCity.Text; exp.Post = txtPost.Text; exp.Start = DateTime.Parse(txtStartDate.Text); exp.End = DateTime.Parse(txtEndDate.Text); exp.Desc = txtDesc.Text; edu.Level = dropEduLevel.SelectedValue; edu.Place = txtPlace.Text; edu.Speciality = txtSpeciality.Text; userManager.RegisterResume(user, detail, edu, exp); } else { txtCompany.Text = ""; txtCity.Text = ""; txtPost.Text = ""; txtStartDate.Text = ""; txtEndDate.Text = ""; txtDesc.Text = ""; } }
protected void btnSubmit_Click(object sender, EventArgs e) { foreach (IValidator i in this.Validators) { i.Validate(); } if (IsValid) { MyUserDataGrid my = new MyUserDataGrid(); my.Id = userToEdit.Id; my.Email = userToEdit.Email; my.Password = userToEdit.Password; my.Birthday = DateTime.Parse(userBirthay.Value); my.Name = userName.Text; my.Surname = userSurname.Text; my.FathersName = userFathersName.Text; my.Phone = userPhone.Text; my.City = userCity.SelectedValue; my.UserDetails = detail.Id; StringBuilder roles = new StringBuilder(); for (int i = 0; i < userToEdit.Roles.Count; i++) { if (i == userToEdit.Roles.Count - 1) { roles.Append(userManager.GetRoleNameById(userToEdit.Roles[i])); } else { roles.Append(userManager.GetRoleNameById(userToEdit.Roles[i]) + ", "); } } my.Roles = roles.ToString(); roles.Clear(); for (int i = 0; i < userCategories.Items.Count; i++) { if (userCategories.Items[i].Selected) { if (i == userCategories.Items.Count - 1) { roles.Append(userCategories.Items[i].Text); } else { roles.Append(userCategories.Items[i].Text + ", "); } } } my.Categories = roles.ToString(); userBase.Save(my); MyUserDetail ndetail = new MyUserDetail(); MyJobExperience nexp = new MyJobExperience(); MyEducation nedu = new MyEducation(); ndetail.Id = detail.Id; ndetail.Header = txtVacancyHeader.Text; ndetail.Salary = Convert.ToDecimal(txtSalary.Text); ndetail.Description = txtDesc.Text; ndetail.Education = edu.Id; ndetail.JobExperience = exp.Id; nexp.Id = exp.Id; nexp.Company = txtCompany.Text; nexp.City = txtCityExp.Text; nexp.Post = txtPost.Text; nexp.Start = DateTime.Parse(txtStartDate.Text); nexp.End = DateTime.Parse(txtEndDate.Text); nexp.Desc = txtDesc.Text; nedu.Id = edu.Id; nedu.Level = dropEduLevel.SelectedValue; nedu.Place = txtPlace.Text; nedu.Speciality = txtSpeciality.Text; userManager.EditEducation(nedu); userManager.EditJobExp(nexp); if (nedu.Id == -1 || nexp.Id == -1) { ndetail.Education = userManager.GetLastEduId(); ndetail.JobExperience = userManager.GetLastJobExpId(); } resumeBase.Save(ndetail); Response.Redirect("~/Employee"); } }
protected void Page_Load(object sender, EventArgs e) { userBase = (UserRepositoryBase)IoCContainer.ServiceLocator.Resolve <IRepository <MyUserDataGrid> >(); resumeBase = (ResumeRepositoryBase)IoCContainer.ServiceLocator.Resolve <IRepository <MyUserDetail> >(); userManager = IoCContainer.ServiceLocator.Resolve <IDbManager>(); userToEdit = this.Session["CurrentUser"] as MyUser; detail = userManager.GetUserDetailById(userToEdit.UserDetails); if (detail.JobExperience == -1) { exp = new MyJobExperience(); } else { exp = userManager.GetJobExpById(detail.JobExperience); } if (detail.Education == -1) { edu = new MyEducation(); } else { edu = userManager.GetEducationById(detail.Education); } if (!IsPostBack) { userCategories.DataSource = userManager.GetCategories().Select(c => c.Name).ToList(); userCategories.DataBind(); userCity.DataSource = userManager.GetCities(); userCity.DataBind(); userCity.SelectedValue = userToEdit.City; userBirthay.Value = userToEdit.Birthday.ToString("dd.mm.yyyy"); userName.Text = userToEdit.Name; userSurname.Text = userToEdit.Surname; userFathersName.Text = userToEdit.FathersName; userPhone.Text = userToEdit.Phone; txtVacancyHeader.Text = detail.Header; txtSalary.Text = detail.Salary.ToString(); txtSelfDesc.Text = detail.Description; txtCompany.Text = exp.Company; txtCityExp.Text = exp.City; txtPost.Text = exp.Post; txtStartDate.Text = exp.Start.ToShortDateString(); txtEndDate.Text = exp.End.ToShortDateString(); txtDesc.Text = exp.Desc; dropEduLevel.SelectedValue = edu.Level; txtPlace.Text = edu.Place; txtSpeciality.Text = edu.Speciality; foreach (ListItem i in userCategories.Items) { if (userToEdit.Categories.Contains(userManager.GetCategoryIdByName(i.Text))) { i.Selected = true; } } } }
protected void repUsers_ItemCommand1(object source, RepeaterCommandEventArgs e) { #region Delete if (e.CommandName == "Delete") { int id = Convert.ToInt32(e.CommandArgument); rep.Delete(id); UpdateData(); } #endregion #region Edit if (e.CommandName == "Edit") { int id = Convert.ToInt32(e.CommandArgument); MyUserDetail my = rep.GetEntityById(id) as MyUserDetail; for (int i = 0; i < e.Item.Controls.Count; i++) { TextBox t = e.Item.Controls[i] as TextBox; if (t != null) { t.Style.Add("display", "block"); object obj = GetPropertyValue(my, t.ToolTip); t.Text = ((obj == null) ? "" : obj.ToString()); } } int index = -1; for (int i = 0; i < repResumes.Items.Count; i++) { if (repResumes.Items[i] == e.Item) { index = i; } } ViewState.Add("EditedId", id); ViewState.Add("EditedIndex", index); btnSave.Style.Add("display", "inline"); btnCancel.Style.Add("display", "inline"); isEditing = true; } #endregion #region Add if (e.CommandName == "Add") { List <MyUserDetail> users = rep.GetAll(); MyUserDetail my = new MyUserDetail(); users.Add(my); repResumes.DataSource = users; repResumes.DataBind(); RepeaterItem item = repResumes.Items.OfType <RepeaterItem>().ElementAt(repResumes.Items.Count - 1); for (int i = 0; i < item.Controls.Count; i++) { TextBox t = item.Controls[i] as TextBox; if (t != null) { t.Style.Add("display", "block"); object obj = GetPropertyValue(my, t.ToolTip); t.Text = (obj == null) ? "" : obj.ToString(); } } int index = -1; for (int i = 0; i < repResumes.Items.Count; i++) { if (repResumes.Items[i] == item) { index = i; } } ViewState.Add("EditedId", -1); ViewState.Add("EditedIndex", index); btnSave.Style.Add("display", "inline"); btnCancel.Style.Add("display", "inline"); isEditing = true; } #endregion }
protected void btnSave_Click(object sender, EventArgs e) { this.Validate(); int index = Convert.ToInt32(ViewState["EditedIndex"]); int id = Convert.ToInt32(ViewState["EditedId"]); RepeaterItem item = repResumes.Items[index]; MyUserDetail my = new MyUserDetail(); if (id != -1) { my = rep.GetEntityById(id) as MyUserDetail; } for (int i = 0; i < item.Controls.Count; i++) { TextBox t = item.Controls[i] as TextBox; if (t != null) { string propName = t.ToolTip; switch (propName) { case "Header": if (my.Header != t.Text) { my.Header = t.Text; } break; case "Salary": if (my.Salary != Convert.ToDecimal(t.Text)) { my.Salary = Convert.ToDecimal(t.Text); } break; case "JobExperience": if (my.JobExperience != Convert.ToInt32(t.Text)) { my.JobExperience = Convert.ToInt32(t.Text); } break; case "Education": if (my.Education != Convert.ToInt32(t.Text)) { my.Education = Convert.ToInt32(t.Text); } break; case "Description": if (my.Description != t.Text) { my.Description = t.Text; } break; default: break; } t.Style.Add("display", "none"); } } rep.Save(my); ViewState.Add("EditedId", -1); ViewState.Add("EditedIndex", -1); btnSave.Style.Add("display", "none"); btnCancel.Style.Add("display", "none"); isEditing = false; UpdateData(); }