public static List <ExpertiseWithSubjectDto> EwithSList()
        {
            List <ExpertiseWithSubjectDto> EwithSDtos;

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                EwithSDtos = placementDepartmentDB.Expertise
                             .SelectMany(e => e.Subject.Select(s =>
                                                               new ExpertiseWithSubjectDto()
                {
                    expertise = new ExpertiseDto()
                    {
                        Id   = e.Id,
                        name = e.name
                    },
                    subject = new SubjectDto()
                    {
                        Id   = s.Id,
                        name = s.name
                    }
                }
                                                               )).ToList();
                return(EwithSDtos);
            }
        }
        public static List <ChartData> GetJobsOpenedChart(DateTime start, DateTime end, int userid, int curUserid)
        {
            List <ChartData> res = new List <ChartData>
            {
                new ChartData("משרות שנפתחו בין " + start.ToShortDateString() + " לבין " + end.ToShortDateString())
            };
            bool isManagar = false;

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                User cuser = placementDepartmentDB.User.Find(curUserid);
                if (cuser.permissionId == 1 && curUserid == userid)
                {
                    isManagar = true;
                }
                if (cuser.permissionId == 2 && curUserid != userid)
                {
                    userid = curUserid;
                }
                res[0].data = placementDepartmentDB.Subject
                              .Select(s => s.Job
                                      .Where(j =>
                                             (isManagar || j.handlesId == userid) &&
                                             j.dateReceived >= start && j.dateReceived <= end)
                                      .Count())
                              .ToList();
            }
            return(res);
        }
        public static List <ChartData> GetPlacementsChart(DateTime start, DateTime end, int userid, int curUserid)
        {
            List <ChartData> res = new List <ChartData>
            {
                new ChartData("השמות בין " + start.ToShortDateString() + " לבין " + end.ToShortDateString())
            };
            bool isManagar = false;

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                User cuser = placementDepartmentDB.User.Find(curUserid);
                if (cuser.permissionId == 1 && curUserid == userid)
                {
                    isManagar = true;
                }
                if (cuser.permissionId == 2 && curUserid != userid)
                {
                    userid = curUserid;
                }
                res[0].data = placementDepartmentDB.Subject
                              .Select(s => s.Job
                                      .Where(j =>
                                             (isManagar || j.handlesId == userid) &&
                                             j.isActive == false && j.ReasonForClosingThePosition.description == "בוצעה השמה" &&
                                             j.lastUpdateDate >= start && j.lastUpdateDate <= end)
                                      .Count())
                              .ToList();
            }
            return(res);
        }
        public static void NewUser(UserDto userDto)
        {
            User user = AutoMapperConfiguration.mapper.Map <User>(userDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                try
                {
                    placementDepartmentDB.Configuration.ValidateOnSaveEnabled = false;
                    placementDepartmentDB.User.Add(user);
                    placementDepartmentDB.SaveChanges();
                }
                catch (DbUpdateException ex)
                {
                    var sqlException = ex.GetBaseException() as SqlException;
                    if (sqlException != null)
                    {
                        if (sqlException.Number == 2627)
                        {
                            throw new Exception("Duplicate");
                        }
                    }
                }
            }
        }
        public static void UserEditing(UserDto userDto)
        {
            User user = AutoMapperConfiguration.mapper.Map <User>(userDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                try
                {
                    placementDepartmentDB.Configuration.ValidateOnSaveEnabled = false;
                    placementDepartmentDB.User.Attach(user);
                    placementDepartmentDB.Entry(user).Property(x => x.name).IsModified         = true;
                    placementDepartmentDB.Entry(user).Property(x => x.email).IsModified        = true;
                    placementDepartmentDB.Entry(user).Property(x => x.permissionId).IsModified = true;
                    placementDepartmentDB.Entry(user).Property(x => x.isActive).IsModified     = true;

                    placementDepartmentDB.SaveChanges();
                }
                catch (DbUpdateException ex)
                {
                    var sqlException = ex.GetBaseException() as SqlException;
                    if (sqlException != null)
                    {
                        if (sqlException.Number == 2627)
                        {
                            throw new Exception("Duplicate");
                        }
                    }
                }
            }
        }
예제 #6
0
 public static void placedGraduateJob(List <int> idCRDs)
 {
     using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
     {
         foreach (var idCRD in idCRDs)
         {
             CoordinatingJobsForGraduates coordinating = placementDepartmentDB.CoordinatingJobsForGraduates.Find(idCRD);
             coordinating.placementStatus       = 6;
             coordinating.JobCoordinationStatus = null;
             coordinating.lastUpdateDate        = DateTime.Now;
             //Job
             coordinating.Job.isActive                    = false;
             coordinating.Job.reasonForClosing            = 5; //work
             coordinating.Job.ReasonForClosingThePosition = null;
             coordinating.Job.lastUpdateDate              = DateTime.Now;
             //Graduate
             coordinating.Graduate.isWorkerInProfession           = true;
             coordinating.Graduate.placedByThePlacementDepartment = true;
             coordinating.Graduate.lastUpdate  = DateTime.Now;
             coordinating.Graduate.companyName = coordinating.Job.Contact.Company.name;
             coordinating.Graduate.role        = coordinating.Job.Subject.name;
             placementDepartmentDB.SaveChanges();
         }
     }
 }
예제 #7
0
 public static void JobsCoordinationUpdate(List <int> idCoordinatingJobsForGraduate, int statusId)
 {
     if (statusId == 6)//work
     {
         placedGraduateJob(idCoordinatingJobsForGraduate);
     }
     else
     {
         List <CoordinatingJobsForGraduates> coordinations = new List <CoordinatingJobsForGraduates>();
         foreach (var item in idCoordinatingJobsForGraduate)
         {
             coordinations.Add(new CoordinatingJobsForGraduates()
             {
                 Id = item,
                 placementStatus = statusId,
                 lastUpdateDate  = DateTime.Now
             });
         }
         using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
         {
             foreach (var coordination in coordinations)
             {
                 placementDepartmentDB.Configuration.ValidateOnSaveEnabled = false;
                 placementDepartmentDB.CoordinatingJobsForGraduates.Attach(coordination);
                 placementDepartmentDB.Entry(coordination).Property(x => x.placementStatus).IsModified = true;
                 placementDepartmentDB.Entry(coordination).Property(x => x.lastUpdateDate).IsModified  = true;
             }
             placementDepartmentDB.SaveChanges();
         }
     }
 }
        public static List <JobDto> JobListByFilters(JobFilters filters)
        {
            List <JobDto> JobDtos;

            filters.sendCV   = filters.sendCV ?? new List <bool>();
            filters.active   = filters.active ?? new List <bool>();
            filters.subjects = filters.subjects ?? new List <int>();
            DateTime dateMonthAgo = new DateTime(DateTime.Now.Year, DateTime.Now.Month - 1, DateTime.Now.Day);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                JobDtos = placementDepartmentDB.Job
                          .Where(j =>
                                 (!filters.sendCV.Any() || filters.sendCV.Contains(j.didSendCV)) &&
                                 (!filters.active.Any() || filters.active.Contains(j.isActive)) &&
                                 (filters.period == 0 ||
                                  filters.period == 1 && j.dateReceived >= dateMonthAgo ||
                                  filters.period == 2 && j.dateReceived >= filters.startDate && j.dateReceived <= filters.endDate) &&
                                 (!filters.subjects.Any() || filters.subjects.Contains(j.subjectId))
                                 )
                          .ProjectTo <JobDto>(AutoMapperConfiguration.config)
                          .ToList();
                return(JobDtos);
            }
        }
        public static FullGraduateDto NewGraduate(FullGraduateDto graduateDto)
        {
            Graduate graduate = AutoMapperConfiguration.mapper.Map <Graduate>(graduateDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                try
                {
                    graduate.dateOfRegistration = graduate.lastUpdate = DateTime.Now;
                    var res = placementDepartmentDB.Graduate.Add(graduate);
                    placementDepartmentDB.SaveChanges();
                    return(AutoMapperConfiguration.mapper.Map <FullGraduateDto>(res));
                }
                catch (DbUpdateException ex)
                {
                    var sqlException = ex.GetBaseException() as SqlException;
                    if (sqlException != null)
                    {
                        if (sqlException.Number == 2627)
                        {
                            throw new Exception("Duplicate");
                        }
                    }
                    return(null);
                }
            }
        }
        public static ApiRes <MainGraduateDto> GraduateLazyList(GraduateFilters filters, string sort, int page, int size)
        {
            ApiRes <MainGraduateDto> res = new ApiRes <MainGraduateDto>();

            sort                = sort == " ," || sort == " , " ? "" : sort;
            filters.active      = filters.active ?? new List <bool>();
            filters.gender      = filters.gender ?? new List <string>();
            filters.didGraduate = filters.didGraduate ?? new List <bool>();
            filters.hasDiploma  = filters.hasDiploma ?? new List <bool>();
            filters.isWork      = filters.isWork ?? new List <bool>();
            filters.expertise   = filters.expertise ?? new List <int>();
            filters.branch      = filters.branch ?? new List <int>();
            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                res.items = placementDepartmentDB.Graduate
                            .Where(g =>
                                   (g.firstName + " " + g.lastName).IndexOf(filters.name) != -1 &&
                                   (!filters.active.Any() || filters.active.Contains(g.isActive)) &&
                                   (!filters.gender.Any() || filters.gender.Contains(g.gender)) &&
                                   (!filters.didGraduate.Any() || filters.didGraduate.Contains(g.didGraduate)) &&
                                   (!filters.hasDiploma.Any() || filters.hasDiploma.Contains(g.hasDiploma)) &&
                                   (!filters.isWork.Any() || filters.isWork.Contains(g.isWorkerInProfession)) &&
                                   (filters.period == 0 ||
                                    filters.period == 1 && g.dateOfRegistration == DateTime.Now ||
                                    filters.period == 2 && g.dateOfRegistration >= filters.startDate && g.dateOfRegistration <= filters.endDate) &&
                                   (!filters.expertise.Any() || filters.expertise.Contains(g.expertiseId)) &&
                                   (!filters.branch.Any() || filters.branch.Contains(g.branchId))
                                   )
                            .OrderBy(sort + "dateOfRegistration desc")
                            .Skip(page * size)
                            .Take(size)
                            .Select(g => new MainGraduateDto()
                {
                    Id            = g.Id,
                    Name          = g.firstName + " " + g.lastName,
                    branchName    = g.Branch.name,
                    expertiseName = g.Expertise.name,
                    endYear       = g.endYear,
                    isActive      = g.isActive
                }).ToList();
                res.totalCount = placementDepartmentDB.Graduate.Where(g =>
                                                                      (g.firstName + " " + g.lastName).IndexOf(filters.name) != -1 &&
                                                                      (!filters.active.Any() || filters.active.Contains(g.isActive)) &&
                                                                      (!filters.gender.Any() || filters.gender.Contains(g.gender)) &&
                                                                      (!filters.didGraduate.Any() || filters.didGraduate.Contains(g.didGraduate)) &&
                                                                      (!filters.hasDiploma.Any() || filters.hasDiploma.Contains(g.hasDiploma)) &&
                                                                      (!filters.isWork.Any() || filters.isWork.Contains(g.isWorkerInProfession)) &&
                                                                      (filters.period == 0 ||
                                                                       filters.period == 1 && g.dateOfRegistration == DateTime.Now ||
                                                                       filters.period == 2 && g.dateOfRegistration >= filters.startDate && g.dateOfRegistration <= filters.endDate) &&
                                                                      (!filters.expertise.Any() || filters.expertise.Contains(g.expertiseId)) &&
                                                                      (!filters.branch.Any() || filters.branch.Contains(g.branchId))
                                                                      ).Count();
                return(res);
            }
        }
 public static void DeleteEwithS(int idExpertise, int idSubject)
 {
     using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
     {
         Expertise expertise = placementDepartmentDB.Expertise.Find(idExpertise);
         Subject   subject   = expertise.Subject.Single(s => s.Id == idSubject);
         expertise.Subject.Remove(subject);
         placementDepartmentDB.SaveChanges();
     }
 }
        public static UserDto UserById(int Id)
        {
            User user;

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                user = placementDepartmentDB.User.Find(Id);
                return(AutoMapperConfiguration.mapper.Map <UserDto>(user));
            }
        }
        public static FullGraduateDto GraduateById(string Id)
        {
            Graduate Ret;

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                Ret = placementDepartmentDB.Graduate.Find(Id);
                return(AutoMapperConfiguration.mapper.Map <FullGraduateDto>(Ret));
            }
        }
        public static JobDto JobById(int Id)
        {
            Job Ret;

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                Ret = placementDepartmentDB.Job.Find(Id);
                return(AutoMapperConfiguration.mapper.Map <JobDto>(Ret));
            }
        }
예제 #15
0
        public static CompanyDto CompanyById(int Id)
        {
            Company Ret;

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                Ret = placementDepartmentDB.Company.Find(Id);
                return(AutoMapperConfiguration.mapper.Map <CompanyDto>(Ret));
            }
        }
예제 #16
0
        public static void NewCompany(CompanyDto companyDto)
        {
            Company company = AutoMapperConfiguration.mapper.Map <Company>(companyDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                placementDepartmentDB.Company.Add(company);
                placementDepartmentDB.SaveChanges();
            }
        }
        public static void editExpertise(ExpertiseDto expertiseDto)
        {
            Expertise expertise = AutoMapperConfiguration.mapper.Map <Expertise>(expertiseDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                placementDepartmentDB.Expertise.Attach(expertise);
                placementDepartmentDB.Entry(expertise).State = EntityState.Modified;
                placementDepartmentDB.SaveChanges();
            }
        }
        public static int NewExpertise(ExpertiseDto expertiseDto)
        {
            Expertise expertise = AutoMapperConfiguration.mapper.Map <Expertise>(expertiseDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                expertise = placementDepartmentDB.Expertise.Add(expertise);
                placementDepartmentDB.SaveChanges();
                return(expertise.Id);
            }
        }
예제 #19
0
        public static void CompanyEditing(CompanyDto companyDto)
        {
            Company company = AutoMapperConfiguration.mapper.Map <Company>(companyDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                placementDepartmentDB.Company.Attach(company);
                placementDepartmentDB.Entry(company).State = EntityState.Modified;
                placementDepartmentDB.SaveChanges();
            }
        }
예제 #20
0
        public static int NewSubject(SubjectDto SubjectDto)
        {
            Subject Subject = AutoMapperConfiguration.mapper.Map <Subject>(SubjectDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                Subject = placementDepartmentDB.Subject.Add(Subject);
                placementDepartmentDB.SaveChanges();
                return(Subject.Id);
            }
        }
예제 #21
0
        public static void editSubject(SubjectDto SubjectDto)
        {
            Subject Subject = AutoMapperConfiguration.mapper.Map <Subject>(SubjectDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                placementDepartmentDB.Subject.Attach(Subject);
                placementDepartmentDB.Entry(Subject).State = EntityState.Modified;
                placementDepartmentDB.SaveChanges();
            }
        }
예제 #22
0
        public static int NewLanguage(LanguageDto LanguageDto)
        {
            Language Language = AutoMapperConfiguration.mapper.Map <Language>(LanguageDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                Language = placementDepartmentDB.Language.Add(Language);
                placementDepartmentDB.SaveChanges();
                return(Language.Id);
            }
        }
예제 #23
0
        public static void editLanguage(LanguageDto LanguageDto)
        {
            Language Language = AutoMapperConfiguration.mapper.Map <Language>(LanguageDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                placementDepartmentDB.Language.Attach(Language);
                placementDepartmentDB.Entry(Language).State = EntityState.Modified;
                placementDepartmentDB.SaveChanges();
            }
        }
        public static int NewCity(CityDto CityDto)
        {
            City City = AutoMapperConfiguration.mapper.Map <City>(CityDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                City = placementDepartmentDB.City.Add(City);
                placementDepartmentDB.SaveChanges();
                return(City.Id);
            }
        }
        public static void editCity(CityDto CityDto)
        {
            City City = AutoMapperConfiguration.mapper.Map <City>(CityDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                placementDepartmentDB.City.Attach(City);
                placementDepartmentDB.Entry(City).State = EntityState.Modified;
                placementDepartmentDB.SaveChanges();
            }
        }
예제 #26
0
        public static void NewContact(ContactDto contactDto)
        {
            Contact contact = AutoMapperConfiguration.mapper.Map <Contact>(contactDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                placementDepartmentDB.Configuration.ValidateOnSaveEnabled = false;
                placementDepartmentDB.Contact.Add(contact);
                placementDepartmentDB.SaveChanges();
            }
        }
        public static void editBranch(BranchDto branchDto)
        {
            Branch branch = AutoMapperConfiguration.mapper.Map <Branch>(branchDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                placementDepartmentDB.Branch.Attach(branch);
                placementDepartmentDB.Entry(branch).State = EntityState.Modified;
                placementDepartmentDB.SaveChanges();
            }
        }
        public static int NewBranch(BranchDto branchDto)
        {
            Branch branch = AutoMapperConfiguration.mapper.Map <Branch>(branchDto);

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                branch = placementDepartmentDB.Branch.Add(branch);
                placementDepartmentDB.SaveChanges();
                return(branch.Id);
            }
        }
        public static List <string> get0TitleAnd1ContactMailOfJobById(int Id)
        {
            List <string> detailes = new List <string>();

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                detailes.Add(placementDepartmentDB.Job.Find(Id).title);
                detailes.Add(placementDepartmentDB.Job.Find(Id).Contact.email);
                return(detailes);
            }
        }
예제 #30
0
        public static List <CoordinatingJobsForGraduates> NewJobsCoordination(List <CoordinatingJobsForGraduates> JobsCoordination)
        {
            List <CoordinatingJobsForGraduates> res;

            using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities())
            {
                res = placementDepartmentDB.CoordinatingJobsForGraduates.AddRange(JobsCoordination).ToList();
                placementDepartmentDB.SaveChanges();
                return(res);
            }
        }