Пример #1
0
        /// <summary>
        ///     Actualiza o domain object com os valores do DTO project recebendo 
        ///     por parametro os objectos obrigatorios (responsavel e o cliente)
        /// </summary>
        /// <param name="domainProject"></param>
        /// <param name="dto"></param>
        /// <param name="domainResponsable"></param>
        /// <param name="domainClient"></param>
        public static void UpdateDomainObject(this Project domainProject, 
                                              ProjectServiceDTO dto, 
                                              Member domainResponsable, Client domainClient)
        {
            domainProject.Name = dto.Name;
            domainProject.Enabled = dto.Enabled;
            domainProject.Description = dto.Description;

            domainProject.Responsable = domainResponsable;
            domainProject.Client = domainClient;
        }
Пример #2
0
 /// <summary>
 ///     Cria um domain project a partir de um DTO project recebendo 
 ///     por parametro os objectos obrigatorios (responsavel e o cliente)
 /// </summary>
 /// <param name="dto"></param>
 /// <param name="domainResponsable"></param>
 /// <param name="domainMember"></param>
 /// <returns></returns>
 public static Project CopyToDomainObject(this ProjectServiceDTO dto, 
                                          Member domainResponsable, Client domainMember)
 {
     return new Project
                {
                    Description = dto.Description,
                    CreatedDate = DateTime.Now,
                    Enabled = dto.Enabled,
                    Name = dto.Name,
                    Responsable = domainResponsable,
                    Client = domainMember
                };
 }
Пример #3
0
        //
        // Porque o Membro pode ser null, passamos o membro que está a alterar o issue por parametro.
        public static NotificatorMemberDTO BuildNotificatorForIssue(Issue dbIssue, Member currentMember)
        {
            return new NotificatorMemberDTO {
                ClientId = dbIssue.Client.UserID,
                IssueId = dbIssue.IssueID,
                ProjectId = dbIssue.Project.ProjectID,

                IssueShortDescription = dbIssue.ShortDescription,
                IssueState = (StateEnum)dbIssue.State,
                MemberName = currentMember.Name,
                ProjectName = dbIssue.Project.Name
            };
        }
Пример #4
0
        public void ProjectAddWorker()
        {
            var project = new Project {
                Description = "VirtualNote"
            };

            var goncalo = new Member { UserID = 1, Name = "Gonçalo" };
            var scott   = new Member { UserID = 2, Name = "Scott" };

            project.Workers.Add(goncalo);
            project.Workers.Add(scott);

            Assert.IsTrue(goncalo.AssignedProjects.Contains(project));
            Assert.IsTrue(scott.AssignedProjects.Contains(project));
        }
Пример #5
0
        public void TestAddMember()
        {
            //
            // Cria um novo membro e testa se o id do membro é o ultimo + 1 depois de inserid
            //

            var member = new Member { Name = "Gestrudes" };

            Assert.AreEqual(0, member.UserID);

            // obter o ultimo id de user na bd
            int lastUserIdOnDb = _db.Query<User>().Max(u => u.UserID);

            _db.Insert(member);

            // Verificar se o id do user foi alterado
            Assert.AreEqual(lastUserIdOnDb + 1, member.UserID);
        }
Пример #6
0
        public void UserAddComment()
        {
            //
            // Adicionar a lista de comentarios de um user, e verificar se esse user
            // fica referenciado no comentario
            //
            User u = new Member {
                Name = "Gonçalo"
            };

            var c = new Comment {
                Description = "Goncalo Comment"
            };

            Assert.IsNull(c.User);

            u.Comments.Add(c);

            Assert.IsTrue(c.User == u); // 2-way established
        }
Пример #7
0
        public void UserRemoveComment()
        {
            //
            // Inserimos um comentario na lista de comentarios de gonçalo
            // e removemos, para verificar se o User fica a null.
            //
            User u = new Member {
                Name = "Gonçalo"
            };

            var c = new Comment {
                Description = "Goncalo Comment"
            };

            u.Comments.Add(c);

            Assert.IsTrue(c.User == u); // 2-way established

            u.Comments.Remove(c);

            Assert.IsNull(c.User);
            Assert.IsTrue(u.Comments.Count == 0);
        }
Пример #8
0
        internal static void AddDefaultData(this IRepository repository, bool loadTestData)
        {
            #region Members

            Member admin = new Member
            {
                Name = "admin",
                CreatedDate = DateTime.Now,
                Enabled = true,
                Password = PasswordUtils.Encript("admin"),
                IsAdmin = true,
                Email = "*****@*****.**"
            };

            repository.Insert(admin);           // id = 1

            if (!loadTestData)
                return;

            //
            // Members
            Member gdias = new Member {
                Name = "gdias",
                CreatedDate = DateTime.Now,
                Enabled = true,
                Password = PasswordUtils.Encript("admin"),
                IsAdmin = true,
                Email = "*****@*****.**"
            };
            Member sHanselman = new Member {
                Name = "shanselman",
                CreatedDate = DateTime.Now,
                Enabled = true,
                Password = PasswordUtils.Encript("foo"),
                Email = "*****@*****.**"
            };
            Member pSilva = new Member {
                Name = "psilva",
                CreatedDate = DateTime.Now,
                Enabled = true,
                Password = PasswordUtils.Encript("foo2"),
                Email = "*****@*****.**"
            };

            Member gustavoG = new Member {
                Name = "gustavog",
                CreatedDate = DateTime.Now,
                Enabled = true,
                Password = PasswordUtils.Encript("foo3"),
                Email = "*****@*****.**"
            };

            repository.Insert(gdias);           // id = 1
            repository.Insert(sHanselman);      // id = 2
            repository.Insert(pSilva);          // id = 3
            repository.Insert(gustavoG);        // id = 4

            #endregion

            #region Clients

            //
            // Clients
            Client clientZON = new Client {
                Name = "zonlusomundo",
                CreatedDate = DateTime.Now,
                Enabled = true,
                Password = PasswordUtils.Encript("zonpassword")
            };

            Client clientWORTEN = new Client {
                Name = "worten",
                CreatedDate = DateTime.Now,
                Enabled = true,
                Password = PasswordUtils.Encript("wortenpassword")
            };

            Client clientVobis = new Client {
                Name = "vobis",
                CreatedDate = DateTime.Now,
                Enabled = true,
                Password = PasswordUtils.Encript("vobispassword")
            };

            Client clientOni = new Client {
                Name = "oni",
                CreatedDate = DateTime.Now,
                Enabled = true,
                Password = PasswordUtils.Encript("onipassword"),
                Email = "*****@*****.**"
            };

            repository.Insert(clientZON);       // id = 5
            repository.Insert(clientWORTEN);    // id = 6
            repository.Insert(clientVobis);     // id = 7
            repository.Insert(clientOni);       // id = 8

            #endregion

            #region Projects

            //
            // Projects
            Project zonPROJECT = new Project {
                Name = "ZonLusomundo Website",
                Enabled = true,
                CreatedDate = DateTime.Now,
                Description = "Um site feito em 2011",

                Responsable = gdias,
                Client = clientZON,
            };

            Project VobisPROJECT = new Project {
                Name = "Vobis Project",
                Enabled = true,
                CreatedDate = DateTime.Now,
                Description = "Descricao a moda da vobis",

                Responsable = gustavoG,
                Client = clientVobis
            };

            Project OniPROJECT = new Project {
                Name = "Oninet",
                Enabled = true,
                CreatedDate = DateTime.Now,
                Description = "Descricao a moda da Oninet",

                Responsable = gustavoG,
                Client = clientOni
            };

            repository.Insert(zonPROJECT);        // id = 1
            repository.Insert(VobisPROJECT);      // id = 2
            repository.Insert(OniPROJECT);        // id = 3

            //
            // Workers
            zonPROJECT.Workers.Add(pSilva);       // pSilva is working on zonProject

            OniPROJECT.Workers.Add(pSilva);       // pSilva is working on oniProject

            #endregion

            #region Issues

            //
            //  Issue
            Issue zonISSUE = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Man i found an error :/",
                LongDescription = "This is my detailed description of the error",
                Priority = 1,
                Type = 0,
                State = 0,

                Client = clientZON,
                Project = zonPROJECT
            };

            Issue oniISSUE1 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 1 - short description",
                LongDescription = "Issue 1 - long description",
                Priority = 1,
                Type = 0,
                State = 1,

                Client = clientOni,
                Project = OniPROJECT,
                Member = gustavoG
            };

            Issue oniISSUE2 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 2 - short description",
                LongDescription = "Issue 2 - long description",
                Priority = 4,
                Type = 1,
                State = 2,

                Client = clientOni,
                Project = OniPROJECT,
                Member = gustavoG
            };

            Issue oniISSUE3 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 3 - short description",
                LongDescription = "Issue 3 - long description",
                Priority = 3,
                Type = 1,
                State = 0,

                Client = clientOni,
                Project = OniPROJECT
            };

            Issue oniISSUE4 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 4 - short description",
                LongDescription = "Issue 4 - long description",
                Priority = 2,
                Type = 1,
                State = 0,

                Client = clientOni,
                Project = OniPROJECT
            };

            Issue oniISSUE5 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 5 - short description",
                LongDescription = "Issue 5 - long description",
                Priority = 1,
                Type = 1,
                State = 0,

                Client = clientOni,
                Project = OniPROJECT
            };

            Issue oniISSUE6 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 6 - short description",
                LongDescription = "Issue 6 - long description",
                Priority = 3,
                Type = 1,
                State = 0,

                Client = clientOni,
                Project = OniPROJECT
            };

            Issue oniISSUE7 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 7 - short description",
                LongDescription = "Issue 7 - long description",
                Priority = 2,
                Type = 1,
                State = 2,

                Client = clientOni,
                Project = OniPROJECT,
                Member = gustavoG
            };

            Issue oniISSUE8 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 8 - short description",
                LongDescription = "Issue 8 - long description",
                Priority = 3,
                Type = 1,
                State = 0,

                Client = clientOni,
                Project = OniPROJECT
            };

            Issue oniISSUE9 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 9 - short description",
                LongDescription = "Issue 9 - long description",
                Priority = 3,
                Type = 1,
                State = 0,

                Client = clientOni,
                Project = OniPROJECT
            };

            Issue oniISSUE10 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 10 - short description",
                LongDescription = "Issue 10 - long description",
                Priority = 1,
                Type = 1,
                State = 2,

                Client = clientOni,
                Project = OniPROJECT,
                Member = gustavoG
            };

            Issue oniISSUE11 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 11 - short description",
                LongDescription = "Issue 11 - long description",
                Priority = 3,
                Type = 1,
                State = 0,

                Client = clientOni,
                Project = OniPROJECT
            };

            Issue oniISSUE12 = new Issue {
                CreatedDate = DateTime.Now,
                LastUpdateDate = null,
                ShortDescription = "Issue 12 - short description",
                LongDescription = "Issue 12 - long description",
                Priority = 4,
                Type = 1,
                State = 0,

                Client = clientOni,
                Project = OniPROJECT
            };

            repository.Insert(zonISSUE);            // id = 1
            repository.Insert(oniISSUE1);           // id = 2

            repository.Insert(oniISSUE2);           // id = 3
            repository.Insert(oniISSUE3);           // id = 4
            repository.Insert(oniISSUE4);           // id = 5
            repository.Insert(oniISSUE5);           // id = 6
            repository.Insert(oniISSUE6);           // id = 7
            repository.Insert(oniISSUE7);           // id = 8
            repository.Insert(oniISSUE8);           // id = 9
            repository.Insert(oniISSUE9);           // id = 10
            repository.Insert(oniISSUE10);          // id = 11
            repository.Insert(oniISSUE11);          // id = 12
            repository.Insert(oniISSUE12);          // id = 13

            #endregion

            #region Comments

            //
            // Comments
            Comment zonISSUEComment1 = new Comment {
                CreatedDate = DateTime.Now,
                Description = "This is a comment for test purposes..",
                User = pSilva,
                Issue = zonISSUE
            };

            Comment zonISSUEComment2 = new Comment {
                CreatedDate = DateTime.Now,
                Description = "This is a comment for test purposes..",
                User = clientZON,
                Issue = zonISSUE
            };

            repository.Insert(zonISSUEComment1);
            repository.Insert(zonISSUEComment2);

            // 12 Comments for Oni

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment1",
                User = clientOni,
                Issue = oniISSUE1
            });

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment2",
                User = gustavoG,
                Issue = oniISSUE1
            });

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment3",
                User = gustavoG,
                Issue = oniISSUE1
            });

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment4",
                User = gustavoG,
                Issue = oniISSUE1
            });

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment5",
                User = gustavoG,
                Issue = oniISSUE1
            });

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment6",
                User = gustavoG,
                Issue = oniISSUE1
            });

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment7",
                User = gustavoG,
                Issue = oniISSUE1
            });

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment8",
                User = gustavoG,
                Issue = oniISSUE1
            });

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment9",
                User = gustavoG,
                Issue = oniISSUE1
            });

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment10",
                User = gustavoG,
                Issue = oniISSUE1
            });

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment11",
                User = gustavoG,
                Issue = oniISSUE1
            });

            repository.Insert(new Comment {
                CreatedDate = DateTime.Now,
                Description = "Comment12",
                User = gustavoG,
                Issue = oniISSUE1
            });

            #endregion
        }
Пример #9
0
        HomeMemberQueryDetailsWelcomeData GetWelcomeData(Member member, IEnumerable<int> myProjectsIds)
        {
            HomeMemberQueryDetailsWelcomeData result = new HomeMemberQueryDetailsWelcomeData();

            //
            // Obter welcome data
            var annon1 = _db.Query<Member>()
                            .Where(m => m.UserID == member.UserID)
                            .Select(m => new {
                                Responsabilities = m.Responsabilities.Count(),
                                WorkingOn = m.AssignedProjects.Count()
                            }).Single();

            //
            // SupportedRequests são os pedidos que dei suporte
            int supportedRequests = _db.Query<Issue>()
                                       .Count(i => i.Member != null && i.Member.UserID == member.UserID);

            //
            // PendingRequests são os pedidos em espera onde estou a trabalhar
            int pendingRequests;
            if(member.IsAdmin){
                pendingRequests = _db.Query<Issue>().Count(i => i.State == (int)StateEnum.Waiting);
            }else{
                pendingRequests = _db.Query<Issue>().Count(i => myProjectsIds.Contains(i.Project.ProjectID) && i.State == (int)StateEnum.Waiting);
            }

            result.ProjectsResponsable = annon1.Responsabilities;
            result.ProjectsWorking = annon1.WorkingOn;
            result.PendingRequests = pendingRequests;
            result.SupportedRequests = supportedRequests;

            return result;
        }
Пример #10
0
 static IssuesMemberQueryDetails GetMemberQueryDetailsFromIssue(Issue dbIssue, Member theMember, IEnumerable<KeyIdValueString> clientProjects, int numComments)
 {
     return new IssuesMemberQueryDetails {
         ClientName = dbIssue.Client.Name,
         InitialData = new IssueQueryInitialData {
             ClientProjects = clientProjects,
             Priorities = EnumUtils.GetPriorityValues(),
             States = EnumUtils.GetStateValues(),
             Types = EnumUtils.GetTypeValues()
         },
         ShowDeleteButton = theMember.IsAdmin,
         CreatedAt = dbIssue.CreatedDate,
         IssueId = dbIssue.IssueID,
         ProjectId = dbIssue.Project.ProjectID,
         LastUpdateAt = dbIssue.LastUpdateDate,
         LongDescription = dbIssue.LongDescription,
         ShortDescription = dbIssue.ShortDescription,
         MemberSolving = dbIssue.Member == null ? null : dbIssue.Member.Name,
         NumComments = numComments,
         Priority = (PriorityEnum)dbIssue.Priority,
         Type = (TypeEnum)dbIssue.Type,
         State = (StateEnum)dbIssue.State
     };
 }