Exemplo n.º 1
0
        public ActionResult Create(VacancyVM model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                var Employer = _empManager.GetUserAsync(User).Result;

                model.EmployerId = Employer.Id;

                var vacancy  = _mapper.Map <vacancy>(model);
                var isSucess = _repo.Create(vacancy);

                if (!isSucess)
                {
                    ModelState.AddModelError("", "Something went wrong...");
                    return(View(model));
                }



                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Something went wrong...");
                return(View(model));
            }
        }
Exemplo n.º 2
0
        public List <string> GetBreadCrumbs(VacancyVM model)
        {
            var breadcrumb = GetBreadCrumbs(model.Career, true);

            breadcrumb.Add(_helper.ActionLink <CenterController>(c =>
                                                                 c.Vacancies(null), "Вакансии").ToString());
            return(breadcrumb);
        }
Exemplo n.º 3
0
        public ActionResult Delete(int id, VacancyVM model)
        {
            try
            {
                var vacancy = _repo.FindById(id);
                if (vacancy == null)
                {
                    return(NotFound());
                }
                var isSucess = _repo.Delete(vacancy);
                if (!isSucess)
                {
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(model));
            }
        }
Exemplo n.º 4
0
        public ActionResult Edit(VacancyVM model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var Vacancy  = _mapper.Map <vacancy>(model);
                var isSucess = _repo.Update(Vacancy);
                if (!isSucess)
                {
                    ModelState.AddModelError("", "Something went wrong...");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Something went wrong...");
                return(View(model));
            }
        }
Exemplo n.º 5
0
        public ActionResult CreateVacancy(VacancyVM model, HttpPostedFileBase postedFile1, FormCollection form)
        {
            IStructuredetailRepository repo = new StructuredetailRepository();
            var city = new SelectList(new[]
            {
                new { ID = "1", Name = "Karachi" },
                new { ID = "2", Name = "Lahore" },
                new { ID = "3", Name = "Islamabad" }
            },
                                      "Name", "Name", "1"
                                      );

            ViewBag.getcitylist = city;


            var deplist = repo.Getdep().ToList();

            SelectList list = new SelectList(deplist, "DepartmentId", "DepartmentName");

            ViewBag.getdep1list = list;


            var levellist = new SelectList(new[]
            {
                new { ID = "1", Name = "1" },
                new { ID = "2", Name = "2" },
                new { ID = "3", Name = "3" },
                new { ID = "4", Name = "4" },
                new { ID = "5", Name = "5" }
            },
                                           "Name", "Name", "1"
                                           );

            ViewBag.getlevellist = levellist;



            if (postedFile1 == null)
            {
                ModelState.AddModelError("CustomError", "Please select Test");
            }

            else if (!(postedFile1.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document" || postedFile1.ContentType == "application/pdf"))
            {
                ModelState.AddModelError("CustomError", "Only .docx and .pdf file allowed");
                return(View());
            }
            else if (postedFile1 != null)
            {
                string fileName1 = Guid.NewGuid() + Path.GetExtension(postedFile1.FileName);
                postedFile1.SaveAs(Path.Combine(Server.MapPath("~/TestPaper"), fileName1));

                var AddVacant = repo.Addvac(model.VacancyName, model.CityName, model.PositionId, model.DepartmentId, model.RequiredQualification, model.JobLevel, model.MarksCriteria, fileName1);
                repo.Addvacant(AddVacant);
                repo.Save();


                TempData["SuccessMessage11"] = "Vacancy Created";
            }
            return(View());
        }
Exemplo n.º 6
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxSchedule.Text))
            {
                MessageBox.Show("Введите шрафик работы", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(textBoxPosition.Text))
            {
                MessageBox.Show("Введите должность", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(textBoxSalary.Text))
            {
                MessageBox.Show("Введите зарплату", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (comboBoxFirm.SelectedValue == null)
            {
                MessageBox.Show("Выберите фирму", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            try
            {
                VacancyBM vacancy = new VacancyBM
                {
                    Id       = id,
                    Schedule = textBoxSchedule.Text,
                    Position = textBoxPosition.Text,
                    Salary   = Convert.ToInt32(textBoxSalary.Text),
                    FirmId   = Convert.ToInt32(comboBoxFirm.SelectedValue),
                };

                if (Vlogic.Read(null).Count != 0)
                {
                    VacancyVM currentVacancy = Vlogic.Read(new VacancyBM {
                        Id = id
                    })[0];
                    if (currentVacancy != null)
                    {
                        vacancy.Employment = currentVacancy.Employment;
                    }
                    else
                    {
                        vacancy.Employment = false;
                    }
                }

                Vlogic.CreateOrUpdate(vacancy);
                MessageBox.Show("Сохранение прошло успешно", "Сообщение",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 7
0
        private void DealForm_Load(object sender, EventArgs e)
        {
            try
            {
                List <EmployeeVM> Elist = Elogic.Read(null);
                if (Elist != null)
                {
                    comboBoxEmployee.DisplayMember = "Surname";
                    comboBoxEmployee.ValueMember   = "Id";
                    comboBoxEmployee.DataSource    = Elist;
                    comboBoxEmployee.SelectedItem  = null;
                }
                List <ApplicantVM> Alist = Alogic.Read(null);
                if (Alist != null)
                {
                    comboBoxApplicant.DisplayMember = "Surname";
                    comboBoxApplicant.ValueMember   = "Id";
                    comboBoxApplicant.DataSource    = Alist;
                    comboBoxApplicant.SelectedItem  = null;
                }
                List <VacancyVM> Vlist = Vlogic.Read(new VacancyBM {
                    Employment = false
                });
                if (Vlist != null)
                {
                    comboBoxVacancy.DisplayMember = "Position";
                    comboBoxVacancy.ValueMember   = "Id";
                    comboBoxVacancy.DataSource    = Vlist;
                    comboBoxVacancy.SelectedItem  = null;
                }
                if (id.HasValue)
                {
                    var view = Dlogic.Read(new DealBM {
                        Id = id
                    })?[0];
                    if (view != null)
                    {
                        dateTimePickerDate.Value = view.Date;

                        EmployeeVM employee = Elogic.Read(new EmployeeBM {
                            Id = view.EmployeeId
                        })?[0];
                        foreach (var currentEmployee in Elist)
                        {
                            if (currentEmployee.Id == employee.Id)
                            {
                                comboBoxEmployee.SelectedItem = currentEmployee;
                            }
                        }

                        ApplicantVM applicant = Alogic.Read(new ApplicantBM {
                            Id = view.ApplicantId
                        })?[0];
                        foreach (var currentApplicant in Alist)
                        {
                            if (currentApplicant.Id == applicant.Id)
                            {
                                comboBoxApplicant.SelectedItem = currentApplicant;
                            }
                        }
                        Vlist = Vlogic.Read(new VacancyBM {
                            Employment = true
                        });

                        VacancyVM vacancy = Vlogic.Read(new VacancyBM {
                            Id = view.VacancyId
                        })?[0];
                        foreach (var currentVacancy in Vlist)
                        {
                            if (currentVacancy.Id == vacancy.Id)
                            {
                                comboBoxVacancy.SelectedItem = currentVacancy;
                            }
                        }
                        Vlist = Vlogic.Read(new VacancyBM {
                            Employment = false
                        });
                        if (Elist != null)
                        {
                            comboBoxVacancy.DisplayMember = "Position";
                            comboBoxVacancy.ValueMember   = "Id";
                            comboBoxVacancy.DataSource    = Vlist;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }