public string RejectProposal(Guid ProposalID, Guid ProfessorID, [FromBody] ProposalCommentJSON comment, bool BigChanges = true) { var ProposalRepository = IocConfig.Container.GetInstance <IProposalRepository>(); ProposalComment p = new ProposalComment { Content = comment.Content, ImportanceLevel = comment.ImportanceLevel }; return(ProposalRepository.RejectProposal(ProposalID, ProfessorID, p, BigChanges)); }
public string ApproveProposal(Guid ProposalID, Guid ProfessorID, [FromBody] ProposalCommentJSON comment) { var ProposalRepository = IocConfig.Container.GetInstance <IProposalRepository>(); ProposalComment p = new ProposalComment { Content = comment.Content, ImportanceLevel = comment.ImportanceLevel }; return(ProposalRepository.ApproveProposal(ProposalID, ProfessorID, p)); }
public bool EditProposal(Guid ProposalID, Guid FileID, string com) { using (var transaction = Context.Database.BeginTransaction()) { try { var proposal = Get(ProposalID); var file = ProposalFileRepository.Get(FileID); if (file == null || proposal == null) { return(false); } file.ProposalID = ProposalID; ProposalWorkflowHistory w = new ProposalWorkflowHistory() { ID = Guid.NewGuid(), OccuredByProfessorID = null, OccuredByStudentID = proposal.StudentID, OccuranceDate = DateTime.Now, ProposalID = proposal.ID, ProposalOperationID = Guid.Parse("bf63e692-e4f9-4e7e-bf3d-1dc2c8189078") }; ProposalWorkflowHistoryRepository.Add(w); ProposalComment c = new ProposalComment() { ID = Guid.NewGuid(), OccuredByProfessorID = null, OccuredByStudentID = proposal.StudentID, OccuranceDate = DateTime.Now, Content = com, ProposalID = proposal.ID, ImportanceLevel = null, ProposalStageID = proposal.ProposalStageID }; ProposalCommentRepository.Add(c); Commit(); transaction.Commit(); transaction.Dispose(); return(true); } catch (Exception e) { transaction.Rollback(); transaction.Dispose(); return(false); } } }
public void Proposal_ApproveProposal() { var ProposalRep = IocConfig.Container.GetInstance <IProposalRepository>(); ProposalComment com = new ProposalComment() { Content = "Unit Test", ImportanceLevel = null }; //Invalid Proposal Assert.IsNotEmpty(ProposalRep.ApproveProposal(Guid.Parse("8ff58299-98e4-4216-93de-0fd31b549ee0"), Guid.Parse("8ff58299-98e4-4216-93de-0fd31b549ee0"), com)); //Invalid Judge Assert.IsNotEmpty(ProposalRep.ApproveProposal(Guid.Parse("47b867b9-2111-44a0-9754-a75696b7ed5f"), Guid.Parse("47b867b9-2111-44a0-9754-a75696b7ed5f"), com)); //Stage 3 Assert.DoesNotThrow(() => { Assert.IsEmpty(ProposalRep.ApproveProposal(Guid.Parse("de7a36a7-d4a7-4edf-927a-f34e8218a119"), Guid.Parse("65fa2183-6839-4c53-981d-f1c733551a71"), com)); }); //Stage 5 Assert.DoesNotThrow(() => { Assert.IsEmpty(ProposalRep.ApproveProposal(Guid.Parse("49af2112-fe58-4f3c-be9b-2084e5cdaf86"), Guid.Parse("65fa2183-6839-4c53-981d-f1c733551a71"), com)); }); //Stage 6 Assert.DoesNotThrow(() => { Assert.IsEmpty(ProposalRep.ApproveProposal(Guid.Parse("ea8ad633-8da8-4aeb-a1f3-071aca2bee55"), Guid.Parse("65fa2183-6839-4c53-981d-f1c733551a71"), com)); }); //Stage 8 Assert.DoesNotThrow(() => { Assert.IsEmpty(ProposalRep.ApproveProposal(Guid.Parse("659f8aa7-3542-47c0-bc13-b58b17a8ddf9"), Guid.Parse("65FA2183-6839-4C53-981D-F1C733551A71"), com)); }); //Stage 9 Assert.DoesNotThrow(() => { Assert.IsEmpty(ProposalRep.ApproveProposal(Guid.Parse("d7597512-6e08-4f72-a724-7d1b13001496"), Guid.Parse("65fa2183-6839-4c53-981d-f1c733551a71"), com)); }); //Stage 10 Assert.DoesNotThrow(() => { Assert.IsEmpty(ProposalRep.ApproveProposal(Guid.Parse("a8cdb3c3-0663-4a06-a010-9f716496cf54"), Guid.Parse("65fa2183-6839-4c53-981d-f1c733551a71"), com)); }); //Stage 12 Assert.DoesNotThrow(() => { Assert.IsEmpty(ProposalRep.ApproveProposal(Guid.Parse("ac221616-793c-480e-a7fd-a1a0a8e08781"), Guid.Parse("65FA2183-6839-4C53-981D-F1C733551A71"), com)); }); }
public string RejectProposal(Guid ID, Guid ProfessorID, ProposalComment comment, bool BigChanges = true) { using (var dbContextTransaction = Context.Database.BeginTransaction()) { try { var proposal = Get(ID); if (proposal == null) { dbContextTransaction.Rollback(); dbContextTransaction.Dispose(); return("اطلاعات پروپوزال اشتباه است"); } if (proposal.ProposalStage.Order != 3 && proposal.ProposalStage.Order != 5 && proposal.ProposalStage.Order != 6 && proposal.ProposalStage.Order != 8 && proposal.ProposalStage.Order != 9 && proposal.ProposalStage.Order != 10 && proposal.ProposalStage.Order != 12) { dbContextTransaction.Rollback(); dbContextTransaction.Dispose(); return("پروپوزال در دست بررسی این کاربر قرار نیست"); } var currentStage = StageRepository.Get(proposal.ProposalStageID); if (currentStage != null) { ProposalStage nextStage = null; //5 ==> 4 //9 ==> 7 //3 ==> 4 //6 ==> 7 BigChanges //8 ==> 7 //10 ==> 11 //12 ==> 11 switch (currentStage.Order) { case 3: { if (proposal.FirstJudgeID == ProfessorID) { proposal.FirstJudgeApproved = true; } else if (proposal.SecondJudgeID == ProfessorID) { proposal.SecondJudgeApproved = true; } if (proposal.SecondJudgeApproved && proposal.FirstJudgeApproved) { nextStage = StageRepository.SelectBy(p => p.Order == 4).FirstOrDefault(); proposal.FirstJudgeApproved = false; proposal.SecondJudgeApproved = false; proposal.LatestOperation = "رد شده توسط داوران"; } else { nextStage = currentStage; } break; } case 5: { if (proposal.FirstJudgeID == ProfessorID) { proposal.FirstJudgeApproved = true; } else if (proposal.SecondJudgeID == ProfessorID) { proposal.SecondJudgeApproved = true; } if (proposal.SecondJudgeApproved && proposal.FirstJudgeApproved) { nextStage = StageRepository.SelectBy(p => p.Order == 4).FirstOrDefault(); proposal.FirstJudgeApproved = false; proposal.SecondJudgeApproved = false; proposal.LatestOperation = "رد شده توسط داوران"; } else { nextStage = currentStage; } break; } case 6: { if (proposal.FirstJudgeID == ProfessorID) { proposal.FirstJudgeApproved = true; } else if (proposal.SecondJudgeID == ProfessorID) { proposal.SecondJudgeApproved = true; } if (proposal.SecondJudgeApproved && proposal.FirstJudgeApproved) { nextStage = StageRepository.SelectBy(p => p.Order == 7).FirstOrDefault(); proposal.FirstJudgeApproved = false; proposal.SecondJudgeApproved = false; proposal.BigChangesForJudges = BigChanges; proposal.LatestOperation = "رد شده توسط داوران در جلسه دفاع"; } else { nextStage = currentStage; } break; } case 8: { nextStage = StageRepository.SelectBy(p => p.Order == 7).FirstOrDefault(); proposal.LatestOperation = "رد شده توسط استاد راهنما"; break; } case 9: { if (proposal.FirstJudgeID == ProfessorID) { proposal.FirstJudgeApproved = true; } else if (proposal.SecondJudgeID == ProfessorID) { proposal.SecondJudgeApproved = true; } if (proposal.SecondJudgeApproved && proposal.FirstJudgeApproved) { nextStage = StageRepository.SelectBy(p => p.Order == 7).FirstOrDefault(); proposal.FirstJudgeApproved = false; proposal.SecondJudgeApproved = false; proposal.LatestOperation = "رد شده توسط داوران"; } else { nextStage = currentStage; } break; } case 10: { nextStage = StageRepository.SelectBy(p => p.Order == 11).FirstOrDefault(); proposal.IsFinalApprove = true; proposal.LatestOperation = "رد شده توسط شورا"; break; } case 12: { nextStage = StageRepository.SelectBy(p => p.Order == 11).FirstOrDefault(); proposal.LatestOperation = "رد شده توسط استاد راهنما"; break; } } if (nextStage != null) { proposal.ProposalStageID = nextStage.ID; //WorkFlow ProposalWorkflowHistory work = new ProposalWorkflowHistory { ID = Guid.NewGuid(), OccuranceDate = DateTime.Now, OccuredByProfessorID = ProfessorID, OccuredByStudentID = null, ProposalID = proposal.ID, ProposalOperationID = Guid.Parse("73142388-9CE9-465A-AC7E-830B5D5F317C") }; ProposalWorkflowHistoryRepository.Add(work); // //Comment ProposalComment com = new ProposalComment { ID = Guid.NewGuid(), ImportanceLevel = comment.ImportanceLevel, Content = comment.Content, OccuranceDate = DateTime.Now, OccuredByProfessorID = ProfessorID, OccuredByStudentID = null, ProposalID = proposal.ID, ProposalStageID = currentStage.ID }; ProposalCommentRepository.Add(com); // } } Commit(); dbContextTransaction.Commit(); dbContextTransaction.Dispose(); return(""); } catch (Exception e) { dbContextTransaction.Rollback(); dbContextTransaction.Dispose(); return("خطا در سرور"); } } }