Exemple #1
0
        public async Task <IActionResult> EditJob(long id)
        {
            ClientJobViewModel model = new ClientJobViewModel();

            model.businessstreams = new List <SelectListItem>();
            model.businessstreams.Add(new SelectListItem
            {
                Value = "",
                Text  = "-- 業界選択 --"
            });

            var businessstreams = _businessRepository.GetAll();

            foreach (var BusinessStrem in businessstreams)
            {
                model.businessstreams.Add(new SelectListItem
                {
                    Value = Convert.ToString(BusinessStrem.Id),
                    Text  = BusinessStrem.Name_jp
                });
            }

            if (model.Provinces.Count == 0)
            {
                model.Provinces = new List <SelectListItem>();
                model.Provinces.Add(new SelectListItem
                {
                    Value = "",
                    Text  = "--Choose--"
                });

                var provinces = _provinceRepository.GetAll();

                foreach (var prov in provinces)
                {
                    model.Provinces.Add(new SelectListItem
                    {
                        Value = Convert.ToString(prov.Id),
                        Text  = prov.Name_Jp
                    });
                }
            }

            Job job           = _jobsRepository.GetJobsById(id);
            var jobCategories = await _jobCategoryRepository.FindByAsyn(x => x.BusinessStreamId == job.BusinessStreamID);

            var postalCode = _postalCodeRepository.GetById(job.PostalCodeId);
            var province   = _provinceRepository.GetById(postalCode.ProvinceID);

            List <SelectListItem> jobCategoryList = new List <SelectListItem>();

            foreach (var jobcategory in jobCategories)
            {
                jobCategoryList.Add(new SelectListItem()
                {
                    Value = Convert.ToString(jobcategory.Id),
                    Text  = jobcategory.CategoryName_JP,
                });
            }
            var postalArry = postalCode.Code.Split('-');

            if (postalArry.Length > 0)
            {
                model.PostalAddrss1 = postalArry[0];
                model.PostalAddrss2 = postalArry[1];
            }
            model.ProvinceID         = province.Id;
            model.CityName           = postalCode.CityName;
            model.Town               = postalCode.Town;
            model.JobCategories      = jobCategoryList;
            model.JobId              = job.Id;
            model.Workinghour        = job.Workinghour;
            model.WorkingDaysPerWeek = job.WorkingdaysPerweek;
            model.JapaneseLevel      = job.JapaneseLevel_Text;
            model.BusinessstreamID   = job.BusinessStreamID;
            model.ClientID           = job.ClientId;
            model.ContractType       = job.ContractType_Text;
            model.Salary_Monthly     = job.Salary_Monthly;
            model.Salary_Hourly      = job.Salary_Hourly;
            model.NeededStaff        = job.NeededStaff;
            model.TransportationFee  = job.Transporationfee;
            model.Address            = job.WorkLocationAddress;
            model.ProvinceName       = job.provinceName;
            model.JobCategoryId      = job.JobTitle;
            model.WorkStartTime      = job.StartWorkingTime;
            model.WorkEndTime        = job.EndWorkingTime;
            model.Status             = job.Status;
            //if (!string.IsNullOrEmpty(job.WorkingTime))
            //{
            //    string []workingtime = job.WorkingTime.Split("-");
            //    if(workingtime.Length > 0)
            //    {
            //        model.WorkStartTime = workingtime[0];
            //        model.WorkEndTime = workingtime[1];
            //    }
            //}
            model.MinAge = job.MinAge;
            model.MaxAge = job.MaxAge;

            //if (!string.IsNullOrEmpty(job.RequiredAge))
            //{
            //    string[] requiredages = job.RequiredAge.Split("-");
            //    if(requiredages.Length > 0)
            //    {
            //        model.MinAge = Convert.ToInt32(requiredages[0]);
            //        model.MaxAge = Convert.ToInt32(requiredages[1]);
            //    }
            //}
            return(View(model));
        }