Example #1
0
        /// <summary>
        /// get details of employees on particular project
        /// </summary>
        /// <param name="pid"></param>
        /// <returns></returns>
        public IEnumerable <Registration> getTeamDetails(int pid)
        {
            using (CompanyDbContext companyDbContext = new CompanyDbContext())
            {
                List <Registration> reg = new List <Registration>();

                IQueryable <string> emps = companyDbContext.Project_TechnologyStacks.Where(c => (c.projectId == pid) && (c.IsActive == true)).Select(c => c.UserId);

                foreach (var e in emps)
                {
                    reg.AddRange(companyDbContext.UserRegistration.Where(c => (c.UserId == e) && (c.IsActive == true)));
                }
                return(reg);
            }
        }
Example #2
0
        /// <summary>
        /// register the users and add the details into the database
        /// </summary>
        /// <param name="registration"></param>
        /// <returns></returns>
        public bool  AddUsers(Registration registration)
        {
            using (CompanyDbContext companyDbContext = new CompanyDbContext())
            {
                registration.DId       = 5;
                registration.RId       = 4;
                registration.CreatedBy = registration.Username;
                registration.CreatedOn = DateTime.Now;
                registration.UpdatedOn = DateTime.Now;
                registration.UpdatedBy = registration.Username;

                registration.R_M_Id   = "CMP-1001";
                registration.IsActive = true;
                registration.Password = Password.EncodePassword(registration.Password, registration.Username);
                companyDbContext.UserRegistration.Add(registration);
                companyDbContext.SaveChanges();
                return(true);
            }
        }
Example #3
0
        public void SetAllEmployeesAttendence()
        {
            using (CompanyDbContext companyDbContext = new CompanyDbContext())
            {
                DateTime          todayDate      = DateTime.Now.Date;
                List <Attendence> EmployeesLogIn = companyDbContext.Emp_Attendence.Where(e => (e.Date == todayDate)).ToList();
                foreach (var obj in EmployeesLogIn)
                {
                    if (obj.LogOutTime == null)
                    {
                        obj.LogOutTime       = obj.LogInTime;
                        obj.TotalTime        = "0";
                        obj.AttendenceStatus = "Absent";
                    }
                    else
                    {
                        TimeSpan TotalTime = TimeSpan.Parse(obj.TotalTime);
                        int      hrs       = TotalTime.Hours;
                        if (hrs >= 3)
                        {
                            obj.AttendenceStatus = "Present";
                        }
                        else
                        {
                            obj.AttendenceStatus = "Present";
                        }
                    }
                }

                List <string> AlreadyLoginEmps = companyDbContext.Emp_Attendence.Where(e => e.Date == todayDate).Select(e => e.Emp_Id).ToList();
                List <string> EmpIds           = companyDbContext.UserRegistration.Select(e => e.UserId).Except(AlreadyLoginEmps).ToList();
                foreach (var obj in EmpIds)
                {
                    Attendence att = new Attendence()
                    {
                        Date = todayDate, AttendenceStatus = "Absent", Emp_Id = obj
                    };
                    companyDbContext.Emp_Attendence.Add(att);
                }
                companyDbContext.SaveChanges();
            }
        }
Example #4
0
        public bool DeleteProject(int pid, string userid)
        {
            using (CompanyDbContext companyDbContext = new CompanyDbContext())
            {
                Project p = companyDbContext.Projects.Where(t => t.PID == pid).FirstOrDefault();

                p.IsActive  = false;
                p.UpdatedOn = DateTime.Now;
                p.UpdatedBy = userid;
                List <Project_TechnologyStack> project_TechnologyStacks = companyDbContext.Project_TechnologyStacks.Where(t => t.projectId == pid).ToList();

                foreach (var list in project_TechnologyStacks)
                {
                    list.IsActive = false;
                }

                companyDbContext.SaveChanges();
            }

            return(true);
        }
Example #5
0
        public int AddProject(Project project)
        {
            if (project.PID == 0)
            {
                int id;
                foreach (var key in project.project_TechnologyStacks)
                {
                    key.IsActive = true;
                }
                //   List<Project_Team> projectTeams = new List<Project_Team>();
                using (CompanyDbContext companyDbContext = new CompanyDbContext())
                {
                    Project proj = companyDbContext.Projects.Where(n => (n.ProjectName == project.ProjectName) && (n.IsActive == true)).FirstOrDefault();
                    if (project != null)
                    {
                        project.UpdatedOn = DateTime.Now;
                        project.UpdatedBy = project.UpdatedBy;
                        project.IsActive  = true;
                        if (proj == null)
                        {
                            project.CreatedOn = DateTime.Now;
                            project.CreatedBy = project.UpdatedBy;
                        }

                        companyDbContext.Projects.Add(project);
                        companyDbContext.SaveChanges();

                        id = project.PID;

                        return(project.PID);
                    }
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
Example #6
0
        /// <summary>
        /// get the unique user id
        /// </summary>
        /// <returns></returns>
        public string GetUserId()
        {
            using (CompanyDbContext companyDbContext = new CompanyDbContext())
            {
                var users = companyDbContext.UserRegistration.Count();;
                if (users == 0)
                {
                    return("CMP-1001");
                }
                else
                {
                    Registration registration = companyDbContext.UserRegistration.OrderByDescending(x => x.Sno).First();

                    Console.WriteLine(registration);

                    string userid = registration.UserId;
                    userid = userid.Replace('"', ' ').Trim();
                    string[] id = userid.Split('-');
                    id[1]  = (Int32.Parse(id[1]) + 1).ToString();
                    userid = id[0] + "-" + id[1];
                    return(userid);
                }
            }
        }
Example #7
0
        // Get project details to set in jq grid
        public IEnumerable <Project> GetProjectDetails(string username, string status)
        {
            IQueryable <int> query = null;

            using (CompanyDbContext companyDbContext = new CompanyDbContext())
            {
                List <Project> projs = new List <Project>();
                if (username == null)
                {
                    return(companyDbContext.Projects.Where(t => t.IsActive == true).ToList());
                }
                else
                {
                    var role = companyDbContext.UserRegistration.Where(u => (u.Username == username || u.Email == username)).Select(r => r.role.RoleName).FirstOrDefault();
                    if (role == "Admin")
                    {
                        query = companyDbContext.Projects.Where(t => t.IsActive == true).Select(p => p.PID);
                    }
                    else if (role == "P_Manager")
                    {
                        query = companyDbContext.Projects.Where(t => t.IsActive == true).Where(t => t.Mgr_Id == (companyDbContext.UserRegistration.Where(r => (r.Username == username || r.Email == username)).Select(r => r.UserId).FirstOrDefault())).Select(p => p.PID);
                    }
                    else if (role == "Member")
                    {
                        query = companyDbContext.Project_TechnologyStacks.Where(t => t.IsActive == true).Where(t => t.UserId == (companyDbContext.UserRegistration.Where(r => (r.Username == username || r.Email == username)).Select(r => r.UserId).FirstOrDefault())).Select(p => p.projectId);
                    }
                    foreach (var pid in query)
                    {
                        //&& c.Status=="status"
                        projs.AddRange(companyDbContext.Projects.Where(c => (c.PID == pid && c.Status == status && c.IsActive == true)));
                    }

                    return(projs);
                }
            }
        }
Example #8
0
        /// <summary>
        /// to check user exist or not on login
        /// </summary>
        /// <param name="login"></param>
        /// <returns></returns>
        public SessionModel CheckUser(Login login)
        {
            using (CompanyDbContext companyDbContext = new CompanyDbContext())
            {
                //   login.Password = Password.EncodePassword(login.Password,login.Username);

                Registration user = companyDbContext.UserRegistration.Where(x => (x.Username == login.Username || x.Email == login.Username) && (x.IsActive == true)).FirstOrDefault();
                if (user != null)
                {
                    login.Password = Password.EncodePassword(login.Password, user.Username);
                    if (user.Password == login.Password)
                    {
                        //                    string p = user.role.RoleName;
                        SessionModel m = companyDbContext.UserRegistration.Where(x => (x.Username == login.Username || x.Email == login.Username)).Select(c => new SessionModel {
                            firstname = c.Firstname, rolename = c.role.RoleName, deptname = c.department.Dname, userid = c.UserId
                        }).FirstOrDefault();
                        return(m);;
                    }

                    return(null);
                }
                return(null);
            }
        }