public IHttpActionResult GetLegalReview(string projectId, Guid?Id = null)
        {
            var tempClosure = TempClosureInfo.FirstOrDefault(tc => tc.ProjectId == projectId);
            var project     = ProjectInfo.Get(projectId, FlowCode.TempClosure_LegalReview);
            var isActor     = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor);
            TempClosureLegalReview entity;

            if (Id != null)
            {
                entity = TempClosureLegalReview.Get(Id.Value);
            }
            else
            {
                entity = TempClosureLegalReview.Get(projectId);
            }
            entity.IsProjectFreezed = entity.CheckIfFreezeProject(projectId);
            var nextRefTableId  = new Guid(FlowInfo.GetRefTableId("TempClosurePackage", projectId));
            var nextFlowStarted = ProjectInfo.Any(p => p.FlowCode == FlowCode.TempClosure_ClosurePackage && p.ProjectId == projectId && p.NodeCode != NodeCode.Start);
            //var haveTask = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.TempClosure_LegalReview && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode);
            var projectComment = ProjectComment.GetSavedComment(entity.Id, "TempClosureLegalReview", ClientCookie.UserCode);
            var isLegalStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.TempClosure_LegalReview);

            return(Ok(new
            {
                Info = tempClosure,
                LegalReview = entity,
                ProjectComment = projectComment != null ? projectComment.Content : "",
                Editable = project.Status == ProjectStatus.Finished && isActor && !nextFlowStarted && !entity.IsHistory,
                Recallable = project.Status != ProjectStatus.Finished && isActor && !entity.IsHistory && isLegalStarted,
                Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.TempClosure_LegalReview)
            }));
        }
Esempio n. 2
0
        public IHttpActionResult InitPage(string projectId, string id = null)
        {
            var letter  = RenewalLetter.Get(projectId, id);
            var project = ProjectInfo.Get(projectId, FlowCode.Renewal_Letter);
            var isActor = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor);

            letter.IsProjectFreezed = letter.CheckIfFreezeProject(projectId);
            var nextRefTableId  = new Guid(FlowInfo.GetRefTableId("RenewalConsInfo", projectId));
            var nextFlowStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_ConsInfo);
            var haveTask        = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_Letter && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode);
            var projectComment  = ProjectComment.GetSavedComment(letter.Id, "RenewalLetter", ClientCookie.UserCode);
            var isStarted       = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Letter);
            var isFinished      = ProjectInfo.IsFlowFinished(projectId, FlowCode.Renewal_Letter);

            return(Ok(new
            {
                Info = RenewalInfo.FirstOrDefault(info => info.ProjectId == letter.ProjectId),
                Letter = letter,
                ProjectComment = projectComment != null ? projectComment.Content : "",
                Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_Letter),
                Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_Letter),
                Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_Letter) && string.IsNullOrEmpty(id)
            }));
        }