Exemplo n.º 1
0
 public static EmployeeInfoModel UpdateEmployeeBasicInfo(EmployeeInfoModel model)
 {
     using (var context = new MakeMyJobsEntities())
     {
         int updated  = 0;
         var user     = context.Users.FirstOrDefault(x => x.UserId == model.userId && x.IsActive == 1);
         var employee = context.Employees.FirstOrDefault(x => x.EmployeeId == model.employeeId);
         if (user == null || employee == null)
         {
             return(null);
         }
         else
         {
             user.Email             = model.email;
             updated               += context.SaveChanges();
             employee.FirstName     = model.firstName;
             employee.LastName      = model.lastName;
             employee.ContactNumber = model.contactNumber;
             employee.DateOfBirth   = model.dateOfBirth;
             employee.City          = model.city;
             employee.Address       = model.address;
             employee.State         = model.state;
             employee.Country       = model.country;
             employee.ZipCode       = model.zipCode;
             updated               += context.SaveChanges();
         }
         return(GetUpdatedEmployeeInfo(user.UserId, employee.EmployeeId));
     }
 }
Exemplo n.º 2
0
 public static EmployeeInfoModel GetEmployeeInfoForEdit(int id)
 {
     using (var context = new MakeMyJobsEntities())
     {
         if (context.Employees.Any(x => x.UserId == id))
         {
             EmployeeInfoModel employeeInfoModel = context.Employees.Join(context.Users, e => e.UserId, u => u.UserId, (e, u) => new EmployeeInfoModel()
             {
                 employeeId    = e.EmployeeId,
                 userId        = e.UserId,
                 firstName     = e.FirstName,
                 lastName      = e.LastName,
                 city          = e.City,
                 contactNumber = e.ContactNumber,
                 dateOfBirth   = e.DateOfBirth,
                 resume        = e.Resume,
                 dateJoined    = e.DateJoined,
                 address       = e.Address,
                 state         = e.State,
                 country       = e.Country,
                 email         = u.Email,
                 zipCode       = e.ZipCode
             }).FirstOrDefault(x => x.userId == id);
             return(employeeInfoModel);
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 3
0
 private static StudentInfoModel GetUpdatedStudentInfo(int userId, int studentId)
 {
     using (var context = new MakeMyJobsEntities())
     {
         var user    = context.Users.FirstOrDefault(x => x.UserId == userId && x.IsActive == 1);
         var student = context.Students.FirstOrDefault(x => x.StudentId == studentId);
         if (user == null || student == null)
         {
             return(null);
         }
         else
         {
             return(new StudentInfoModel()
             {
                 userId = userId,
                 studentId = studentId,
                 email = user.Email,
                 firstName = student.FirstName,
                 lastName = student.LastName,
                 contactNumber = student.ContactNumber,
                 address = student.Address,
                 state = student.State,
                 country = student.Country,
                 dateOfBirth = student.DateOfBirth,
                 zipCode = student.ZipCode
             });
         }
     }
 }
Exemplo n.º 4
0
 public static int UploadResume(int employeeId, String fileName, String fileNameOnDisk, long fileSize)
 {
     using (var context = new MakeMyJobsEntities())
     {
         var previousResume = context.EmployeeDocuments.FirstOrDefault(x => x.EmployeeId == employeeId && x.DocumentType == 1);
         if (previousResume != null)
         {
             context.Entry(previousResume).State = System.Data.Entity.EntityState.Deleted;
         }
         else
         {
             context.EmployeeDocuments.Add(new EmployeeDocument()
             {
                 DocumentName       = fileName,
                 DocumentNameOnDisk = fileNameOnDisk,
                 DocumentSize       = fileSize,
                 DocumentType       = 1,
                 IsActive           = 1,
                 LastUpdatedOn      = DateTime.Now,
                 EmployeeId         = employeeId
             });
         }
         return(context.SaveChanges());
     }
 }
Exemplo n.º 5
0
 public static EmployeeEducationModel AddEmployeeEducation(EmployeeEducationModel model)
 {
     using (var context = new MakeMyJobsEntities())
     {
         EmployeeEducation employeeEducation = new EmployeeEducation();
         employeeEducation.EmployeeId    = model.employeeId;
         employeeEducation.InstituteName = model.instituteName;
         employeeEducation.InstituteType = model.instituteType;
         employeeEducation.JoinedOn      = model.joinedOn;
         employeeEducation.PassedOn      = model.passedOn;
         employeeEducation.Percentage    = Convert.ToDecimal(model.percentage);
         employeeEducation.IsActive      = 1;
         context.EmployeeEducations.Add(employeeEducation);
         int added = context.SaveChanges();
         if (added > 0)
         {
             return(new EmployeeEducationModel()
             {
                 empEducationId = employeeEducation.EmpEducationId,
                 employeeId = employeeEducation.EmployeeId,
                 instituteName = employeeEducation.InstituteName,
                 instituteType = employeeEducation.InstituteType,
                 joinedOn = employeeEducation.JoinedOn,
                 passedOn = employeeEducation.PassedOn,
                 percentage = employeeEducation.Percentage,
                 isActive = employeeEducation.IsActive
             });
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 6
0
 public static EmployeeExperienceModel AddEmployeeExperience(EmployeeExperienceModel model)
 {
     using (var context = new MakeMyJobsEntities())
     {
         EmployeeExperience employeeExperience = new EmployeeExperience();
         employeeExperience.EmployeeId  = model.employeeId;
         employeeExperience.CompanyName = model.companyName;
         employeeExperience.Position    = model.position;
         employeeExperience.JoinedOn    = model.joinedOn;
         employeeExperience.LeftOn      = model.leftOn;
         employeeExperience.IsActive    = 1;
         context.EmployeeExperiences.Add(employeeExperience);
         int added = context.SaveChanges();
         if (added > 0)
         {
             return(new EmployeeExperienceModel()
             {
                 empExperienceId = employeeExperience.EmpExperienceId,
                 employeeId = employeeExperience.EmployeeId,
                 companyName = employeeExperience.CompanyName,
                 position = employeeExperience.Position,
                 joinedOn = employeeExperience.JoinedOn,
                 leftOn = employeeExperience.LeftOn,
                 isActive = employeeExperience.IsActive
             });
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 7
0
 public static int CreateUser(SignupModel model)
 {
     using (var context = new MakeMyJobsEntities())
     {
         if (context.Users.Any(x => x.Email == model.email))
         {
             return(-1);
         }
         int  created = 0;
         User user    = new User();
         user.Email    = model.email;
         user.Password = model.password;
         user.UserType = model.userType;
         user.IsActive = 1;
         context.Users.Add(user);
         created += context.SaveChanges();
         if (model.userType == UserTypes.Student)
         {
             created += AccountBusiness.CreateStudent(model, user.UserId);
         }
         else if (model.userType == UserTypes.Employee)
         {
             created += AccountBusiness.CreateEmployee(model, user.UserId);
         }
         else
         {
             created += AccountBusiness.CreateCorporate(model, user.UserId);
         }
         return(created);
     }
 }
Exemplo n.º 8
0
 public static StudentInfoModel UpdateStudentInfo(StudentInfoModel model)
 {
     using (var context = new MakeMyJobsEntities())
     {
         StudentInfoModel studentInfo = new StudentInfoModel();
         int updated = 0;
         var user    = context.Users.FirstOrDefault(x => x.UserId == model.userId && x.IsActive == 1);
         var student = context.Students.FirstOrDefault(x => x.StudentId == model.studentId);
         if (user == null || student == null)
         {
             return(null);
         }
         else
         {
             user.Email            = model.email;
             updated              += context.SaveChanges();
             student.FirstName     = model.firstName;
             student.LastName      = model.lastName;
             student.ContactNumber = model.contactNumber;
             student.DateOfBirth   = model.dateOfBirth;
             student.CollegeName   = model.collegeName;
             student.Address       = model.address;
             student.State         = model.state;
             student.Country       = model.country;
             student.ZipCode       = model.zipCode;
             updated              += context.SaveChanges();
         }
         return(GetUpdatedStudentInfo(user.UserId, student.StudentId));
     }
 }
Exemplo n.º 9
0
 public static StudentInfoModel GetStudentInfoForEdit(int id)
 {
     using (var context = new MakeMyJobsEntities())
     {
         if (context.Students.Any(x => x.UserId == id))
         {
             StudentInfoModel studentInfoModel = context.Students.Join(context.Users, s => s.UserId, u => u.UserId, (s, u) => new StudentInfoModel()
             {
                 studentId     = s.StudentId,
                 userId        = s.UserId,
                 firstName     = s.FirstName,
                 lastName      = s.LastName,
                 collegeName   = s.CollegeName,
                 contactNumber = s.ContactNumber,
                 dateOfBirth   = s.DateOfBirth,
                 resume        = s.Resume,
                 dateJoined    = s.DateJoined,
                 address       = s.Address,
                 state         = s.State,
                 country       = s.Country,
                 email         = u.Email,
                 zipCode       = s.ZipCode
             }).FirstOrDefault(x => x.userId == id);
             return(studentInfoModel);
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 10
0
 private static EmployeeInfoModel GetUpdatedEmployeeInfo(int userId, int employeeId)
 {
     using (var context = new MakeMyJobsEntities())
     {
         var user     = context.Users.FirstOrDefault(x => x.UserId == userId && x.IsActive == 1);
         var employee = context.Employees.FirstOrDefault(x => x.EmployeeId == employeeId);
         if (user == null || employee == null)
         {
             return(null);
         }
         else
         {
             return(new EmployeeInfoModel()
             {
                 userId = userId,
                 employeeId = employeeId,
                 email = user.Email,
                 firstName = employee.FirstName,
                 lastName = employee.LastName,
                 contactNumber = employee.ContactNumber,
                 city = employee.City,
                 address = employee.Address,
                 state = employee.State,
                 country = employee.Country,
                 dateOfBirth = employee.DateOfBirth,
                 zipCode = employee.ZipCode
             });
         }
     }
 }
Exemplo n.º 11
0
 public static List <DropdownModel> GetSalaryDivision()
 {
     using (var context = new MakeMyJobsEntities())
     {
         return(context.Lookups.Where(x => x.LookUpCategory == 3).Select(x => new DropdownModel()
         {
             value = x.LookupId,
             text = x.Name
         }).ToList());
     }
 }
Exemplo n.º 12
0
 public static List <DropdownModel> GetTags()
 {
     using (var context = new MakeMyJobsEntities())
     {
         return(context.Tags.Select(x => new DropdownModel()
         {
             value = x.TagId,
             text = x.TagName
         }).ToList());
     }
 }
Exemplo n.º 13
0
 public static int CreateStudent(SignupModel model, int userId)
 {
     using (var context = new MakeMyJobsEntities())
     {
         context.Students.Add(new Student()
         {
             FirstName  = model.firstName,
             LastName   = model.lastName,
             UserId     = userId,
             State      = 0,
             Country    = 0,
             DateJoined = DateTime.Now,
             IsActive   = 1
         });
         return(context.SaveChanges());
     }
 }
Exemplo n.º 14
0
        public static StudentInfoModel GetStudentInfo(int id)
        {
            using (var context = new MakeMyJobsEntities())
            {
                if (context.Students.Any(x => x.UserId == id))
                {
                    StudentInfoModel studentInfoModel = context.Students.Join(context.States, s => s.State, st => st.StateId, (s, st) => new
                    {
                        StateName = st.StateName,
                        student   = s
                    }).Join(context.Countries, s => s.student.Country, c => c.CountryId, (s, c) => new
                    {
                        student     = s,
                        stateName   = s.StateName,
                        countryName = c.CountryName
                    }).Join(context.Users, s => s.student.student.UserId, u => u.UserId, (s, u) => new StudentInfoModel()
                    {
                        studentId     = s.student.student.StudentId,
                        userId        = s.student.student.UserId,
                        firstName     = s.student.student.FirstName,
                        lastName      = s.student.student.LastName,
                        collegeName   = s.student.student.CollegeName,
                        contactNumber = s.student.student.ContactNumber,
                        dateOfBirth   = s.student.student.DateOfBirth,
                        resume        = s.student.student.Resume,
                        dateJoined    = s.student.student.DateJoined,
                        address       = s.student.student.Address + ", " + s.student.StateName + ", " + s.countryName,
                        state         = s.student.student.State,
                        country       = s.student.student.Country,
                        email         = u.Email,
                        zipCode       = s.student.student.ZipCode
                    }).FirstOrDefault(x => x.userId == id);

                    if (context.StudentDocuments.Any(x => x.StudentId == studentInfoModel.studentId && x.DocumentType == StudentDocumentTypes.Resume))
                    {
                        studentInfoModel.resume = "1";
                    }

                    return(studentInfoModel);
                }
                else
                {
                    return(null);
                }
            }
        }
Exemplo n.º 15
0
 public static bool DeleteEmployeeEducation(int id)
 {
     using (var context = new MakeMyJobsEntities())
     {
         var employeeEducation = context.EmployeeEducations.FirstOrDefault(x => x.EmpEducationId == id);
         if (employeeEducation != null)
         {
             employeeEducation.IsActive = 2;
             int deleted = context.SaveChanges();
             return(deleted > 0);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 16
0
 public static LoginResponseModel Login(LoginModel model)
 {
     using (var context = new MakeMyJobsEntities())
     {
         User user = context.Users.FirstOrDefault(x => x.Email == model.email && x.Password == model.password && x.IsActive == 1);
         LoginResponseModel loginResponse = new LoginResponseModel();
         if (user != null)
         {
             loginResponse.loggedIn = 1;
             if (user.UserType == UserTypes.Student)
             {
                 Student student = context.Students.FirstOrDefault(x => x.UserId == user.UserId);
                 loginResponse.firstName = student.FirstName;
                 loginResponse.lastName  = student.LastName;
                 loginResponse.userId    = student.UserId;
                 loginResponse.email     = user.Email;
                 loginResponse.userType  = user.UserType;
             }
             else if (user.UserType == UserTypes.Employee)
             {
                 Employee employee = context.Employees.FirstOrDefault(x => x.UserId == user.UserId);
                 loginResponse.firstName = employee.FirstName;
                 loginResponse.lastName  = employee.LastName;
                 loginResponse.userId    = employee.UserId;
                 loginResponse.email     = user.Email;
                 loginResponse.userType  = user.UserType;
             }
             else
             {
                 Corporate corporate = context.Corporates.FirstOrDefault(x => x.UserId == user.UserId);
                 loginResponse.firstName = corporate.FirstName;
                 loginResponse.lastName  = corporate.LastName;
                 loginResponse.userId    = corporate.UserId;
                 loginResponse.email     = user.Email;
                 loginResponse.userType  = user.UserType;
             }
         }
         else
         {
             loginResponse.loggedIn = 0;
         }
         return(loginResponse);
     }
 }
Exemplo n.º 17
0
 public static EmployeeExperienceModel EditEmployeeExperience(EmployeeExperienceModel model)
 {
     using (var context = new MakeMyJobsEntities())
     {
         EmployeeExperience employeeExperience = context.EmployeeExperiences.FirstOrDefault(x => x.EmpExperienceId == model.empExperienceId);
         if (employeeExperience != null)
         {
             employeeExperience.EmployeeId  = model.employeeId;
             employeeExperience.CompanyName = model.companyName;
             employeeExperience.Position    = model.position;
             employeeExperience.JoinedOn    = model.joinedOn;
             employeeExperience.LeftOn      = model.leftOn;
             employeeExperience.IsActive    = 1;
             int updated = context.SaveChanges();
             if (updated > 0)
             {
                 return(new EmployeeExperienceModel()
                 {
                     empExperienceId = employeeExperience.EmpExperienceId,
                     employeeId = employeeExperience.EmployeeId,
                     companyName = employeeExperience.CompanyName,
                     position = employeeExperience.Position,
                     joinedOn = employeeExperience.JoinedOn,
                     leftOn = employeeExperience.LeftOn,
                     isActive = employeeExperience.IsActive
                 });
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 18
0
 public static EmployeeEducationModel EditEmployeeEducation(EmployeeEducationModel model)
 {
     using (var context = new MakeMyJobsEntities())
     {
         EmployeeEducation employeeEducation = context.EmployeeEducations.FirstOrDefault(x => x.EmpEducationId == model.empEducationId);
         if (employeeEducation != null)
         {
             employeeEducation.EmployeeId    = model.employeeId;
             employeeEducation.InstituteName = model.instituteName;
             employeeEducation.InstituteType = model.instituteType;
             employeeEducation.JoinedOn      = model.joinedOn;
             employeeEducation.PassedOn      = model.passedOn;
             employeeEducation.IsActive      = 1;
             int updated = context.SaveChanges();
             if (updated > 0)
             {
                 return(new EmployeeEducationModel()
                 {
                     empEducationId = employeeEducation.EmpEducationId,
                     employeeId = employeeEducation.EmployeeId,
                     instituteName = employeeEducation.InstituteName,
                     instituteType = employeeEducation.InstituteType,
                     joinedOn = employeeEducation.JoinedOn,
                     passedOn = employeeEducation.PassedOn,
                     isActive = employeeEducation.IsActive
                 });
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 19
0
 public static int ChangePassword(ChangePasswordModel model)
 {
     using (var context = new MakeMyJobsEntities())
     {
         var user = context.Users.FirstOrDefault(x => x.UserId == model.userId && x.IsActive == 1 && x.Password == model.currentPassword);
         if (user == null)
         {
             return(0);
         }
         else
         {
             user.Password = model.updatedPassword;
             int updated = context.SaveChanges();
             if (updated > 0)
             {
                 return(updated);
             }
             else
             {
                 return(0);
             }
         }
     }
 }
Exemplo n.º 20
0
        public static EmployeeInfoModel GetEmployeeInfo(int id)
        {
            using (var context = new MakeMyJobsEntities())
            {
                if (context.Employees.Any(x => x.UserId == id))
                {
                    EmployeeInfoModel employeeInfoModel = context.Employees.Join(context.States, e => e.State, st => st.StateId, (e, st) => new
                    {
                        StateName = st.StateName,
                        employee  = e
                    }).Join(context.Countries, e => e.employee.Country, c => c.CountryId, (e, c) => new
                    {
                        employee    = e,
                        stateName   = e.StateName,
                        countryName = c.CountryName
                    }).Join(context.Users, e => e.employee.employee.UserId, u => u.UserId, (e, u) => new EmployeeInfoModel()
                    {
                        employeeId    = e.employee.employee.EmployeeId,
                        userId        = e.employee.employee.UserId,
                        firstName     = e.employee.employee.FirstName,
                        lastName      = e.employee.employee.LastName,
                        city          = e.employee.employee.City,
                        contactNumber = e.employee.employee.ContactNumber,
                        dateOfBirth   = e.employee.employee.DateOfBirth,
                        resume        = e.employee.employee.Resume,
                        dateJoined    = e.employee.employee.DateJoined,
                        address       = e.employee.employee.Address + (e.employee.employee.City == null ? "" : (", " + e.employee.employee.City)) + (e.employee.employee.State == 0 ? "" : (", " + e.employee.StateName)) + (e.employee.employee.Country == 0 ? "" : (", " + e.countryName)),
                        state         = e.employee.employee.State,
                        country       = e.employee.employee.Country,
                        email         = u.Email,
                        zipCode       = e.employee.employee.ZipCode
                    }).FirstOrDefault(x => x.userId == id);

                    employeeInfoModel.employeeEducation = new List <EmployeeEducationModel>();
                    employeeInfoModel.employeeEducation = context.EmployeeEducations.Where(x => x.EmployeeId == employeeInfoModel.employeeId && x.IsActive == 1).Select(x => new EmployeeEducationModel()
                    {
                        empEducationId = x.EmpEducationId,
                        employeeId     = x.EmployeeId,
                        instituteName  = x.InstituteName,
                        instituteType  = x.InstituteType,
                        percentage     = x.Percentage,
                        joinedOn       = x.JoinedOn,
                        passedOn       = x.PassedOn,
                        isActive       = x.IsActive
                    }).ToList();

                    employeeInfoModel.employeeExperience = new List <EmployeeExperienceModel>();
                    employeeInfoModel.employeeExperience = context.EmployeeExperiences.Where(x => x.EmployeeId == employeeInfoModel.employeeId && x.IsActive == 1).Select(x => new EmployeeExperienceModel()
                    {
                        empExperienceId = x.EmpExperienceId,
                        employeeId      = x.EmployeeId,
                        companyName     = x.CompanyName,
                        position        = x.Position,
                        joinedOn        = x.JoinedOn,
                        leftOn          = x.LeftOn,
                        isActive        = x.IsActive,
                    }).ToList();

                    if (context.EmployeeDocuments.Any(x => x.EmployeeId == employeeInfoModel.employeeId && x.DocumentType == EmployeeDocumentTypes.Resume))
                    {
                        employeeInfoModel.resume = "1";
                    }

                    return(employeeInfoModel);
                }
                else
                {
                    return(null);
                }
            }
        }