Example #1
0
        public object Update([FromBody] JobVm jobVm)
        {
            var identity  = HttpContext.User.Identity as ClaimsIdentity;
            var userClaim = _authService.GetClaim(identity);

            try
            {
                _logger.LogInfo($"{MethodInfoHelper.GetCurrentMethodName()} started.");
                var user = _authService.AuthorizeUser(Convert.ToInt32(userClaim[4].Value));
                if (user != null)
                {
                    var job = _mapper.Map <Job>(jobVm);
                    _unitOfWork.Jobs.Update(job);
                    _unitOfWork.Jobs.Save();
                    return(new { message = "Success" });
                }
                else
                {
                    return(new { message = "Unauthorize" });
                }
            }
            catch (AppException ex)
            {
                _logger.LogError($"{MethodInfoHelper.GetCurrentMethodName()} failed.", ex);
                throw;
            }
            finally
            {
                _logger.LogInfo($"{MethodInfoHelper.GetCurrentMethodName()} ended.");
            }
        }
Example #2
0
        public IActionResult EditJob(JobVm model)
        {
            if (ModelState.IsValid)
            {
                var entityModel = MappingUtils.MapToNew <JobVm, Job>(model);
                _settingsBlProvider.UpdateJob(entityModel);
            }

            return(RedirectToAction("JobsManagement", "Settings"));
        }
Example #3
0
 public IActionResult Create(JobVm form)
 {
     if (ModelState.IsValid)
     {
         Job formCo = _mapper.Map <Job>(form);
         _unitOfWork.Jobs.Add(formCo);
         _unitOfWork.Complate();
         TempData["Message"] = "Sikeres hozzáadás!";
         return(RedirectToAction(nameof(Index)));
     }
     return(View(form));
 }
Example #4
0
        public IActionResult Edit(JobVm form)
        {
            if (ModelState.IsValid)
            {
                Job jobCo = _mapper.Map <Job>(form);
                _unitOfWork.Jobs.Update(jobCo);
                _unitOfWork.Complate();

                TempData["Message"] = "A változtatásokat sikeresen elmentettük!";
                return(RedirectToAction(nameof(Index)));
            }
            return(View(form));
        }
Example #5
0
        public object Post([FromBody] JobVm jobVm)
        {
            try
            {
                _logger.LogInfo($"{MethodInfoHelper.GetCurrentMethodName()} started.");
                var job = _mapper.Map <Job>(jobVm);
                if (job != null)
                {
                    _unitOfWork.Jobs.Insert(job);
                    _unitOfWork.Jobs.Save();
                }

                return(Ok(new { message = "Success" }));
            }
            catch (AppException ex)
            {
                return(new { message = "Something went wrong please try again" });
            }
        }
Example #6
0
 private static void PopulateRecord(ref JobOffer tr, ref JobVm vm)
 {
     tr.OrganizationContactID     = vm.ContactId;
     tr.PortalUsersID             = vm.PortalUserId;
     tr.JobTiltleID               = string.IsNullOrWhiteSpace(vm.Title) ? "" : vm.Title;
     tr.ExpYearFrom               = vm.ExpFrom;
     tr.ExpYearTo                 = vm.ExpTo;
     tr.NumberOfVacanciesPosition = vm.Vacancies;
     tr.StartDate                 = vm.StartDate.AsUtc();
     tr.EndDate             = vm.EndDate.AsUtc();
     tr.EmploymentTypeID    = vm.EmploymentType;
     tr.GenderID            = vm.Gender;
     tr.CountryID           = vm.Country;
     tr.CityID              = vm.City;
     tr.JobStatus           = vm.JobStatus;
     tr.SalaryRangePerMonth = vm.PerMonth;
     tr.SalaryRangePerHour  = vm.PerHour;
     tr.SalaryCurrencyID    = vm.Currency;
     tr.IsApproved          = (byte)vm.Approval;
 }
Example #7
0
        public List <JobVm> GetAll(int id)
        {
            var jobList   = _context.Job.ToList();
            var jobVm     = new JobVm();
            var jobVmlist = new List <JobVm>();

            foreach (var item in jobList)
            {
                if (item.EmployeerId == id)
                {
                    var userApplicantIds            = _context.Applicant.Where(el => el.JobID == item.Id).ToList();
                    List <UserModel> userApplicants = new List <UserModel>();
                    foreach (var i in userApplicantIds)
                    {
                        userApplicants = _context.UserModels.Where(el => el.Id == i.UserModelID).ToList();
                    }
                    item.Users = userApplicants;
                    jobVm      = _mapper.Map <JobVm>(item);
                    jobVmlist.Add(jobVm);
                }
            }

            return(jobVmlist);
        }
Example #8
0
        public long Post(ref JobVm vm, string userId)
        {
            using (var db = new LMISEntities())
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var id = vm.JobId;

                        if (id > 0) //Update
                        {
                            var tr = db.JobOffers
                                     .Where(r => r.IsDeleted == null && r.JobOfferID == id)
                                     .ToList().Single();

                            PopulateRecord(ref tr, ref vm);
                            tr.UpdateUserID = userId;
                            tr.UpdateDate   = DateTime.UtcNow;

                            //Delete detail records
                            var dr0 = db.JobOfferDetails
                                      .Where(r => r.JobOfferID == id)
                                      .ToList();

                            db.JobOfferDetails.RemoveRange(dr0);

                            var dr1 = db.JobOfferAdditionalDocs
                                      .Where(r => r.JobOfferID == id)
                                      .ToList();

                            db.JobOfferAdditionalDocs.RemoveRange(dr1);

                            var dr2 = db.JobOfferEducationLevelDetails
                                      .Where(r => r.JobOfferID == id)
                                      .ToList();

                            db.JobOfferEducationLevelDetails.RemoveRange(dr2);

                            var dr3 = db.JobOfferEducationLevels
                                      .Where(r => r.JobOfferID == id)
                                      .ToList();

                            db.JobOfferEducationLevels.RemoveRange(dr3);

                            var dr4 = db.jobOfferMedicalDetails
                                      .Where(r => r.JobOfferID == id)
                                      .ToList();

                            db.jobOfferMedicalDetails.RemoveRange(dr4);

                            var dr5 = db.jobOfferSkillsDetails
                                      .Where(r => r.JobOfferID == id)
                                      .ToList();

                            db.jobOfferSkillsDetails.RemoveRange(dr5);

                            var dr6 = db.JobOtherSkills
                                      .Where(r => r.JobOfferId == id)
                                      .ToList();

                            db.JobOtherSkills.RemoveRange(dr6);
                        }
                        else //Insert
                        {
                            var tr = new JobOffer();

                            PopulateRecord(ref tr, ref vm);
                            tr.PostUserID = userId;
                            tr.PostDate   = DateTime.UtcNow;

                            db.JobOffers.Add(tr);
                            db.SaveChanges();

                            vm.JobId = (long)tr.JobOfferID;
                        }

                        //Insert detail records
                        var ds = Utils.MultilingualDataSet(
                            new Dictionary <string, GlobalString>
                        {
                            { "c1", vm.NewTitle },
                            { "c2", vm.Description },
                        });

                        foreach (var r in ds)
                        {
                            db.JobOfferDetails.Add(new JobOfferDetail()
                            {
                                JobOfferID     = vm.JobId,
                                LanguageID     = r["c1"].L,
                                OtherJobTitle  = r["c1"].T,
                                JobDescription = r["c2"].T
                            });
                        }

                        //Insert education details
                        var joEd = db.JobOfferEducationLevels.Add(new JobOfferEducationLevel()
                        {
                            JobOfferID       = vm.JobId,
                            EducationLevelID = vm.EdLevel
                        });

                        ds = Utils.MultilingualDataSet(new Dictionary <string, GlobalString>
                        {
                            { "c1", vm.EdCert },
                        });

                        foreach (var r in ds)
                        {
                            joEd.JobOfferEducationLevelDetails.Add(new JobOfferEducationLevelDetail()
                            {
                                JobOfferID        = vm.JobId,
                                EdLevelID         = vm.EdLevel,
                                LanguageID        = r["c1"].L,
                                CertificationType = r["c1"].T
                            });
                        }

                        //Insert skill details
                        foreach (var r in vm.Skills.Where(a => !a.IsNew))
                        {
                            db.jobOfferSkillsDetails.Add(new jobOfferSkillsDetail()
                            {
                                JobOfferID   = vm.JobId,
                                IndustryID   = r.Industry.id,
                                SkillID      = r.Skill.id,
                                SkillLevelID = r.Level.id,
                                SkillTypeID  = r.Type == null || string.IsNullOrWhiteSpace(r.Type.id) ? null : r.Type.id
                            });
                        }

                        foreach (var r in vm.Skills.Where(a => a.IsNew))
                        {
                            db.JobOtherSkills.Add(new JobOtherSkill()
                            {
                                JobOfferId   = vm.JobId,
                                IndustryId   = r.Industry.id,
                                OtherSkill   = r.Skill.desc,
                                SkillLevelId = r.Level.id,
                                IsReviewed   = false
                            });
                        }

                        //Insert medical details
                        foreach (var cond in vm.MedConditions)
                        {
                            db.jobOfferMedicalDetails.Add(new jobOfferMedicalDetail()
                            {
                                JobOfferID = vm.JobId,
                                MedicalID  = cond
                            });
                        }

                        //Insert document details
                        if (!string.IsNullOrWhiteSpace(vm.FileName))
                        {
                            db.JobOfferAdditionalDocs.Add(new JobOfferAdditionalDoc()
                            {
                                JobOfferID                = vm.JobId,
                                AdditionalDocTypeID       = "99999999", //Application Form
                                AdditionalDocTemplatePath = vm.FileName
                            });
                        }
                        foreach (var docType in vm.DocTypes)
                        {
                            db.JobOfferAdditionalDocs.Add(new JobOfferAdditionalDoc()
                            {
                                JobOfferID          = vm.JobId,
                                AdditionalDocTypeID = docType
                            });
                        }

                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        ExceptionDispatchInfo.Capture(ex).Throw();
                    }
                }

            return(vm.JobId);
        }
Example #9
0
        public ModelResponse Post(UserInfo user, ref JobVm vm, string fileFolder, bool validateOnly)
        {
            try
            {
                //Authorization
                if (!IsAuthorized(user))
                {
                    return(new ModelResponse(101));
                }
                Debug.Assert(user.OrgContactId != null);
                if (vm.JobId > 0 && !Repo.IsByOrgContact(vm.JobId, (long)user.OrgContactId))
                {
                    return(new ModelResponse(101));
                }

                //Validations
                if ((vm.Title.IsNotASubCode() && vm.NewTitle.HasNoValue()) ||
                    vm.Description.HasNoValue() ||
                    vm.ExpFrom < 0 || vm.ExpTo < 0 || vm.Vacancies < 1 ||
                    vm.EmploymentType.IsNotASubCode() ||
                    vm.EdLevel.IsNotASubCode() ||
                    vm.EdCert.HasNoValue() ||
                    vm.Gender.IsNotASubCode() ||
                    vm.Country.IsNotASubCode() ||
                    vm.City.IsNotASubCode() ||
                    vm.Skills.Count < 1 ||
                    vm.Skills.Any(s => s.Industry.id.IsNotASubCode() || s.Level.id.IsNotASubCode()) ||
                    vm.Skills.Any(s => !s.IsNew && s.Skill.id.IsNotASubCode()) ||
                    (vm.PerMonth <= 0 && vm.PerHour <= 0) ||
                    vm.Currency.IsNotASubCode() ||
                    vm.MedConditions.Count < 1 || vm.MedConditions.Any(x => x.IsNotASubCode()))
                {
                    return(new ModelResponse(1));
                }

                if ((vm.JobId < 1 && vm.StartDate < DateTime.Today) || vm.EndDate < vm.StartDate)
                {
                    return(new ModelResponse(2));
                }

                if (!validateOnly)
                {
                    //Verify File Path
                    if (fileFolder.HasNoValue())
                    {
                        return(new ModelResponse(102));
                    }
                    if (!vm.FileName.HasNoValue() && !File.Exists(Path.Combine(fileFolder, vm.FileName)))
                    {
                        return(new ModelResponse(102));
                    }

                    //Save to DB
                    if (vm.Title.IsNotASubCode())
                    {
                        vm.Title = "";
                    }
                    else
                    {
                        vm.NewTitle = new GlobalString();
                    }

                    if (vm.ExpTo < vm.ExpFrom)
                    {
                        var tmp = vm.ExpTo;
                        vm.ExpTo   = vm.ExpFrom;
                        vm.ExpFrom = tmp;
                    }
                    if (vm.PerMonth < 0)
                    {
                        vm.PerMonth = 0;
                    }
                    if (vm.PerHour < 0)
                    {
                        vm.PerHour = 0;
                    }

                    vm.Approval     = Approval.Pending;
                    vm.PortalUserId = (long)user.PortalUserId;
                    vm.ContactId    = (long)user.OrgContactId;
                    Repo.Post(ref vm, user.UserId);
                }
            }
            catch (Exception ex)
            {
                return(new ModelResponse(ex));
            }

            return(new ModelResponse(0, vm.JobId));
        }
Example #10
0
		internal void Append(JobVm Job)
		{
			var job = new Editor.PPEditorJob(Job.Model, _jobDs);
			job.RefreshPPTable += () => { if (RefreshPPItems != null) RefreshPPItems(); };
            JobList.Add(job);
		}
Example #11
0
        public static object Post(JobVm data, bool validateOnly)
        {
            var mr = Mgr.Post(Utils.LoggedUser, ref data, Utils.UploadFolder, validateOnly);

            return(Utils.ServiceResponse(PageCode, mr));
        }