public static Entities.Part PartEntities(DAL.Part p) { return(new Entities.Part() { PartId = p.PartId, PartName = p.PartName }); }
public static List <JobView> JobView(List <Job> job) { try { using (DAL.IdialEntities3 dbn = new DAL.IdialEntities3()) { //new connection to the database dbn.Database.Connection.Open(); String diff2 = ""; List <Entities.JobView> jv = new List <JobView>(); DateTime temp; foreach (var item in job) { DAL.Workspace w = dbn.Workspace.FirstOrDefault(p1 => p1.WSId == item.JobWorkspaceId); DAL.SubjectJob s = dbn.SubjectJob.FirstOrDefault(p1 => p1.SubId == item.JobSubId); DAL.OutNet outNet = dbn.OutNet.FirstOrDefault(o => o.OutNetId == item.JobPartOutNetId); DAL.Company company = dbn.Company.FirstOrDefault(q => q.CompanyId == item.JobCompanyId); DAL.City city = dbn.City.FirstOrDefault(c => c.CityId == company.CompanyCityId); DAL.Area area = dbn.Area.FirstOrDefault(a => a.AreaId == company.CompanyAreaId); DAL.SubjectJob SubjectJob = dbn.SubjectJob.FirstOrDefault(o => o.SubId == item.JobSubId); DAL.Part p = dbn.Part.FirstOrDefault(s2 => s2.PartId == item.JobPartId); DAL.Job job1 = dbn.Job.FirstOrDefault(j => j.JobId == item.JobId); Entities.JobView v = new JobView(); DateTime.TryParse(item.JobDateAdv.ToString(), out temp); if (temp != null) { diff2 = Convert.ToInt32((DateTime.Today - temp).TotalDays).ToString(); } v = Entities.JobView.CreateJobView(area, company, job1, SubjectJob, w, p, outNet, city, diff2); jv.Add(v); } db.Database.Connection.Close(); return(jv); } //DAL.IdialEntities3.Connection.Open(); } catch (Exception e) { BL.SendMail.SendEmail(e.ToString(), e.Message, ""); BL.WriteLogError.WriteLogErrors(e.Message); return(null); } }
//public JobView():base() //{ //} public static Entities.JobView CreateJobView(DAL.Area a, DAL.Company c, DAL.Job j, DAL.SubjectJob s, DAL.Workspace w, DAL.Part p, DAL.OutNet o, DAL.City ci, string diff) { return(new Entities.JobView() { JobDateAdv = j.JobDateAdv, JobDateShow = diff, CompanyName = c.CompanyName, CompanyId = c.CompanyId, JobRole = j.JobRole, JobDateCaughtJob = j.JobDateCaughtJob, PartName = p.PartName, OutNetName = o.OutNetName, WSName = w.WSName, JobExperience = j.JobExperience, JobStars = j.JobStars, JobDescribe = j.JobDescribe, AreaName = a.AreaName, BossId = j.JobBossId, CityName = ci.CityName, SubjectName = s.SubName, JobRequire = j.JobRequire, JobId = j.JobId }); }