コード例 #1
0
        public void GivenACode_WhenAManCoIsRequested_ThenAManCoIsReturned()
        {
            _manCoRepository.Setup(a => a.GetManCo(It.IsAny <string>())).Returns(new ManCo());
            ManCo manCo = _manCoService.GetManCo(It.IsAny <string>());

            manCo.Should().NotBeNull();
        }
コード例 #2
0
        public void WhenIUpdateAManCo_AndTheManCoDoesNotExist_ThenAnExceptionIsThrown()
        {
            _manCoRepository.Create(_manCo1);

            ManCo manCo = _manCoRepository.Entities.Where(p => p.Code == "code").FirstOrDefault();

            Assert.Throws <UnityException>(() => _manCoRepository.Update(manCo.Id + 1001, "code 1", "description name 1"));
        }
コード例 #3
0
        public virtual ActionResult Edit(int manCoId)
        {
            ManCo manCo = _manCoService.GetManCo(manCoId);

            return(View(new EditManCoViewModel {
                ManCoId = manCoId, Code = manCo.Code, Description = manCo.Description
            }));
        }
コード例 #4
0
        public void WhenIUpdateADocType_ThenTheDocTypeIsUpdated()
        {
            _manCoRepository.Create(_manCo1);

            ManCo manCo = _manCoRepository.Entities.Where(p => p.Code == "code").FirstOrDefault();

            _manCoRepository.Update(manCo.Id, "new code", "description 1");
            manCo = _manCoRepository.Entities.Where(p => p.Code == "new code").FirstOrDefault();

            manCo.Should().NotBeNull();
        }
コード例 #5
0
ファイル: ManCoService.cs プロジェクト: syedshah/Repository
 public ManCo CreateManCo(string code, string description)
 {
     try
     {
         var manCo = new ManCo(code, description);
         return(_manCoRepository.Create(manCo));
     }
     catch (Exception e)
     {
         throw new UnityException("Unable to create man co", e);
     }
 }
コード例 #6
0
 public void Setup()
 {
     _transactionScope       = new TransactionScope();
     _autoApprovalRepository =
         new AutoApprovalRepository(ConfigurationManager.ConnectionStrings["Unity"].ConnectionString);
     _docTypeRepository    = new DocTypeRepository(ConfigurationManager.ConnectionStrings["Unity"].ConnectionString);
     _subDocTypeRepository = new SubDocTypeRepository(ConfigurationManager.ConnectionStrings["Unity"].ConnectionString);
     _manCoRepository      = new ManCoRepository(ConfigurationManager.ConnectionStrings["Unity"].ConnectionString);
     _docType      = BuildMeA.DocType("code", "description");
     _manCo1       = BuildMeA.ManCo("code1", "description1");
     _manCo2       = BuildMeA.ManCo("code2", "description2");
     _subDocType1  = BuildMeA.SubDocType("code 1", "description 1").WithDocType(_docType);
     _subDocType2  = BuildMeA.SubDocType("code 2", "description 3").WithDocType(_docType);
     _autoApproval =
         BuildMeA.AutoApproval().WithDocType(_docType).WithSubDocType(_subDocType1).WithManCo(_manCo1);
     _autoApproval2 =
         BuildMeA.AutoApproval().WithDocType(_docType).WithSubDocType(_subDocType2).WithManCo(_manCo2);
     _autoApproval3 =
         BuildMeA.AutoApproval().WithDocType(_docType).WithSubDocType(_subDocType2).WithManCo(_manCo1);
 }
コード例 #7
0
 public XmlFileBuilder WithManCo(ManCo manCo)
 {
     Instance.ManCo = manCo;
     return(this);
 }
コード例 #8
0
        private void SetUpVariables()
        {
            _manCo1 = new ManCo {
                Id = 1
            };
            _manCo2 = new ManCo {
                Id = 2
            };
            _manCo3 = new ManCo {
                Id = 3
            };

            this._manCos = new List <ManCo>();

            this._manCos.Add(_manCo1);
            this._manCos.Add(_manCo2);
            this._manCos.Add(_manCo3);

            _docType1 = new DocType {
                Id = 1, Code = "Code1"
            };
            _docType2 = new DocType {
                Id = 2, Code = "Code2"
            };
            _docType3 = new DocType {
                Id = 3, Code = "Code3"
            };

            this._docTypes = new List <DocType>();

            this._docTypes.Add(_docType1);
            this._docTypes.Add(_docType2);
            this._docTypes.Add(_docType3);

            this._subDocType1 = new SubDocType {
                Id = 1, DocType = _docType1, Code = "SubCode1"
            };
            this._subDocType2 = new SubDocType {
                Id = 2, DocType = _docType1, Code = "subCode2"
            };
            this._subDocType3 = new SubDocType {
                Id = 3, DocType = _docType1, Code = "SubCode3"
            };
            this._subDocType4 = new SubDocType {
                Id = 4, DocType = _docType2, Code = "SubCode4"
            };
            this._subDocType5 = new SubDocType {
                Id = 5, DocType = _docType2, Code = "SubCode5"
            };
            this._subDocType6 = new SubDocType {
                Id = 6, DocType = _docType3, Code = "SubCode6"
            };
            this._subDocType7 = new SubDocType {
                Id = 7, DocType = _docType3, Code = "SubCode7"
            };
            this._subDocType8 = new SubDocType {
                Id = 8, DocType = _docType3, Code = "SubCode8"
            };

            this._subDocTypes = new List <SubDocType>();

            this._subDocTypes.Add(_subDocType1);
            this._subDocTypes.Add(_subDocType2);
            this._subDocTypes.Add(_subDocType3);
            this._subDocTypes.Add(_subDocType4);
            this._subDocTypes.Add(_subDocType5);
            this._subDocTypes.Add(_subDocType6);
            this._subDocTypes.Add(_subDocType7);
            this._subDocTypes.Add(_subDocType8);

            this._approval1 = new AutoApproval {
                Id = 1, DocType = _docType1, SubDocType = _subDocType1, Manco = _manCo1
            };
            this._approval2 = new AutoApproval {
                Id = 2, DocType = _docType1, SubDocType = _subDocType2, Manco = _manCo1
            };
            this._approval3 = new AutoApproval {
                Id = 3, DocType = _docType1, SubDocType = _subDocType3, Manco = _manCo1
            };

            this._approval4 = new AutoApproval {
                Id = 4, DocType = _docType2, SubDocType = _subDocType4, Manco = _manCo1
            };
            this._approval5 = new AutoApproval {
                Id = 5, DocType = _docType3, SubDocType = _subDocType7, Manco = _manCo1
            };
            this._approvals = new List <AutoApproval>();

            this._approvals.Add(_approval1);
            this._approvals.Add(_approval2);
            this._approvals.Add(_approval3);
            this._approvals.Add(_approval4);
            this._approvals.Add(_approval5);
        }
コード例 #9
0
ファイル: ZipPackage.cs プロジェクト: syedshah/Repository
        public void SaveToDatabase(IXmlFileService xmlFileService,
                                   IZipFileService zipFileService, IConFileService conFileService, IDocTypeService docTypeService, IManCoService manCoService, ApplicationInfo appInfo)
        {
            try
            {
                NexdoxMessaging.SendMessage("    Adding Data to SQL Database", true, this);
                foreach (ZipPackage zp in Statics.zipPackage)
                {
                    switch (Path.GetExtension(zp.FileName).ToLower())
                    {
                    case ".xml":

                        DocType docType = docTypeService.GetDocType(zp.DocumentType);
                        if (docType == null)
                        {
                            throw new Exception(string.Format("Document type {0} not found in unity database", zp.DocumentType));
                        }

                        ManCo manCo = manCoService.GetManCo(zp.ManCoID);
                        if (manCo == null)
                        {
                            throw new Exception(string.Format("Man Co {0} not found in unity database", zp.ManCoID));
                        }

                        xmlFileService.CreateXmlFile(
                            Statics.zipPackage.DocumentSetID.ToString(),
                            zp.FileName,
                            zp.ParentZipFileName,
                            zp.Offshore,
                            docType.Id,
                            manCo.Id,
                            0,
                            string.Empty,
                            zp.FileName,
                            DateTime.Now,
                            appInfo.NexdoxGlobalRunID.ToString(),
                            File.GetLastWriteTime(appInfo.InputPath));
                        break;

                    case ".zip":
                        if (zp.IsBigZip)
                        {
                            zipFileService.CreateBigZipFile(Statics.zipPackage.DocumentSetID.ToString(), zp.FileName, File.GetLastWriteTime(appInfo.InputPath));
                        }
                        else
                        {
                            zipFileService.CreateLittleZipFile(Statics.zipPackage.DocumentSetID.ToString(), zp.FileName, zp.ParentZipFileName, File.GetLastWriteTime(appInfo.InputPath));
                        }
                        break;

                    case ".con":
                        conFileService.CreateConFile(Statics.zipPackage.DocumentSetID.ToString(), zp.FileName, zp.ParentZipFileName, File.GetLastWriteTime(appInfo.InputPath));
                        break;
                    }

                    /*SqlCommand sqlComm = new SqlCommand("sp_InsertInputFile", sqlConn);
                     * sqlComm.CommandType = CommandType.StoredProcedure;
                     *
                     * SqlParameter InputFileName = sqlComm.Parameters.Add("@INPUTFILENAME", SqlDbType.VarChar);
                     * InputFileName.Direction = ParameterDirection.Input;
                     * InputFileName.Value = zp.FileName;
                     *
                     * SqlParameter DocType = sqlComm.Parameters.Add("@DOCTYPE", SqlDbType.VarChar);
                     * DocType.Direction = ParameterDirection.Input;
                     * DocType.Value = zp.DocumentType;
                     *
                     * SqlParameter ParentDocFileName = sqlComm.Parameters.Add("@PARENTDOCFILENAME", SqlDbType.VarChar);
                     * ParentDocFileName.Direction = ParameterDirection.Input;
                     * ParentDocFileName.Value = zp.ParentZipFileName;
                     *
                     * SqlParameter BigZip = sqlComm.Parameters.Add("@BIGZIP", SqlDbType.Bit);
                     * BigZip.Direction = ParameterDirection.Input;
                     * BigZip.Value = zp.IsBigZip;
                     *
                     * SqlParameter LittleZip = sqlComm.Parameters.Add("@LITTLEZIP", SqlDbType.Bit);
                     * LittleZip.Direction = ParameterDirection.Input;
                     * LittleZip.Value = zp.IsLittleZip;
                     *
                     * SqlParameter DocumentSetID = sqlComm.Parameters.Add("@DOCUMENTSET_ID", SqlDbType.UniqueIdentifier);
                     * DocumentSetID.Direction = ParameterDirection.Input;
                     * DocumentSetID.Value = Statics.zipPackage.DocumentSetID;
                     *
                     * SqlParameter OffShore = sqlComm.Parameters.Add("@OFFSHORE", SqlDbType.Bit);
                     * OffShore.Direction = ParameterDirection.Input;
                     * OffShore.Value = zp.Offshore;
                     *
                     * SqlParameter ManCo = sqlComm.Parameters.Add("@MANCO", SqlDbType.VarChar);
                     * ManCo.Direction = ParameterDirection.Input;
                     * ManCo.Value = zp.ManCoID.ToString();
                     *
                     * SqlParameter Domicile = sqlComm.Parameters.Add("@DOMICILE", SqlDbType.VarChar);
                     * Domicile.Direction = ParameterDirection.Input;
                     * Domicile.Value = zp.Domicile;
                     *
                     * SqlParameter StatusID = sqlComm.Parameters.Add("@STATUS_ID", SqlDbType.Int);
                     * StatusID.Direction = ParameterDirection.Input;
                     * StatusID.Value = zp.StatusID;
                     *
                     * SqlParameter InputDateCreation = sqlComm.Parameters.Add("@INPUTCREATIONDATE", SqlDbType.DateTime);
                     * InputDateCreation.Direction = ParameterDirection.Input;
                     * InputDateCreation.Value = zp.InputCreationDate;
                     *
                     * SqlDataReader myReader = sqlComm.ExecuteReader();
                     * myReader.Close();*/
                }
            }
            catch (Exception e)
            {
                throw NexdoxMessaging.Exception(e.Message, this);
            }
        }
コード例 #10
0
 public AutoApprovalBuilder WithManCo(ManCo manCo)
 {
     Instance.Manco = manCo;
     return(this);
 }
コード例 #11
0
 public DocumentBuilder WithManCo(ManCo manCo)
 {
     Instance.ManCo = manCo;
     return(this);
 }