Пример #1
0
 public Projects()
 {
     projects = new Project[2];
     
     projects[0] = new Project { Id = 1, GUID = Guid.NewGuid(), Enabled = true, Name = "Tempus", ProjetId = "temp1" };
     projects[1] = new Project { Id = 2, GUID = Guid.NewGuid(), Enabled = true, Name = "Trio Link", ProjetId = "trio1" };
 }
        public Boolean post(dynamic project)
        {

            String ProjectID = project.assignment;
            Boolean isExisting = true; 

            var projectToCheck = context.Projects.Where(a => a.ProjetId == ProjectID).FirstOrDefault();

            if (projectToCheck == null)
            {
                var projectToAdd = new Project();
                projectToAdd.GUID = Guid.NewGuid();

                projectToAdd.Enabled = true;
                projectToAdd.Name = project.name;
                projectToAdd.ProjetId = project.assignment;

                if (project.membersfrommanual != null)
                {
                    List<string> membersArr = new List<string>();
                    foreach (var mem in project.membersfrommanual)
                    {
                        membersArr.Add(mem.Value.ToString());
                    }
                    projectToAdd.TeamMembers = string.Join(",", membersArr.ToArray());
                    projectToAdd.ProjectMemberRep = project.rep;
                }
               
                context.Projects.Add(projectToAdd);
                context.SaveChanges();
                isExisting = false; 
            }

            return isExisting;
        }
        public Project put(Project project)
        {

            //      var projectToAdd = project;

            if (project.Enabled == false)
                project.Enabled = true;
            else
                project.Enabled = false;

            var projectToAdd = context.Projects.Where(p => p.ProjetId == project.ProjetId).FirstOrDefault();
            //context.Projects.Attach(projectToAdd);
            //   context.Entry(projectToAdd).State = System.Data.Entity.EntityState.Modified;
            // context.SaveChanges();

            context.Entry(projectToAdd).CurrentValues.SetValues(project);
            context.SaveChanges();
            return projectToAdd;

        }
Пример #4
0
        public Claims(Project[] projects, List<Practice> practices, SpecDbContext context)
        {
            //KEY for project status map
            // 0 -> not claimed
            // 1 -> accepted
            // 2 -> rejected
            // 3 -> pending
            int id_count = 0;

            int[] map1 = new int[28] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 3, 0, 1, 1, 1, 1, 0, 1, 1, 2, 3, 3, 1 }; // 1 -> aproved, 2-> reject, 3 -> pending



            int[] map_tempus = new int[61];
            int[] map_TrioLink = new int[61];
            for (int i = 0; i < 28; i++)
            {
                map_tempus[i] = map1[i];
                map_TrioLink[i] = 1;

            }
            for (int i = 28; i < 61; i++)
            {
                map_tempus[i] = 1;
                map_TrioLink[i] = 1;
                if (i == 32)
                {
                    map_tempus[i] = 2;
                }
                if (i >= 43 && i < 47)
                {
                    map_tempus[i] = 0;
                }
            }




            claims = new Claim[map_tempus.Length + map_TrioLink.Length - 7 + 3]; //reduce 3 for number of 0 s add 3 for extra 3 at the end

            //tempus project claim seeds        
            for (int i = 0; i < map_tempus.Length; i++)
            {
                if (map_tempus[i] != 0)
                {
                    claims[id_count] = new Claim

                    {
                        Id = id_count + 1,
                        GUID = Guid.NewGuid(),
                        Status = getStatus(map_tempus[i]),
                        AuditorComment = "Seed Auto generated ",
                        CreatedTime = new DateTime(2014, 2, 1),
                        Practice = context.Practices.FirstOrDefault(t => t.Id == i + 1),
                        Project = context.Projects.FirstOrDefault(t => t.Id == 1),
                        TeamComment = "Seed Auto generated"
                    };
                    id_count++;
                }
            }

            claims[id_count++] = new Claim
            {
                //Id = id_count + 1,
                GUID = Guid.NewGuid(),
                Status = Status.REJECTED,
                AuditorComment = "rejected due to abc ",
                CreatedTime = new DateTime(2014, 1, 1),
                Practice = context.Practices.FirstOrDefault(t => t.Id == 1),
                Project = context.Projects.FirstOrDefault(t => t.Id == 1),
                TeamComment = "Seed Auto generated"
            };
            claims[id_count++] = new Claim
            {
                // Id = id_count + 1,
                GUID = Guid.NewGuid(),
                Status = Status.REJECTED,
                AuditorComment = "rejected due to abc ",
                CreatedTime = new DateTime(2013, 11, 1),
                Practice = context.Practices.FirstOrDefault(t => t.Id == 5),
                Project = context.Projects.FirstOrDefault(t => t.Id == 1),
                TeamComment = "Seed Auto generated"
            };
            claims[id_count++] = new Claim
            {
                // Id = id_count + 1,
                GUID = Guid.NewGuid(),
                Status = Status.REJECTED,
                AuditorComment = "rejected due to abc ",
                CreatedTime = new DateTime(2013, 11, 13),
                Practice = context.Practices.FirstOrDefault(t => t.Id == 9),
                Project = context.Projects.FirstOrDefault(t => t.Id == 1),
                TeamComment = "Seed Auto generated"
            };

            //TrioLink project claim seeds
            for (int i = 0; i < map_TrioLink.Length; i++)
                if (map_TrioLink[i] != 0)
                {
                    claims[id_count] = new Claim
                    {
                        Id = id_count + 1,
                        GUID = Guid.NewGuid(),
                        Status = getStatus(map_TrioLink[i]),
                        AuditorComment = "Seed Auto generated ",
                        CreatedTime = new DateTime(2014, 3, 1),
                        Practice = context.Practices.FirstOrDefault(t => t.Id == i + 1),
                        Project = context.Projects.FirstOrDefault(t => t.Id == 2),
                        TeamComment = "Seed Auto generated"
                    };
                    id_count++;
                }



        }