コード例 #1
0
        public void CreateNewProject(int userId, ProjectData data)
        {
            using (var context = new ProjectManagerDBEntities())
            {
                var project = new Project()
                {
                    Name = data.Name,
                    Description = data.Description,
                    Deadline = data.Deadline,
                    Done = data.Done,
                    CreatedDate = DateTime.Now
                };

                context.Project.Add(project);

                context.Role.Add(new Role()
                {
                    ProjectUserId = userId,
                    Type = new ProjectUserManager().GetLeaderId(),
                    Project = project
                });

                context.SaveChanges();
            }
        }
コード例 #2
0
        public IEnumerable<ProjectData> Projects()
        {
            int userId = int.Parse(User.Identity.GetProjectUserId());

            List<ProjectData> res = new List<ProjectData>();
            var projectUserManager = new ProjectUserManager();
            foreach (Project p in projectUserManager.GetProjectsForUser(userId))
            {
                ProjectData data = new ProjectData();
                data.Id = p.Id;
                data.Name = p.Name;
                data.Description = p.Description;
                data.Deadline = p.Deadline;
                data.Done = p.Done;
                res.Add(data);
            }

            return res;
        }