Exemplo n.º 1
0
        public void CreateTasks(string title,
                                string details,
                                DateTime?expirationDate,
                                bool?isCompleted,
                                int?effort,
                                int?remaininWork,
                                int?statedId,
                                int?activityId,
                                int?priorityId,
                                int?projectId)
        {
            DAL.Models.PCoreContext _context = new DAL.Models.PCoreContext();
            _context.Tasks.Add(new DAL.Models.Tasks
            {
                Title          = title,
                ActivityId     = activityId,
                Details        = details,
                Effort         = effort,
                ExpirationDate = expirationDate,
                IsCompleted    = isCompleted,
                PriorityId     = priorityId,
                ProjectId      = projectId,
                RemainingWork  = remaininWork,
                StateId        = statedId
            });

            _context.SaveChanges();
        }
Exemplo n.º 2
0
        public void DeleteProjects(int id)
        {
            DAL.Models.PCoreContext _context = new DAL.Models.PCoreContext();
            if (_context.Artifacts.Any(x => x.ProjectId == id) || _context.UserProjects.Any(x => x.ProjectId == id))
            {
                return;
            }
            var projectEF = _context.Projects.Where(x => x.Id == id).FirstOrDefault();

            _context.Projects.Remove(projectEF);
            _context.SaveChanges();
        }
Exemplo n.º 3
0
        public void UpdateProjects(int id, string title, string detail, DateTime?expectedCompletionDate)
        {
            DAL.Models.PCoreContext _context = new DAL.Models.PCoreContext();

            var projectEF = _context.Projects.Where(x => x.Id == id).FirstOrDefault();

            projectEF.Title   = title;
            projectEF.Details = detail;
            projectEF.ExpectedCompletionDate = expectedCompletionDate;
            projectEF.UpdatedAt = DateTime.Now;

            _context.SaveChanges();
        }
Exemplo n.º 4
0
        public List <Models.DB.Activities> GetActivities()
        {
            DAL.Models.PCoreContext _context = new DAL.Models.PCoreContext();

            var listActivities = (from _activities in _context.Activities
                                  where _activities.Active == true
                                  select new Models.DB.Activities
            {
                Id = _activities.Id,
                Name = _activities.Name,
                Active = _activities.Active
            }).ToList();

            return(listActivities);
        }
Exemplo n.º 5
0
        public void CreateProjects(string title, string details, DateTime?expectedCompletionDate, int?tenantId)
        {
            DAL.Models.PCoreContext _context = new DAL.Models.PCoreContext();

            _context.Projects.Add(new DAL.Models.Projects
            {
                Title   = title,
                Details = details,
                ExpectedCompletionDate = expectedCompletionDate,
                TenantId  = tenantId,
                CreatedAt = DateTime.Now
            });

            _context.SaveChanges();
        }
Exemplo n.º 6
0
        public List <Models.DB.Tenants> GetTenants(string userId)
        {
            DAL.Models.PCoreContext _context = new DAL.Models.PCoreContext();

            var listTenants = (from _tenants in _context.Tenants
                               join _aspNetUsers in _context.AspNetUsers on _tenants.Id equals _aspNetUsers.TenantId
                               where _aspNetUsers.Id.Equals(userId)
                               select new Models.DB.Tenants {
                Id = _tenants.Id,
                Name = _tenants.Name,
                Plan = _tenants.Plan,
                CreatedAt = _tenants.CreatedAt,
                UpdatedAt = _tenants.UpdatedAt
            }).ToList();

            return(listTenants);
        }
Exemplo n.º 7
0
        public List <Models.DB.Tasks> GetTasks(int?projectId, int?id)
        {
            DAL.Models.PCoreContext _context = new DAL.Models.PCoreContext();
            var listTasks = (from _tasks in _context.Tasks
                             join _states in _context.States on _tasks.StateId equals _states.Id
                             join _activities in _context.Activities on _tasks.ActivityId equals _activities.Id
                             join _priorities in _context.Priorities on _tasks.PriorityId equals _priorities.Id
                             select new Models.DB.Tasks
            {
                Id = _tasks.Id,
                Details = _tasks.Details,
                Effort = _tasks.Effort,
                Title = _tasks.Title,
                ExpirationDate = _tasks.ExpirationDate,
                RemainingWork = _tasks.RemainingWork,
                IsCompleted = _tasks.IsCompleted,
                StateId = _tasks.StateId,
                State = new Models.DB.States
                {
                    Name = _states.Name
                },
                PriorityId = _tasks.PriorityId,
                Priority = new Models.DB.Priorities
                {
                    Name = _priorities.Name
                },
                ActivityId = _tasks.ActivityId,
                Activity = new Models.DB.Activities
                {
                    Name = _activities.Name
                },
                ProjectId = _tasks.ProjectId
            }).ToList();

            if (projectId != null)
            {
                listTasks = listTasks.Where(x => x.ProjectId == projectId).ToList();
            }
            if (id != null)
            {
                listTasks = listTasks.Where(x => x.Id == id).ToList();
            }

            return(listTasks);
        }
Exemplo n.º 8
0
        public List <Models.DB.Projects> GetProjects(int?id, int?tenantId, string userId = null)
        {
            DAL.Models.PCoreContext _context = new DAL.Models.PCoreContext();

            var listProjectsEF = (from _projects in _context.Projects
                                  select _projects).ToList();

            if (id != null)
            {
                listProjectsEF = listProjectsEF.Where(x => x.Id == id).ToList();
            }
            if (tenantId != null)
            {
                listProjectsEF = listProjectsEF.Where(x => x.TenantId == tenantId).ToList();
            }
            if (!string.IsNullOrEmpty(userId))
            {
                listProjectsEF = (from _projects in listProjectsEF
                                  join _userProjects in _context.UserProjects on _projects.Id equals _userProjects.ProjectId
                                  where _userProjects.UserId.Equals(userId)
                                  select _projects).ToList();
            }

            var listProjects = (from _projects in listProjectsEF
                                select new Models.DB.Projects
            {
                Id = _projects.Id,
                Title = _projects.Title,
                Details = _projects.Details,
                ExpectedCompletionDate = _projects.ExpectedCompletionDate,
                TenantId = _projects.TenantId,
                CreatedAt = _projects.CreatedAt,
                UpdatedAt = _projects.UpdatedAt
            }).ToList();


            return(listProjects);
        }