public StoriesCreateModel(GetRequirementDetails_Result item)
 {
     this.Id = item.RevisionID;
     this.Tag = item.Tag;
     this.Summary = item.Title;
     this.Text = item.Text;
 }
        public StoriesDetailsModel(GetRequirementDetails_Result item)
        {
            this.Id = item.Tag;
            this.RevisionId = item.RevisionID;
            this.UserName = new UserNameModel(item.UserID);
            this.RevisionNumber = item.RevisionNumber;
            this.RevisionDate = item.RevisionDate;
            this.Summary = item.Title;
            this.Text = item.Text;
            this.Published = item.Published;

            using (var ctx = new Entities())
            {
                int logged = Authentication.GetLoggedUser().UserID;
                this.Rated = (ctx.RequirementRatings.FirstOrDefault(i => i.RevisionID == item.RevisionID) != null);
                this.Approved = (ctx.RequirementRatings.FirstOrDefault(i => i.RevisionID == item.RevisionID && i.Approved == true) != null);

                if (this.Rated)
                {
                    this.ComentarioRevisao = (ctx.UserRatings.FirstOrDefault(i => i.RevisionID == item.RevisionID).Comments);
                }
            }

            if(item.BaselineDate.HasValue)
            {
                this.Published = this.Rated = this.Implemented = true;
                this.Status = "Atendida";
            }
            else if (this.Published == false)
            {
                this.Status = "Em edição";
            }
            else if (this.Rated == false)
            {
                this.Status = "Publicada, aguardando avaliação";
            }
            else if (this.Approved == false)
            {
                this.Status = "Reprovado";

                if (this.ComentarioRevisao != null && this.ComentarioRevisao.Length != 0)
                {
                    this.Status += " - Comentários: " + this.ComentarioRevisao;
                }

                this.Published = false;
            }
            else
            {
                this.Status = "Aprovada, aguardando documentação";
            }
        }
        public RequirementsDetailsModel(GetRequirementDetails_Result item)
        {
            this.Id = item.Tag;
            this.RevisionId = item.RevisionID;
            this.UserName = new UserNameModel(item.UserID);
            this.RevisionNumber = item.RevisionNumber;
            this.RevisionDate = item.RevisionDate;
            this.Summary = item.Title;
            this.Text = item.Text;
            this.Published = item.Published;

            using (var ctx = new Entities())
            {
                int logged = Authentication.GetLoggedUser().UserID;
                this.Rated = (ctx.RequirementRatings.FirstOrDefault(i => i.RevisionID == item.RevisionID) != null);
                this.Approved = (ctx.RequirementRatings.FirstOrDefault(i => i.RevisionID == item.RevisionID && i.Approved == true) != null);
                this.Archived = (ctx.RequirementRevisions.FirstOrDefault(i => i.RevisionID == item.RevisionID && i.Archived == true) != null);

                if (this.Rated)
                {
                    this.ComentarioRevisao = (ctx.UserRatings.FirstOrDefault(i => i.RevisionID == item.RevisionID).Comments);
                }

                var bl = (from i in ctx.Baselines orderby i.SetDate descending select i.SetDate).Take(1);

                if (bl != null && bl.Count() == 1)
                {
                    this.LatestBaseline = bl.ToArray()[0];
                }
            }

            if (item.BaselineDate.HasValue)
            {
                this.Published = this.Rated = this.Implemented = true;

                if (this.LatestBaseline.HasValue && this.LatestBaseline.Value >= item.BaselineDate.Value)
                {
                    this.Status = "Baseline";
                }
                else
                {
                    this.Status = "Implementado";
                }
            }
            else if (this.Published == false)
            {
                this.Status = "Em edição";
            }
            else if (this.Rated == false)
            {
                this.Status = "Publicado, aguardando avaliação";
            }
            else if (this.Approved == false)
            {
                this.Status = "Reprovado";

                if (this.ComentarioRevisao != null && this.ComentarioRevisao.Length != 0)
                {
                    this.Status += " - Comentários: " + this.ComentarioRevisao;
                }

                this.Published = false;
            }
            else if (this.Archived)
            {
                this.Status = "Cancelado";
                this.Implemented = true;
            }
            else
            {
                this.Status = "Aprovado, aguardando implementação";
            }
        }
 public NewRequirementModel(GetRequirementDetails_Result item)
 {
     this.Story = new StoriesDetailsModel(item);
     this.Requirement = new RequirementCreateModel(item.RevisionID);
 }