async Task <Exam> InitByRecruitAsync(RecruitViewModel recruitView, List <RecruitViewModel> recruitViewList) { var rootRecruitView = recruitViewList.FirstOrDefault(x => x.Id == recruitView.ParentId); var exam = new Exam() { RecruitId = rootRecruitView.Id, SubjectId = recruitView.SubjectId, ExamType = ExamType.Recruit, RecruitExamType = RecruitExamType.Exactly, OptionType = recruitView.OptionType.ToOptionType() }; var parts = recruitView.SubItems; if (parts.HasItems()) { foreach (var part in parts) { var examPart = await InitExamPartAsync(part); exam.Parts.Add(examPart); } } else { var examPart = await InitExamPartAsync(recruitView); exam.Parts.Add(examPart); } exam.LoadPartTitles(); return(exam); }
public static Recruit MapEntity(this RecruitViewModel model, IMapper mapper, string currentUserId) { var entity = mapper.Map <RecruitViewModel, Recruit>(model); entity.Date = model.DateText.ToDatetimeOrNull(); if (model.Id == 0) { entity.SetCreated(currentUserId); foreach (var item in entity.SubItems) { item.SetCreated(currentUserId); } } else { entity.SetUpdated(currentUserId); foreach (var item in entity.SubItems) { item.SetUpdated(currentUserId); } } return(entity); }
public async Task <IActionResult> RecruitConfirm(RecruitViewModel model, string from) { var transferList = new List <TransferViewModel>(); foreach (var candidate in model.Candidates) { if (candidate.Selected) { transferList.Add(new TransferViewModel { ProjectId = model.ProjectId, ProjectName = model.ProjectName, DutyId = candidate.RecruitDutyId, EmployeeId = candidate.EmployeeId, EmployeeName = candidate.EmployeeName, SpecialityName = candidate.SpecialityName, TransferDate = DateTime.Today, }); } } ViewBag.DutyList = new SelectList( await _sysAdminService.GetReferences(ReferenceTypeEnum.Duty), nameof(Reference.ID), nameof(Reference.ReferenceValue)); ViewBag.From = from; return(View(transferList)); }
private void RecruitView_Closed(object sender, EventArgs e) { _recruitViewModel.StateChanged -= ViewModel_StateChanged; _recruitViewModel.RecruitSaved -= RecruitViewModel_RecruitSaved; _recruitViewModel = null; _recruitView.Closed -= RecruitView_Closed; _recruitView = null; }
public async Task <IActionResult> Withdraw(RecruitViewModel model) { foreach (var staff in model.Candidates) { if (staff.Selected) { await _projectService.Transfer(staff.EmployeeId, 0, 0, model.ReleaseDate, UserHelper.GetUserID(HttpContext)); } } return(RedirectToAction(nameof(Dispatch))); }
public async Task <IActionResult> Dispatch() { var originModel = new RecruitViewModel { IncludeInactive = false, JustFreeOnly = false, ReleaseDate = DateTime.Today, PageIndex = 0, PageSize = 20, }; return(View(await ProcessRecruitViewModel(originModel))); }
async Task <RQPartViewModel> InitRQPartViewModelAsync(RecruitViewModel recruitView, List <UploadFile> attachments) { var questions = await _questionsService.FetchByIdsAsync(recruitView.QuestionIds); return(new RQPartViewModel { Points = recruitView.Points, MultiAnswers = recruitView.MultiAnswers, Order = recruitView.Order, OptionCount = recruitView.OptionCount, Title = recruitView.Title, Questions = questions.MapViewModelList(_mapper, null, attachments, null) }); }
public JsonResult Selected(RecruitViewModel r) { bool success = recService.writetorecruits(r); if (success) { ViewBag.Message = "Successful!"; return(Json(new { success = false, message = ViewBag.Message })); } else { ViewBag.Message = "Operation Failed!"; return(Json(new { success = false, message = ViewBag.Message })); } }
public async Task <ActionResult> Store([FromBody] RecruitViewModel model) { await ValidateRequestAsync(model); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } model.Order = model.Active ? 0 : -1; var recruit = model.MapEntity(_mapper, CurrentUserId); recruit = await _recruitsService.CreateAsync(recruit, recruit.SubItems); return(Ok(recruit.Id)); }
/// <summary> /// 处理视图模型,包括ViewBag /// </summary> /// <param name="originModel"></param> /// <returns></returns> async Task <RecruitViewModel> ProcessRecruitViewModel(RecruitViewModel originModel) { var orgs = await _sysAdminService.GetOrganiztions(); var specs = await _sysAdminService.GetReferences(ReferenceTypeEnum.Specialty); var duties = await _sysAdminService.GetReferences(ReferenceTypeEnum.Duty); ViewBag.OrgList = new SelectList(orgs, nameof(Organization.ID), nameof(Organization.Name)); ViewBag.SpecList = new SelectList(specs, nameof(Reference.ID), nameof(Reference.ReferenceValue)); ViewBag.DutyList = new SelectList(duties, nameof(Reference.ID), nameof(Reference.ReferenceValue)); var result = await _employeeService.SearchEmployee(originModel.GetCriteria()); originModel.Total = result.Total; originModel.Candidates = result.Records.Select(e => ProjEmployeeViewModel.Create(e, specs)).ToArray(); return(originModel); }
async Task ValidateRequestAsync(RecruitViewModel model) { if (String.IsNullOrEmpty(model.Title)) { ModelState.AddModelError("title", "請填寫標題"); } if (model.ParentId > 0) { var parent = await _recruitsService.GetByIdAsync(model.ParentId); if (parent == null) { ModelState.AddModelError("parentId", "父項目錯誤"); } else { if (model.SubItems.HasItems()) { var points = model.SubItems.Select(x => x.Points).ToList(); if (points.Sum() != 100) { ModelState.AddModelError("points", "分數錯誤"); } } } } else { if (model.Year <= 0) { ModelState.AddModelError("year", "請填寫年度"); } if (model.SubItems.IsNullOrEmpty()) { ModelState.AddModelError("subItems", "必須要有筆試項目"); } var subjectIds = model.SubItems.Select(x => x.SubjectId).Distinct(); if (subjectIds.Count() != model.SubItems.Count()) { ModelState.AddModelError("subItems", "筆試科目重複了"); } } }
async Task <ExamPart> InitExamPartAsync(RecruitViewModel recruitView) { var examPart = new ExamPart { Points = recruitView.Points, MultiAnswers = recruitView.MultiAnswers, Order = recruitView.Order, OptionCount = recruitView.OptionCount, Title = recruitView.Title }; var questions = (await _questionsService.FetchByIdsAsync(recruitView.QuestionIds)).ToList(); examPart.LoadExamQuestions(questions); return(examPart); }
/// <summary> /// 向项目中添加人员 /// </summary> /// <param name="id">项目的ProjectID</param> /// <returns></returns> public async Task <IActionResult> Recruit(int?id) { if (!id.HasValue) { throw new Exception("必须指定要加入的项目"); } var project = await _projectService.GetProjectById(id.Value); var originModel = new RecruitViewModel { JustFreeOnly = true, IncludeInactive = false, ProjectId = project.ID, ProjectName = project.FullName, PageIndex = 0, PageSize = 20 }; return(View(await ProcessRecruitViewModel(originModel))); }
public async Task <ActionResult> Update(int id, [FromBody] RecruitViewModel model) { var existingEntity = _recruitsService.GetById(id); if (existingEntity == null) { return(NotFound()); } await ValidateRequestAsync(model); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (model.Active) { if (existingEntity.Active == false) { model.Order = 0; } } else { if (existingEntity.Active) { model.Order = -1; } } var recruit = model.MapEntity(_mapper, CurrentUserId); await _recruitsService.UpdateAsync(existingEntity, recruit, recruit.SubItems); return(Ok()); }
private void RecruitViewShowed(object sender, RecruitOperationEventArgs e) { if (_recruitView == null) { InitRecruitCardGroupFactory(); _recruitViewModel = new RecruitViewModel(_recruitCardGroupFactory, _saveRecruitParameterizedCommand, e, notValidCallback: (message) => { new NotValidDialogView(message).ShowDialog(); }); _recruitViewModel.StateChanged += ViewModel_StateChanged; _recruitViewModel.RecruitSaved += RecruitViewModel_RecruitSaved; _recruitView = new RecruitView(_recruitViewModel); _recruitView.Closed += RecruitView_Closed; _recruitView.Owner = _mainView; _recruitView.Show(); } }
public RecruitView(RecruitViewModel viewModel) { InitializeComponent(); DataContext = viewModel; }
public static BaseOption <int> ToOption(this RecruitViewModel model) => new BaseOption <int>(model.Id, model.Title);
private void RecruitView_Clicked(object sender, RoutedEventArgs e) { DataContext = new RecruitViewModel(); }
public async Task <IActionResult> Dispatch(RecruitViewModel model) { ModelState.Clear(); return(View(await ProcessRecruitViewModel(model))); }
public bool writetorecruits(RecruitViewModel r) { Recruit recruits = new Recruit(); //Instance of recruit table from database try { var j = (from ed1 in DBContext.Jobs //To get jobname from jobs table where ed1.JobID == r.JobID select new { JobName = ed1.Post, Bonus = ed1.Bonus, }).SingleOrDefault(); var data = (from ed2 in DBContext.Referrals //Get Candidate data from referral table where ed2.ReferralID == r.ReferralID select ed2).SingleOrDefault();; /* select new * { * CandidateName = ed2.CandidateName, * EmployeeId = ed2.EmployeeID, * PhoneNumber = ed2.PhoneNumber, * Location = ed2.Location, * Email = ed2.Email, * DOB = ed2.DOB, * ResumeID = ed2.ResumeID, * * StatusID = r.StatusID, * ReferralID = ed2.ReferralID, * Post = j.JobName, * Joiningdate = r.JoiningDate * }).SingleOrDefault();*/ data.StatusID = r.StatusID; DBContext.SaveChanges(); recruits.CandidateName = data.CandidateName; //Write candidate details to recruit table recruits.EmployeeID = data.EmployeeID; recruits.Post = j.JobName; recruits.JoiningDate = System.Convert.ToDateTime(r.JoiningDate); recruits.ReferralID = data.ReferralID; recruits.Bonus = j.Bonus; DBContext.Recruits.Add(recruits); DBContext.SaveChanges(); History history = new History(); //Write details to history table history.CandidateName = data.CandidateName; history.Date = System.Convert.ToDateTime(DateTime.Now); history.DOB = data.DOB; history.Email = data.Email; history.EmployeeID = data.EmployeeID; history.PhoneNumber = data.PhoneNumber; history.JobID = r.JobID; history.ReferralID = data.ReferralID; history.StatusID = Convert.ToInt16(data.StatusID); DBContext.Histories.Add(history); DBContext.SaveChanges(); // var RecordToDelete = DBContext.Referrals.Where(a => a.ReferralID == r.ReferralID).SingleOrDefault(); //Delete from referral table // DBContext.Referrals.Remove(RecordToDelete); DBContext.SaveChanges(); return(true); } catch (Exception) { return(false); } }