Пример #1
0
        public bool UpdateUser(User user)
        {
            try
            {
                using (FSDEntities db = new FSDEntities())
                {
                    var userData = (from p in db.Users
                                    where p.User_Id == user.User_Id
                                    select p).FirstOrDefault();
                    if (userData != null)
                    {
                        userData.First_Name  = user.First_Name;
                        userData.Last_Name   = user.Last_Name;
                        userData.Employee_id = user.Employee_id;

                        db.SaveChanges();
                        return(true);
                    }

                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public bool AddTask(Task task)
        {
            using (FSDEntities db = new FSDEntities())
            {
                if (task.Start_Date != Convert.ToDateTime("01-01-0001 00:00:00"))
                {
                    Task taskManager = new Task();
                    taskManager.Task_Name  = task.Task_Name;
                    taskManager.Parent_Id  = task.Parent_Id;
                    taskManager.Priority   = task.Priority;
                    taskManager.Start_Date = task.Start_Date;
                    taskManager.End_Date   = task.End_Date;
                    taskManager.Staus      = true;
                    taskManager.Project_Id = task.Project_Id;

                    db.Tasks.Add(taskManager);
                    db.SaveChanges();
                }

                else
                {
                    Parent_Task parent = new Parent_Task();
                    parent.Parent_Task1 = task.Task_Name;
                    db.Parent_Task.Add(parent);
                    db.SaveChanges();
                }
            }
            return(true);
        }
Пример #3
0
        public bool UpdateTask(Task task)
        {
            using (FSDEntities db = new FSDEntities())
            {
                db.Configuration.ProxyCreationEnabled = false;

                var taskManager = (from p in db.Tasks
                                   where p.Task_Id == task.Task_Id
                                   select p).FirstOrDefault();
                if (taskManager != null)
                {
                    taskManager.Task_Name  = task.Task_Name;
                    taskManager.Parent_Id  = task.Parent_Id;
                    taskManager.Priority   = task.Priority;
                    taskManager.Start_Date = task.Start_Date;
                    taskManager.End_Date   = task.End_Date;
                    taskManager.Staus      = true;
                    taskManager.Project_Id = task.Project_Id;
                    db.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #4
0
        public bool UpdateProject(Project project)
        {
            try
            {
                using (FSDEntities db = new FSDEntities())
                {
                    db.Configuration.ProxyCreationEnabled = false;

                    var projectData = (from p in db.Projects
                                       where p.Project_Id == project.Project_Id
                                       select p).FirstOrDefault();
                    if (projectData != null)
                    {
                        projectData.Project_Name = project.Project_Name;
                        projectData.Start_Date   = project.Start_Date;
                        projectData.End_Date     = project.End_Date;
                        projectData.Manager_Id   = project.Manager_Id;
                        projectData.Priority     = project.Priority;

                        db.SaveChanges();
                        return(true);
                    }

                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
        public bool AddUser(User user)
        {
            using (FSDEntities db = new FSDEntities())
            {
                User taskManager = new User();
                taskManager.Employee_id = user.Employee_id;
                taskManager.First_Name  = user.First_Name;
                taskManager.Last_Name   = user.Last_Name;

                db.Users.Add(taskManager);
                db.SaveChanges();
            }
            return(true);
        }
Пример #6
0
 public List <User> GetAllUsers()
 {
     try
     {
         using (FSDEntities db = new FSDEntities())
         {
             var userData = (from p in db.Users
                             select p).ToList();
             return(userData);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #7
0
        public bool AddProject(Project project)
        {
            using (FSDEntities db = new FSDEntities())
            {
                Project projectData = new Project();
                projectData.Project_Name = project.Project_Name;
                projectData.Start_Date   = project.Start_Date;
                projectData.End_Date     = project.End_Date;
                projectData.Manager_Id   = project.Manager_Id;
                projectData.Priority     = project.Priority;

                db.Projects.Add(projectData);
                db.SaveChanges();
            }
            return(true);
        }
Пример #8
0
 public User GetUsersById(int userId)
 {
     try
     {
         using (FSDEntities db = new FSDEntities())
         {
             var userData = (from p in db.Users
                             where p.User_Id == userId
                             select p).FirstOrDefault();
             return(userData);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #9
0
 public Task GetTaskById(int id)
 {
     try
     {
         using (FSDEntities db = new FSDEntities())
         {
             db.Configuration.ProxyCreationEnabled = false;
             var taskData = (from p in db.Tasks
                             where p.Task_Id == id
                             select p).FirstOrDefault();
             return(taskData);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #10
0
        public List <Parent_Task> GetAllParentTask()
        {
            try
            {
                using (FSDEntities db = new FSDEntities())
                {
                    db.Configuration.ProxyCreationEnabled = false;

                    var taskData = (from p in db.Parent_Task
                                    select p).ToList();
                    return(taskData);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #11
0
        public Project GetProjectById(int projectId)
        {
            try
            {
                using (FSDEntities db = new FSDEntities())
                {
                    db.Configuration.ProxyCreationEnabled = false;

                    var projectData = (from p in db.Projects
                                       where p.Project_Id == projectId
                                       select p).FirstOrDefault();
                    return(projectData);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #12
0
        public List <Task> GetAllTask()
        {
            try
            {
                using (FSDEntities db = new FSDEntities())
                {
                    db.Configuration.ProxyCreationEnabled = false;

                    var taskData = (from p in db.Tasks
                                    join parent in db.Parent_Task
                                    on p.Parent_Id equals parent.Parent_Id into ps
                                    from parent in ps.DefaultIfEmpty()
                                    select new {
                        Task_Id = p.Task_Id,
                        Task_Name = p.Task_Name,
                        Start_Date = p.Start_Date,
                        End_Date = p.End_Date,
                        Priority = p.Priority,
                        Parent_Name = p.Parent_Id == null ? "No Parent Task Present" : parent.Parent_Task1,
                        Status = p.Staus,
                        Project_Name = db.Projects.Where(a => a.Project_Id == p.Project_Id).Select(a => a.Project_Name).FirstOrDefault(),
                        Project_Id = p.Project_Id
                    }).ToList().Select(x => new Task()
                    {
                        Task_Id      = x.Task_Id,
                        Task_Name    = x.Task_Name,
                        Start_Date   = x.Start_Date,
                        End_Date     = x.End_Date,
                        Priority     = x.Priority,
                        Parent_Name  = x.Parent_Name,
                        Staus        = x.Status,
                        Project_Id   = x.Project_Id,
                        Project_Name = x.Project_Name
                    });
                    return(taskData.ToList());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #13
0
        public List <Project> GetAllProjects()
        {
            try
            {
                using (FSDEntities db = new FSDEntities())
                {
                    db.Configuration.ProxyCreationEnabled = false;

                    var projectData = (from p in db.Projects

                                       //join task in db.Tasks
                                       //on p.Project_Id equals task.Project_Id into ps
                                       //from task in ps.DefaultIfEmpty()
                                       select new
                    {
                        Project_Id = p.Project_Id,
                        Project_Name = p.Project_Name,
                        Start_Date = p.Start_Date,
                        End_Date = p.End_Date,
                        Manager_Id = p.Manager_Id,
                        Priority = p.Priority,
                        No_Of_Task = db.Tasks.Where(x => x.Project_Id == p.Project_Id).Count(),
                        Completed_Task = db.Tasks.Where(x => x.End_Date <= System.DateTime.Now && x.Project_Id == p.Project_Id).Count()
                    }).ToList().Select(x => new Project()
                    {
                        Project_Id     = x.Project_Id,
                        Project_Name   = x.Project_Name,
                        Start_Date     = x.Start_Date,
                        End_Date       = x.End_Date,
                        Manager_Id     = x.Manager_Id,
                        Priority       = x.Priority,
                        No_Of_Task     = x.No_Of_Task,
                        Completed_Task = x.Completed_Task
                    }).Distinct();
                    return(projectData.ToList());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #14
0
        public bool DeleteUser(int userId)
        {
            try
            {
                using (FSDEntities db = new FSDEntities())
                {
                    var userData = (from p in db.Users
                                    where p.User_Id == userId
                                    select p).FirstOrDefault();
                    db.Users.Remove(userData);
                    db.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #15
0
        public bool EndTask(int id)
        {
            using (FSDEntities db = new FSDEntities())
            {
                db.Configuration.ProxyCreationEnabled = false;

                var taskData = (from p in db.Tasks
                                where p.Task_Id == id
                                select p).FirstOrDefault();
                if (taskData != null)
                {
                    taskData.Staus    = false;
                    taskData.End_Date = System.DateTime.Now;
                    db.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #16
0
        public bool DeleteProject(int projectId)
        {
            try
            {
                using (FSDEntities db = new FSDEntities())
                {
                    db.Configuration.ProxyCreationEnabled = false;

                    var userData = (from p in db.Projects
                                    where p.Project_Id == projectId
                                    select p).FirstOrDefault();
                    db.Projects.Remove(userData);
                    db.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }