コード例 #1
0
        public void Proposal_SubmitProposal(ProposalGeneralInfoJSON p, string Username, bool expect)
        {
            var ProposalRep = IocConfig.Container.GetInstance <IProposalRepository>();

            Assert.DoesNotThrow(() => ProposalRep.SubmitProposal(p, Username));
            Assert.That(ProposalRep.SubmitProposal(p, Username), Is.EqualTo(expect));
        }
コード例 #2
0
 public bool UploadProposal(string username, [FromBody] ProposalGeneralInfoJSON Proposal)
 {
     try
     {
         var ProposalRep = IocConfig.Container.GetInstance <IProposalRepository>();
         return(ProposalRep.SubmitProposal(Proposal, username));
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #3
0
        public void Proposal_RealSubmit()
        {
            var ProposalRep           = IocConfig.Container.GetInstance <IProposalRepository>();
            ProposalGeneralInfoJSON p = new ProposalGeneralInfoJSON()
            {
                Name          = "Unit test proposal" + DateTime.Now.ToString(),
                LatinName     = "Unit Test Proposal" + DateTime.Now.ToString(),
                ReseachTypeID = Guid.Parse("232B3133-79BF-4A9B-BF58-ABE941C05860"),
                keywords      = new List <string>()
                {
                    "test1", "test2"
                },
                FileID = Guid.Parse("F4234BCF-79AE-48EA-B7BE-C4BA0EF7E37B")
            };

            Assert.DoesNotThrow(() => {
                Assert.That(ProposalRep.SubmitProposal(p, "0020881029"), Is.EqualTo(true));
            });
        }
コード例 #4
0
        public void Proposal_Submit_ProposalFileIsInvalid()
        {
            var ProposalRep           = IocConfig.Container.GetInstance <IProposalRepository>();
            ProposalGeneralInfoJSON p = new ProposalGeneralInfoJSON()
            {
                Name          = "Unit test proposal",
                LatinName     = "Unit Test Proposal",
                ReseachTypeID = Guid.Parse("232B3133-79BF-4A9B-BF58-ABE941C05860"),
                keywords      = new List <string>()
                {
                    "test1", "test2"
                },
                FileID = Guid.Parse("232B3133-79BF-4A9B-BF58-ABE941C05860")
            };

            Assert.DoesNotThrow(() => {
                Assert.That(ProposalRep.SubmitProposal(p, "0020881029"), Is.EqualTo(false));
            });
        }
コード例 #5
0
        public void Proposal_Submit_ResearchTypeIsInvalid()
        {
            var ProposalRep           = IocConfig.Container.GetInstance <IProposalRepository>();
            ProposalGeneralInfoJSON p = new ProposalGeneralInfoJSON()
            {
                Name          = "Unit test proposal",
                LatinName     = "Unit Test Proposal",
                ReseachTypeID = Guid.Parse("F4234BCF-79AE-48EA-B7BE-C4BA0EF7E37B"),
                keywords      = new List <string>()
                {
                    "test1", "test2"
                },
                FileID = Guid.Parse("F4234BCF-79AE-48EA-B7BE-C4BA0EF7E37B")
            };

            Assert.DoesNotThrow(() => {
                Assert.That(ProposalRep.SubmitProposal(p, "0020881029"), Is.EqualTo(false));
            });
        }
コード例 #6
0
        public bool SubmitProposal(ProposalGeneralInfoJSON ProposalJSON, string Username)
        {
            using (var dbContextTransaction = Context.Database.BeginTransaction())
            {
                try
                {
                    bool result = true;

                    Student s = StudentRepository.Value.SelectBy(q => q.SocialSecurityNumber == Username).FirstOrDefault();
                    if (s == null)
                    {
                        return(false);
                    }

                    Proposal p = new Proposal();
                    p.ID                  = Guid.NewGuid();
                    p.CreateDate          = DateTime.Now;
                    p.IsFinalApprove      = false;
                    p.LatestOperation     = "ثبت شده توسط دانشجو";
                    p.LatinName           = ProposalJSON.LatinName;
                    p.Name                = ProposalJSON.Name;
                    p.ResearchTypeID      = ProposalJSON.ReseachTypeID;
                    p.ProposalStageID     = StageRepository.SelectBy(w => w.Order == 1).FirstOrDefault().ID;
                    p.ProposalStatusID    = StatusRepository.SelectBy(e => e.IsDefault).FirstOrDefault().ID;
                    p.StudentID           = s.ID;
                    p.FirstJudgeApproved  = false;
                    p.SecondJudgeApproved = false;

                    Add(p);

                    result &= KeywordRepository.AddProposalKeyword(ProposalJSON.keywords, p.ID);

                    //WorkFlow
                    ProposalWorkflowHistory work = new ProposalWorkflowHistory {
                        ID                   = Guid.NewGuid(),
                        OccuranceDate        = DateTime.Now,
                        OccuredByProfessorID = null,
                        OccuredByStudentID   = s.ID,
                        ProposalID           = p.ID,
                        ProposalOperationID  = Guid.Parse("4aaaa946-53ce-45c8-a317-20eba03867e0")
                    };
                    ProposalWorkflowHistoryRepository.Add(work);
                    //

                    ProposalFile pf = ProposalFileRepository.Get(ProposalJSON.FileID);
                    if (pf == null)
                    {
                        return(false);
                    }
                    else
                    {
                        pf.ProposalID = p.ID;
                    }


                    Commit();
                    dbContextTransaction.Commit();
                    dbContextTransaction.Dispose();

                    return(result);
                }
                catch (Exception e)
                {
                    dbContextTransaction.Rollback();
                    dbContextTransaction.Dispose();
                    return(false);
                }
            }
        }