コード例 #1
0
        public bool UpdateJob(JobPostViewModel job, int userId)
        {
            var jModel = new JobPostModel
            {
                CityCode           = job.CityCode,
                CountryCode        = job.CountryCode,
                CreatedBy          = Convert.ToString(userId),
                CTC                = job.CTC,
                HiringCriteria     = job.HiringCriteria,
                JobDetails         = job.JobDetails,
                JobTitleId         = Convert.ToString(job.JobTitleId),
                JobType            = job.JobType,
                MonthlySalary      = job.MonthlySalary,
                Quarter1           = job.Quarter1,
                Quarter2           = job.Quarter2,
                Quarter3           = job.Quarter3,
                Quarter4           = job.Quarter4,
                SPOC               = job.ContactPerson,
                SPOCContact        = job.Mobile,
                SPOCEmail          = job.SPOCEmail,
                StateCode          = job.StateCode,
                Featured           = job.Featured,
                DisplayOrder       = job.DisplayOrder,
                JobTitleByEmployer = job.JobTitleByEmployer,
                PositionStartDate  = job.PositionStartDate,
                PositionEndDate    = job.PositionEndDate,
                FinancialYear      = job.FinancialYear
            };

            return(dashboardRepository.UpdateJob(userId, job.JobPostId, jModel));
        }
コード例 #2
0
        public ActionResult EditJobPost(JobPostModel jpm)
        {
            if (ModelState.IsValid)
            {
                var jobPost = _context.JobPost.Where(jp => jp.Id == jpm.JobPostId).FirstOrDefault();

                jobPost.ModifiedById     = UserService.GetUserByEmail(HttpContext.User.Identity.Name).Id;
                jobPost.ModifiedOn       = DateTime.Now;
                jobPost.Title            = jpm.Title;
                jobPost.JobBrief         = jpm.JobBrief;
                jobPost.Responsibilities = jpm.Responsibilities;
                jobPost.Requirements     = jpm.Requirements;

                //foreach (var skillId in jpm.SkillIds)
                //{
                //    var jobSkill = new JobSkill
                //    {
                //        JobPostId = jobPost.Id,
                //        SkillId = Convert.ToInt32(skillId)
                //    };
                //    _context.JobSkill.Add(jobSkill);
                //}

                _context.SaveChanges();
                return(RedirectToAction("JobsListing", "Job"));
            }
            return(View("JobPost", jpm));
        }
コード例 #3
0
        private void ValidateJobModel(ref JobPostModel job)
        {
            var pInfos = job.GetType().GetProperties();

            foreach (var pInfo in pInfos)
            {
                var val = pInfo.GetValue(job);
                if (null == val)
                {
                    DataTable t = null;
                    switch (pInfo.Name)
                    {
                    case "CountryCode":
                        t =
                            bjpProcessor.GetIdFromValue(Convert.ToString("INDIA"), pInfo.Name);
                        if (null != t && t.Rows.Count > 0)
                        {
                            pInfo.SetValue(job, t.Rows[0]["Id"]);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
        }
コード例 #4
0
        public ActionResult JobDetails(int jobId)
        {
            var jobPost = _context.JobPost.Include(jp => jp.JobType).Where(jp => jp.Id == jobId).FirstOrDefault();

            if (jobPost == null)
            {
                //return
            }

            var skills       = _context.JobSkill.Include(js => js.Skill).Where(js => js.JobPostId == jobPost.Id).Select(js => js.Skill.Name).ToList();
            var jobPostModel = new JobPostModel()
            {
                JobPostId        = jobPost.Id,
                Title            = jobPost.Title,
                IsActive         = jobPost.IsActive,
                CreatedUserEmail = jobPost.CreatedBy.Email,
                PostedOn         = jobPost.PostedOn,
                JobBrief         = jobPost.JobBrief,
                Responsibilities = jobPost.Responsibilities,
                Requirements     = jobPost.Requirements,
                JobTypeId        = jobPost.JobTypeId,
                JobType          = jobPost.JobType.Type
            };

            return(View(jobPostModel));
        }
コード例 #5
0
        public async Task <bool> SaveJob(JobPostModel jobPost)
        {
            bool flag = false;

            try
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    HttpClient    httpClient     = new HttpClient();
                    Uri           uri1           = new Uri(Constants.baseUrl + "api/Jobs");
                    StringContent stringContent1 = new StringContent(JsonConvert.SerializeObject((object)jobPost), Encoding.UTF8, "application/json");
                    Uri           uri2           = uri1;
                    StringContent stringContent2 = stringContent1;
                    //flag = (await httpClient.PostAsync(uri2, (HttpContent)stringContent2)).IsSuccessStatusCode;

                    var requestTask = httpClient.PostAsync(uri2, (HttpContent)stringContent2);
                    var response    = Task.Run(() => requestTask);
                    flag = response.Result.IsSuccessStatusCode;
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.StackTrace);
                flag = false;
            }
            return(flag);
        }
コード例 #6
0
 public bool AddJobPostData(JobPostModel model)
 {
     using (var connection = new SqlConnection(connectionString))
     {
         try
         {
             SqlParameter[] parameters = new SqlParameter[] {
                 new SqlParameter("@CTC", model.CTC),
                 new SqlParameter("@CityCode", model.CityCode),
                 new SqlParameter("@CountryCode", model.CountryCode),
                 new SqlParameter("@CreatedBy", model.CreatedBy),
                 new SqlParameter("@EmploymentStatusId", model.EmploymentStatusId),
                 new SqlParameter("@EmploymentTypeId", model.EmploymentTypeId),
                 new SqlParameter("@Gender", model.Gender),
                 new SqlParameter("@HiringCriteria", model.HiringCriteria),
                 new SqlParameter("@Jobdetails", model.JobDetails),
                 new SqlParameter("@JobIndustryAreaId", model.JobIndustryAreaId),
                 new SqlParameter("@OtherJobIndustryArea", model.OtherJobIndustryArea),
                 new SqlParameter("@JobTitleId", model.JobTitleId),
                 new SqlParameter("@JobType", model.JobType),
                 new SqlParameter("@MonthlySalary", model.MonthlySalary),
                 new SqlParameter("@Nationality", model.Nationality),
                 new SqlParameter("@IsWalkInJob", model.IsWalkin == "Yes"?true:false),
                 new SqlParameter("@NoPosition", model.NoPosition),
                 new SqlParameter("@PositionStartDate", model.PositionStartDate),
                 new SqlParameter("@PositionEndDate", model.PositionEndDate),
                 new SqlParameter("@Spoc", model.SPOC),
                 new SqlParameter("@SpocContact", model.SPOCContact),
                 new SqlParameter("@SpocEmail", model.SPOCEmail),
                 new SqlParameter("@StateCode", model.StateCode),
                 new SqlParameter("@PostedTo", model.Userid),
                 new SqlParameter("@Skills", model.Skills),
                 new SqlParameter("@JobTitleByEmployer", model.JobTitleByEmployer),
                 new SqlParameter("@MinExp", model.MinExp),
                 new SqlParameter("@MaxExp", model.MaxExp),
                 new SqlParameter("@FinancialYear", model.FinancialYear),
                 new SqlParameter("@IsFromBulkUpload", model.IsFromBulkUpload),
                 new SqlParameter("@isDraftJob", model.IsDraftJob)
             };
             var result =
                 SqlHelper.ExecuteNonQuery
                 (
                     connection,
                     CommandType.StoredProcedure,
                     "usp_InsertJobPost",
                     parameters
                 );
             if (result > 0)
             {
                 return(true);
             }
         }
         finally
         {
             SqlHelper.CloseConnection(connection);
         }
     }
     throw new UserNotCreatedException("Unable to create job post, please contact your teck deck with your details.");
 }
コード例 #7
0
 public ActionResult UserJob_Destroy(JobPostModel obj)
 {
     new UserJobModel().Delete(new UserJob()
     {
         JobId = obj.Id, UserId = SessionItems.CurrentUser.Id
     });
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
コード例 #8
0
        public ActionResult AddJobPost(JobPostModel jp)
        {
            if (ModelState.IsValid)
            {
                var jobPost = new JobPost()
                {
                    CreatedById      = UserService.GetUserByEmail(HttpContext.User.Identity.Name).Id,
                    PostedOn         = DateTime.Now,
                    IsActive         = true,
                    Title            = jp.Title,
                    JobTypeId        = jp.JobTypeId,
                    JobBrief         = jp.JobBrief,
                    Responsibilities = jp.Responsibilities,
                    Requirements     = jp.Requirements
                };

                _context.JobPost.Add(jobPost);

                foreach (var skillId in jp.SkillIds)
                {
                    var jobSkill = new JobSkill
                    {
                        JobPostId = jobPost.Id,
                        SkillId   = Convert.ToInt32(skillId)
                    };
                    _context.JobSkill.Add(jobSkill);
                }

                //create notification
                var notification = new Notification
                {
                    Type      = NotificationType.Add,
                    JobPostId = jobPost.Id
                };
                _context.Notification.Add(notification);

                //notify all users
                var seekerRoleId = _context.Role.Where(r => r.Type == "JobSeeker").FirstOrDefault().Id;
                var jobSeekersId = _context.User.Include(u => u.Role).Where(u => u.Role.Id == seekerRoleId).Select(u => u.Id).ToList();

                foreach (var seekerId in jobSeekersId)
                {
                    var un = new UserNotification
                    {
                        NotificationId = notification.Id,
                        UserId         = seekerId,
                        IsRead         = false
                    };
                    _context.UserNotification.Add(un);
                }

                _context.SaveChanges();
                return(RedirectToAction("JobsListing", "Job"));
            }
            return(View("JobPost", jp));
        }
コード例 #9
0
        public async Task PostJob(JobPostModel model)
        {
            ContractEntity entity = Mapper.Map <JobPostModel, ContractEntity>(model);

            entity.UserId           = NTContext.Context.UserId;
            entity.ContractStatusId = (int)ContractStatusEnum.Job;
            entity.PublicStatusId   = (int)ContractStatusEnum.Job;
            this.DbContext.Contracts.Add(entity);
            await this.DbContext.SaveChangesAsync();
        }
コード例 #10
0
        public ActionResult EditJobPost(Guid JobPostID)
        {
            JobPostModel post = new JobPostModel();

            if (JobPostID != Guid.Empty)
            {
                //edit mode
                post = new JobPostModel(JobPostID);
            }
            return(View(post));
        }
コード例 #11
0
        public ActionResult AddJobPost()
        {
            var jobPostModel = new JobPostModel
            {
                ActionName = "AddJobPost",
                Skills     = _context.Skills.ToList(),
                JobTypes   = _context.JobTypes.ToList()
            };

            return(View("JobPost", jobPostModel));
        }
 public bool UpdateJob(int userId, int jobId, JobPostModel job)
 {
     using (var connection = new SqlConnection(connectionString))
     {
         try
         {
             SqlParameter[] parameters = new SqlParameter[] {
                 new SqlParameter("@JobId", jobId),
                 new SqlParameter("@CityCode", job.CityCode),
                 new SqlParameter("@CountryCode", job.CountryCode),
                 new SqlParameter("@CTC", job.CTC),
                 new SqlParameter("@UpdatedBy", userId),
                 new SqlParameter("@HiringCriteria", job.HiringCriteria),
                 new SqlParameter("@Jobdetails", job.JobDetails),
                 new SqlParameter("@JobTitleId", job.JobTitleId),
                 new SqlParameter("@JobType", job.JobType),
                 new SqlParameter("@MonthlySalary", job.MonthlySalary),
                 new SqlParameter("@Quarter1", job.Quarter1),
                 new SqlParameter("@Quarter2", job.Quarter2),
                 new SqlParameter("@Quarter3", job.Quarter3),
                 new SqlParameter("@Quarter4", job.Quarter4),
                 new SqlParameter("@Spoc", job.SPOC),
                 new SqlParameter("@SpocContact", job.SPOCContact),
                 new SqlParameter("@SpocEmail", job.SPOCEmail),
                 new SqlParameter("@StateCode", job.StateCode),
                 new SqlParameter("@Feauterdjobs", job.Featured == null?0:1),
                 new SqlParameter("@DisplayOrder", job.DisplayOrder),
                 new SqlParameter("@JobTitleByEmployer", job.JobTitleByEmployer),
                 new SqlParameter("@PostingDate", job.PositionStartDate),
                 new SqlParameter("@ExpiryDate", job.PositionEndDate),
                 new SqlParameter("@FinancialYear", job.FinancialYear),
             };
             var result =
                 SqlHelper.ExecuteNonQuery
                 (
                     connection,
                     CommandType.StoredProcedure,
                     "usp_UpdateJobDetails",
                     parameters
                 );
             if (result > 0)
             {
                 return(true);
             }
         }
         finally
         {
             SqlHelper.CloseConnection(connection);
         }
     }
     throw new DataNotUpdatedException("Unable to update posted job, please contact your teck deck with your details.");
 }
コード例 #13
0
 public bool AddJobPost(JobPostViewModel jobpostviewmodel, int userId)
 {
     JobPostModel model = new JobPostModel
     {
         JobIndustryAreaId = jobpostviewmodel.JobIndustryAreaId,
         OtherJobIndustryArea = jobpostviewmodel.OtherJobIndustryArea,
         CountryCode = jobpostviewmodel.CountryCode,
         StateCode = jobpostviewmodel.StateCode,
         CityCode = jobpostviewmodel.CityCode,
         EmploymentStatusId = jobpostviewmodel.EmploymentStatusId,
         JobTitleId = jobpostviewmodel.JobTitleId,
         EmploymentTypeId = jobpostviewmodel.EmploymentTypeId,
         MonthlySalary = jobpostviewmodel.MonthlySalary,
         NoPosition = jobpostviewmodel.NoPosition,
         Nationality = jobpostviewmodel.Nationality,
         PositionStartDate = jobpostviewmodel.PositionStartDate,
         PositionEndDate = jobpostviewmodel.PositionEndDate,
         HiringCriteria = jobpostviewmodel.HiringCriteria,
         JobDetails = jobpostviewmodel.JobDetails,
         Gender = jobpostviewmodel.Gender,
         CreatedBy = Convert.ToString(userId),
         JobType = jobpostviewmodel.JobType,
         Userid = userId,
         CTC = jobpostviewmodel.CTC,
         SPOC = jobpostviewmodel.ContactPerson,
         SPOCContact = jobpostviewmodel.Mobile,
         SPOCEmail = jobpostviewmodel.SPOCEmail,
         IsWalkin = jobpostviewmodel.IsWalkIn,
         //Quarter1 = jobpostviewmodel.Quarter1,
         //Quarter2 = jobpostviewmodel.Quarter2,
         //Quarter3 = jobpostviewmodel.Quarter3,
         //Quarter4 = jobpostviewmodel.Quarter4,
         Skills = jobpostviewmodel.Skills,
         JobTitleByEmployer=jobpostviewmodel.JobTitleByEmployer,
         MinExp=(int)jobpostviewmodel.MinExp,
         MaxExp=(int)jobpostviewmodel.MaxExp,
         FinancialYear=jobpostviewmodel.FinancialYear
     };
     bool result = _jobPostProcessor.AddJobPostData(model);
     if (result == true)
     {
         return result;
     }
     throw new UserNotCreatedException("Job Post is not create.");
 }
コード例 #14
0
        private void ResolveJobData(out JobPostModel job, DataRow row, string[] additionalColumns)
        {
            job = new JobPostModel();
            var pInfos = job.GetType().GetProperties();

            foreach (var pInfo in pInfos)
            {
                try
                {
                    DataColumnCollection columns = row.Table.Columns;
                    if (columns.Contains(pInfo.Name))
                    {
                        switch (pInfo.PropertyType.Name)
                        {
                        case "String":
                            string val = Convert.ToString(row[pInfo.Name]);
                            if (!string.IsNullOrWhiteSpace(val))
                            {
                                pInfo.SetValue(job, val);
                            }
                            break;

                        case "Int32":
                            int inVal = Convert.ToInt32(row[pInfo.Name]);
                            if (inVal > 0)
                            {
                                pInfo.SetValue(job, inVal);
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    row[additionalColumns[2]]  = "Failed";
                    row[additionalColumns[3]] += $"<li>{pInfo.Name} is not in valid format</li>";
                }
            }
        }
コード例 #15
0
        // GET: Dashboard/Details/5
        public ActionResult Details(int id)
        {
            var getDetails = _jobPostRepo.GetJobPostWithApplicant(id);
            var model      = new JobPostModel
            {
                DateCreated        = getDetails.DateCreated,
                Description        = getDetails.Description,
                JobTitle           = getDetails.JobTitle,
                Id                 = getDetails.Id,
                IsClosed           = getDetails.IsClosed,
                Withdraw           = getDetails.Applicants.Count(x => x.HiringStatus == "Withdraw"),
                ImmediateRejection = getDetails.Applicants.Count(x => x.HiringStatus == "Immediate Rejection"),
                Interviewed        = getDetails.Applicants.Count(x => x.HiringStatus == "Interview"),
                Hired              = getDetails.Applicants.Count(x => x.HiringStatus == "Hired"),
                New                = getDetails.Applicants.Count(x => x.HiringStatus == "New"),
                TotalApplications  = getDetails.Applicants.Count(),
                Applicants         = getDetails.Applicants
            };

            return(View(model));
        }
コード例 #16
0
        public ActionResult <JobPost> Create(JobPostModel model)
        {
            try
            {
                int?employerID = ClaimHelper.GetIdFromClaimIdentity((ClaimsIdentity)this.ControllerContext.HttpContext.User.Identity);

                if (employerID == null)
                {
                    return(Unauthorized());
                }

                JobPost post       = _mapper.Map <JobPost>(model);
                IJobDAO JobPostDAO = new JobDAO(_connection);
                JobPost JobPosts   = JobPostDAO.Create((int)employerID, post);
                return(Ok(JobPosts));
            }
            catch (Exception ex)
            {
                return(BadRequest(new ErrorMessageModel(ex.Message)));
            }
        }
コード例 #17
0
        public IActionResult Update(int id, JobPostModel model)
        {
            try
            {
                int?employerID = ClaimHelper.GetIdFromClaimIdentity((ClaimsIdentity)this.ControllerContext.HttpContext.User.Identity);

                if (employerID == null)
                {
                    return(Unauthorized());
                }

                IJobDAO JobPostDAO = new JobDAO(_connection);
                JobPost oldPost    = JobPostDAO.FindById(id, (int)employerID);

                if (oldPost == null)
                {
                    return(NotFound(new ErrorMessageModel("Post não encontrado!")));
                }

                JobPost newPost = _mapper.Map <JobPost>(model);

                oldPost.Title         = newPost.Title;
                oldPost.Category      = newPost.Category;
                oldPost.ImagePath     = newPost.ImagePath;
                oldPost.Description   = newPost.Description;
                oldPost.Tradable      = newPost.Tradable;
                oldPost.InitialPrice  = newPost.InitialPrice;
                oldPost.Address       = newPost.Address;
                oldPost.PaymentMethod = newPost.PaymentMethod;

                JobPost updatedPost = JobPostDAO.UpdatePostDetails(oldPost);

                return(Ok(updatedPost));
            }
            catch (Exception ex)
            {
                return(BadRequest(new ErrorMessageModel(ex.Message)));
            }
        }
コード例 #18
0
        public ActionResult EditJobPost(int jobPostId)
        {
            var jobPost = _context.JobPost.Where(jp => jp.Id == jobPostId).FirstOrDefault();


            var jobPostModel = new JobPostModel()
            {
                JobPostId        = jobPost.Id,
                Title            = jobPost.Title,
                Skills           = _context.Skills.ToList(),
                SkillIds         = _context.JobSkill.Where(js => js.JobPostId == jobPost.Id).Select(js => js.SkillId).ToList(),
                JobTypeId        = jobPost.JobTypeId,
                JobTypes         = _context.JobTypes.ToList(),
                JobBrief         = jobPost.JobBrief,
                Requirements     = jobPost.Requirements,
                Responsibilities = jobPost.Responsibilities,
                ActionName       = "EditJobPost"
            };


            return(View("JobPost", jobPostModel));
        }
コード例 #19
0
ファイル: JobController.cs プロジェクト: Nootus/0xServices
 public async Task <AjaxModel <NTModel> > PostJob([FromBody] JobPostModel model)
 {
     return(await AjaxHelper.SaveAsync(m => this.domain.PostJob(model), Messages.JobPostSuccess));
 }
コード例 #20
0
 public async Task PostJob(JobPostModel model)
 {
     await this.contractRepository.PostJob(model);
 }
コード例 #21
0
        public async Task <ActionResult <JobPostModel> > PostJob(JobPostModel jobPostModel)
        {
            String jwt = Request.Headers["Authorization"];

            jwt = jwt.Substring(7);
            //Decode jwt and get payload
            var stream    = jwt;
            var handler   = new JwtSecurityTokenHandler();
            var jsonToken = handler.ReadToken(stream);
            var tokenS    = jsonToken as JwtSecurityToken;
            //I can get Claims using:
            var email = tokenS.Claims.First(claim => claim.Type == "email").Value;

            var renter = await _context.Accounts
                         .SingleOrDefaultAsync(p => p.Email == email);

            if (renter == null)
            {
                return(BadRequest());
            }
            var job = new Job()
            {
                Name         = jobPostModel.Name,
                RenterId     = renter.Id,
                Details      = jobPostModel.Details,
                TypeId       = jobPostModel.TypeId,
                FormId       = jobPostModel.FormId,
                PayformId    = jobPostModel.PayformId,
                Deadline     = jobPostModel.Deadline,
                Floorprice   = jobPostModel.Floorprice,
                Cellingprice = jobPostModel.Cellingprice,
                IsPrivate    = jobPostModel.IsPrivate,
                SpecialtyId  = jobPostModel.SpecialtyId,
                ProvinceId   = jobPostModel.ProvinceId,
                ServiceId    = jobPostModel.ServiceId,
                CreateAt     = DateTime.Now,
                Status       = "Waiting",
            };

            _context.Jobs.Add(job);
            await _context.SaveChangesAsync();

            foreach (var skill in jobPostModel.Skills)
            {
                _context.JobSkills.Add(new JobSkill()
                {
                    JobId   = job.Id,
                    SkillId = skill.Id,
                });
            }
            await _context.SaveChangesAsync();

            job = await _context.Jobs
                  .Include(p => p.Renter)
                  .Include(p => p.Freelancer)
                  .Include(p => p.Form)
                  .Include(p => p.Type)
                  .Include(p => p.JobSkills).ThenInclude(p => p.Skill)
                  .Include(p => p.S).ThenInclude(p => p.Service)
                  .Include(p => p.S).ThenInclude(p => p.Specialty)
                  .Include(p => p.Payform)
                  .Include(p => p.JobSkills).ThenInclude(p => p.Skill)
                  .Include(p => p.Province)
                  .SingleOrDefaultAsync(p => p.Id == job.Id);

            return(Ok(new JobResponseModel(job)));
        }
コード例 #22
0
 public ActionResult EditJobPost(JobPostModel model)
 {
     model.SaveOrUpdate(SessionItems.CurrentUser.Id);
     return(RedirectToAction("index", "Manage"));
 }
コード例 #23
0
 public ActionResult CompanyJob_Destroy(JobPostModel obj)
 {
     new JobPostModel().Delete(obj.ToObject());
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
コード例 #24
0
        private async void OnClickPostJob(object sender, EventArgs e)
        {
            aiPostJob.IsRunning = true;
            JobPostModel jpm  = new JobPostModel();
            string       text = entryPJTitle.Text;

            if (text == null || text.Equals(""))
            {
                await DisplayAlert("", "Please enter Job Title.", "OK");

                aiPostJob.IsRunning = false;
            }
            else
            {
                jpm.JobTitle = text;
                string l = entryPJLocation.Text;
                if (l == null || l.Equals(""))
                {
                    await DisplayAlert("", "Please enter Job Location.", "OK");

                    aiPostJob.IsRunning = false;
                }
                else
                {
                    try
                    {
                        Place place = await Places.GetPlace(selectedPrediction.Place_ID, Constants.googlePlaceApiKey);

                        jpm.Location = new List <LocationModel>()
                        {
                            new LocationModel()
                            {
                                LocationName = l,
                                Latitude     = place.Latitude.ToString(),
                                Longitude    = place.Longitude.ToString()
                            }
                        };
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex.StackTrace);
                    }

                    jpm.JobType = !rgPJJobStatus.SelectedItem.ToString().ToLower().Equals("normal") ? "U" : "N";

                    ServiceModel serviceModel = services.ElementAt <ServiceModel>(selectedService);
                    jpm.JobServicesId   = serviceModel.Id;
                    jpm.JobServicesName = serviceModel.ServiceName;

                    //if (serviceModel.ServiceName.Equals("Child Care"))
                    if (serviceModel.ServiceName.ToLower().Contains("child"))
                    {
                        jpm.Receivers = new List <Receiver>();

                        for (int i = 0; i < gridChildCare.Children.Count - 1; i++)
                        {
                            ChildView  content    = (ChildView)gridChildCare.Children[i];
                            Grid       grid       = (Grid)content.Children.ElementAt(0);
                            RadioGroup radioGroup = (RadioGroup)grid.Children.ElementAt(1);
                            Button     button     = (Button)grid.Children.ElementAt(3);
                            int        gender     = (new List <string>()
                            {
                                "Male",
                                "Female",
                                "N/A"
                            }).IndexOf(radioGroup.SelectedItem.ToString());
                            jpm.Receivers.Add(new Receiver()
                            {
                                ReceiverAge = (int)float.Parse(button.Text), ReceiverGender = gender + 1
                            });
                        }
                    }

                    jpm.HelperType = !cbPJHelperHome.Checked ? "M" : "S";

                    if (btnPJPriceTbd.BorderColor == Color.FromHex("BCC1C4"))
                    {
                        if (btnPJPriceDaily.BorderColor == Color.FromHex("FE7890"))
                        {
                            jpm.IsDaily       = true;
                            jpm.MinDailyPrice = btnPJPriceDayMin.Text.Substring(2);
                            jpm.MaxDailyPrice = btnPJPriceDayMax.Text.Substring(2);
                        }
                        if (btnPJPriceMonthly.BorderColor == Color.FromHex("FE7890"))
                        {
                            jpm.IsMonthly       = true;
                            jpm.MinMonthlyPrice = btnPJPriceMonthMin.Text.Substring(2);
                            jpm.MaxMonthlyPrice = btnPJPriceMonthMax.Text.Substring(2);
                        }
                        if (btnPJPriceHourly.BorderColor == Color.FromHex("FE7890"))
                        {
                            jpm.IsHourly       = true;
                            jpm.MinHourlyPrice = btnPJPriceHrMin.Text.Substring(2);
                            jpm.MaxHourlyPrice = btnPJPriceHrMax.Text.Substring(2);
                        }
                    }
                    if (entryPJDescription.Text != null)
                    {
                        jpm.JobDescription = entryPJDescription.Text;
                    }
                    if (btnPJSun.BorderColor == Color.FromHex("FE7890"))
                    {
                        jpm.IsSunday = true;
                    }
                    if (btnPJMon.BorderColor == Color.FromHex("FE7890"))
                    {
                        jpm.IsMonday = true;
                    }
                    if (btnPJTue.BorderColor == Color.FromHex("FE7890"))
                    {
                        jpm.IsTuesday = true;
                    }
                    if (btnPJWed.BorderColor == Color.FromHex("FE7890"))
                    {
                        jpm.IsWednesday = true;
                    }
                    if (btnPJThu.BorderColor == Color.FromHex("FE7890"))
                    {
                        jpm.IsThursday = true;
                    }
                    if (btnPJFri.BorderColor == Color.FromHex("FE7890"))
                    {
                        jpm.IsFriday = true;
                    }
                    if (btnPJSat.BorderColor == Color.FromHex("FE7890"))
                    {
                        jpm.IsSaturday = true;
                    }

                    //jpm.StartTime = rsPJTime.LowerValue / 60 + ":" + rsPJTime.LowerValue % 60 + ":00";
                    //jpm.EndTime = rsPJTime.UpperValue / 60 + ":" + rsPJTime.UpperValue % 60 + ":00";
                    jpm.StartTime = btnPJStartTime.Text.Substring(0, 2) + ":" + btnPJStartTime.Text.Substring(2, 2) + ":00";
                    jpm.EndTime   = btnPJEndTime.Text.Substring(0, 2) + ":" + btnPJEndTime.Text.Substring(2, 2) + ":00";

                    jpm.JobScope = new List <JobScopes>();
                    foreach (Button button in gridPJScopes.Children.ToList())
                    {
                        if (button.BorderColor == Color.FromHex("FE7890"))
                        {
                            string scope = button.Text;
                            var    s     = scopes.Where((x => x.ScopeName == scope)).FirstOrDefault();
                            jpm.JobScope.Add(new JobScopes()
                            {
                                ScopeId = s.Id.ToString(), ScopeName = s.ScopeName
                            });
                        }
                    }
                    jpm.UserId = loggedUser.Id;
                    int num = await new JobServices().SaveJob(jpm) ? 1 : 0;

                    aiPostJob.IsRunning = false;
                    if (num != 0)
                    {
                        await DisplayAlert("", "Job Post successfully.", "OK");

                        Page page = await Navigation.PopAsync();
                    }
                    else
                    {
                        await DisplayAlert("", "Job not post. Please try again.", "OK");
                    }
                }
            }
        }
コード例 #25
0
        public IEnumerable <BulkUploadSummaryViewModel <BulkJobPostSummaryDetailViewModel> > UploadJobs(UserViewModel user, IList <IFormFile> files)
        {
            string roleName        = user.RoleName;
            string mappingFilePath =
                Path.Combine(environment.WebRootPath, "DataMappings", "BulkJobPostMappings", "JobPostMapping.xml");
            DataTable dt = XmlProcessor.XmlToTable(mappingFilePath);

            if (null != dt)
            {
                var summary = new List <BulkUploadSummaryViewModel <BulkJobPostSummaryDetailViewModel> >();
                foreach (var file in files)
                {
                    var fileSummary = new BulkUploadSummaryViewModel <BulkJobPostSummaryDetailViewModel>
                    {
                        FileName = file.FileName,
                        Summary  = new List <BulkJobPostSummaryDetailViewModel>()
                    };
                    DataTable dTable = null;
                    NPOIManager.ReadFile(file, dt, out dTable, true, roleName);
                    if (null != dTable && dTable.Rows.Count > 1)
                    {
                        string[] additionalColumns = new string[] { "ProcessedBy", "ProcessedOn", "Status", "ErrorDetails" };
                        //  If at the time of file read we pass true for first row as header then here also we need to pass the same.
                        ExtendTable(additionalColumns, ref dTable, user.UserId, true);

                        //  In Case of multiple cities in Job Location Column we need to divide them in multiple rows as below.
                        SimpliFyTableDataForMultipleCitiesForSingleJob(dTable);
                        JobPostModel jDetail = null;
                        int          rIndex  = -1;
                        foreach (DataRow row in dTable.Rows)
                        {
                            rIndex++;
                            if (rIndex == 0)
                            {
                                fileSummary.Summary.Add(AddSummary(row));
                                continue;
                            }
                            BulkJobPostSummaryDetailViewModel sData = null;
                            row[additionalColumns[0]] = user.FullName;
                            row[additionalColumns[1]] = DateTime.Now;

                            //  Checking if user authorized to post jobs.
                            if (!IsAllowToPostJob(user, row))
                            {
                                row[additionalColumns[2]]  = "Failed";
                                row[additionalColumns[3]] += $"<li>You are not allowed to post this job - Enter company name used while registration.</li>";
                                sData = AddSummary(row);
                                fileSummary.Summary.Add(sData);
                                SaveDetailToAudit(sData, fileSummary.FileName, user.UserId);
                                continue;
                            }
                            try
                            {
                                //Saving JobTitleByEmployer as JobTitle
                                GetJobTitle(row, additionalColumns);

                                ManageJobType(row, additionalColumns);

                                //  Checking if at least one quarter must have a value
                                //ValidateQuarters(row, additionalColumns);

                                //Validate SPOC Contact
                                ValidateSpocContact(row, additionalColumns);

                                // Validate Job Expiry Dates
                                ValidateJobExpiryDates(row, additionalColumns);

                                //   All external validations should be done before this method.
                                ResolveJobData(out jDetail, row, additionalColumns);

                                //  Validate model if some thing needs for default value.
                                ValidateJobModel(ref jDetail);

                                foreach (DataColumn col in dTable.Columns)
                                {
                                    //  Check if any required field is empty
                                    switch (col.ColumnName)
                                    {
                                    case "CompanyName":
                                    case "StateCode":
                                    case "CityCode":
                                    case "JobTitleByEmployer":
                                    case "JobTitleId":
                                    case "SPOC":
                                    case "SPOCEmail":
                                    case "SPOCContact":
                                    //case "CTC":
                                    case "HiringCriteria":
                                    //case "Quarter1":
                                    //case "Quarter2":
                                    //case "Quarter3":
                                    //case "Quarter4":
                                    case "JobType":
                                    case "PositionStartDate":
                                    case "PositionEndDate":
                                        if (string.IsNullOrEmpty(Convert.ToString(row[col.ColumnName])))
                                        {
                                            switch (col.ColumnName)
                                            {
                                            case "JobTitleId":
                                                row[additionalColumns[2]]  = "Failed";
                                                row[additionalColumns[3]] += $"<li>At least one job Title is mandatory</li>";
                                                break;

                                            default:
                                                row[additionalColumns[2]]  = "Failed";
                                                row[additionalColumns[3]] += $"<li>{dTable.Rows[0][col.ColumnName]} is mandatory</li>";
                                                break;
                                            }
                                        }
                                        break;

                                    default:
                                        break;
                                    }
                                    //  Check if master information available in our system or not.
                                    DataTable t = null;
                                    switch (col.ColumnName)
                                    {
                                    //case "FinancialYear":
                                    //    int year = Convert.ToInt32(row[col.ColumnName]);
                                    //    if (year <= 0)
                                    //    {
                                    //        jDetail.GetType().GetProperty(col.ColumnName).SetValue(jDetail, DateTime.Now.Year);
                                    //    }
                                    //    break;
                                    case "StateCode":
                                        string state = Convert.ToString(row[col.ColumnName]);
                                        t =
                                            bjpProcessor.GetIdFromValue(state, col.ColumnName);
                                        if (null != t && t.Rows.Count > 0)
                                        {
                                            jDetail.GetType().GetProperty(col.ColumnName).SetValue(jDetail, t.Rows[0]["Id"]);
                                        }
                                        else
                                        {
                                            //var sModel = new StateModel
                                            //{
                                            //    CountryCode = jDetail.CountryCode,
                                            //    State = state,
                                            //    StateCode = string.Empty
                                            //};
                                            //bjpProcessor.InsertState(ref sModel);
                                            //if (!string.IsNullOrWhiteSpace(sModel.StateCode))
                                            //{
                                            //    jDetail.GetType().GetProperty(col.ColumnName).SetValue(jDetail, sModel.StateCode);
                                            //}
                                            //else
                                            //{
                                            row[additionalColumns[2]]  = "Failed";
                                            row[additionalColumns[3]] += "<li>State Not Found In Our Record</li>";
                                            //}
                                            InformToAdmin(row[col.ColumnName], col.ColumnName, user.Email, user.FullName);
                                        }

                                        break;

                                    case "CityCode":
                                        string city = Convert.ToString(row[col.ColumnName]);
                                        t =
                                            bjpProcessor.GetIdFromValue(city, col.ColumnName);
                                        if (null != t && t.Rows.Count > 0)
                                        {
                                            jDetail.GetType().GetProperty(col.ColumnName).SetValue(jDetail, t.Rows[0]["Id"]);
                                        }
                                        else
                                        {
                                            //var cModel = new CityModel
                                            //{
                                            //    City = city,
                                            //    CityCode = string.Empty,
                                            //    StateCode = jDetail.StateCode
                                            //};
                                            //bjpProcessor.InsertCity(ref cModel);
                                            //if (!string.IsNullOrWhiteSpace(cModel.CityCode))
                                            //{
                                            //    jDetail.GetType().GetProperty(col.ColumnName).SetValue(jDetail, cModel.CityCode);
                                            //}
                                            //else
                                            //{
                                            row[additionalColumns[2]]  = "Failed";
                                            row[additionalColumns[3]] += "<li>City Not Found In Our Record</li>";
                                            //}
                                            InformToAdmin(row[col.ColumnName], col.ColumnName, user.Email, user.FullName);
                                        }
                                        break;

                                    case "SPOCEmail":
                                        string email = Convert.ToString(row[col.ColumnName]);
                                        if (!string.IsNullOrWhiteSpace(email) && email != Constants.NotAvailalbe)
                                        {
                                            if (!emailHandler.IsValidEmail(email))
                                            {
                                                row[additionalColumns[2]]  = "Failed";
                                                row[additionalColumns[3]] += $"<li>SPOC email is not in valid format, please use {Constants.NotAvailalbe} if SPOC email is not available.</li>";
                                            }
                                        }
                                        break;

                                    case "CompanyName":
                                        string companyName = Convert.ToString(row[col.ColumnName]);
                                        if (!authProcessor.CheckIfEmployerExists(companyName, true))
                                        {
                                            string mailId = companyName.ToLower().Replace(" ", "_");
                                            var    u      = new UserModel
                                            {
                                                CompanyName = companyName,
                                                Email       = mailId,
                                                Password    = RandomGenerator.GetRandom(),
                                                RoleId      = 3,
                                                ProfilePic  = string.Empty
                                            };
                                            bool isRegister = authProcessor.RegisterEmployer(u, true);
                                        }
                                        t =
                                            bjpProcessor.GetIdFromValue(companyName, col.ColumnName);
                                        if (null != t && t.Rows.Count > 0)
                                        {
                                            jDetail.Userid = Convert.ToInt32(t.Rows[0]["Id"]);
                                        }
                                        else
                                        {
                                            row[additionalColumns[2]]  = "Failed";
                                            row[additionalColumns[3]] += "<li>User Not Found In Our Record</li>";
                                        }
                                        break;

                                    default:
                                        break;
                                    }
                                }

                                if ("Failed" != Convert.ToString(row[additionalColumns[2]]))
                                {
                                    jDetail.IsFromBulkUpload = true;
                                    jDetail.CreatedBy        = Convert.ToString(user.UserId);
                                    var date = DateTime.Now;
                                    jDetail.FinancialYear = date.Year;
                                    //ValidateJobModel(ref jDetail);
                                    if (jobPostProcessor.AddJobPostData(jDetail))
                                    {
                                        row[additionalColumns[2]] = "Success";
                                    }
                                    else
                                    {
                                        row[additionalColumns[2]] = "Failed";
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                row[additionalColumns[2]]  = "Failed";
                                row[additionalColumns[3]] += $"<li>{ex.Message}</li>";
                            }
                            sData = AddSummary(row);
                            fileSummary.Summary.Add(sData);
                            SaveDetailToAudit(sData, fileSummary.FileName, user.UserId);
                        }
                    }
                    else
                    {
                        throw new DataNotFound(
                                  string.Format("{0}", "Data not found in file to import."));
                    }
                    summary.Add(fileSummary);
                }
                return(summary);
            }
            else
            {
                throw new XmlFileMapperException(
                          string.Format("{0}", "JobPostMapping.xml file is not in proper format to convert in data table."));
            }
        }