Inheritance: IUnitOfWork
 public HubAllocationService(UnitOfWork unitOfWork)
 {
     this._unitOfWork = unitOfWork;
 }
        public void Init()
        {
            var giftDetails = new List<GiftCertificateDetail>()
                                  {
                                      new GiftCertificateDetail
                                          {
                                              GiftCertificateID = 1,
                                              AccountNumber = 1,
                                              BillOfLoading = "1",
                                              Detail = new Detail {DetailID = 1, Name = "WFP"},
                                              CommodityID = 1,
                                              Commodity = new Commodity() {CommodityID = 1, Name = "CSB"}
                                          }
                                  };
            ;
            var gifts = new List<GiftCertificate>()
                            {
                                new GiftCertificate()
                                    {GiftCertificateID = 1, ProgramID = 1, ReferenceNo = "1", ShippingInstructionID = 1,ShippingInstruction =new ShippingInstruction() {ShippingInstructionID = 1,Value ="SI-001" },DonorID=1,Donor=new Donor(){DonorID=1,Name="WFP"},GiftCertificateDetails=giftDetails},
                                new GiftCertificate()
                                    {GiftCertificateID = 1, ProgramID = 1, ReferenceNo = "1", ShippingInstructionID = 1,ShippingInstruction =new ShippingInstruction() {ShippingInstructionID = 1,Value ="SI-001" },DonorID=1,Donor=new Donor(){DonorID=1,Name="WFP"},GiftCertificateDetails=giftDetails},
                                new GiftCertificate()
                                    {GiftCertificateID = 1, ProgramID = 1, ReferenceNo = "1", ShippingInstructionID = 1,ShippingInstruction =new ShippingInstruction() {ShippingInstructionID = 1,Value ="SI-001" },DonorID=1,Donor=new Donor(){DonorID=1,Name="WFP"},GiftCertificateDetails=giftDetails}
                            };

            var commonService = new Mock<ICommonService>();
            commonService.Setup(
                t =>
                t.GetCommodities(It.IsAny<Expression<Func<Commodity, bool>>>(),
                                 It.IsAny<Func<IQueryable<Commodity>, IOrderedQueryable<Commodity>>>(),
                                 It.IsAny<string>())).Returns(new List<Commodity>()
                                                                  {new Commodity() {CommodityID = 1, Name = "CSB"}});
            commonService.Setup(
               t =>
               t.GetCommodityTypes(It.IsAny<Expression<Func<CommodityType, bool>>>(),
                                It.IsAny<Func<IQueryable<CommodityType>, IOrderedQueryable<CommodityType>>>(),
                                It.IsAny<string>())).Returns(new List<CommodityType>() { new CommodityType() { CommodityTypeID = 1, Name = "CSB++" } });
            commonService.Setup(
               t =>
               t.GetDetails(It.IsAny<Expression<Func<Detail, bool>>>(),
                                It.IsAny<Func<IQueryable<Detail>, IOrderedQueryable<Detail>>>(),
                                It.IsAny<string>())).Returns(new List<Detail>() { new Detail() { DetailID = 1, Name = "CSB" } });
            commonService.Setup(
               t =>
               t.GetDonors(It.IsAny<Expression<Func<Donor, bool>>>(),
                                It.IsAny<Func<IQueryable<Donor>, IOrderedQueryable<Donor>>>(),
                                It.IsAny<string>())).Returns(new List<Donor>() { new Donor() { DonorID = 1, Name = "WFP" } });
            commonService.Setup(
             t =>
             t.GetPrograms(It.IsAny<Expression<Func<Program, bool>>>(),
                              It.IsAny<Func<IQueryable<Program>, IOrderedQueryable<Program>>>(),
                              It.IsAny<string>())).Returns(new List<Program>() { new Program() { ProgramID = 1, Name = "PSNP" } });

            var giftCertificateService = new Mock<IGiftCertificateService>();
            giftCertificateService.Setup(t => t.IsSINumberNewOrEdit(It.IsAny<string>(), It.IsAny<int>())).Returns(true);
            giftCertificateService.Setup(t => t.Get(It.IsAny<Expression<Func<GiftCertificate,bool>>>(),It.IsAny<Func<IQueryable<GiftCertificate>,IOrderedQueryable<GiftCertificate>>>(),It.IsAny<string>())).Returns(gifts);
            giftCertificateService.Setup(t => t.AddGiftCertificate(It.IsAny<GiftCertificate>())).Returns(true);
            var giftCertificateDetailService = new Mock<IGiftCertificateDetailService>();
            var transactionService = new Mock<ITransactionService>();
            var letterTemplateService = new Mock<ILetterTemplateService>();
            transactionService.Setup(t => t.PostGiftCertificate(It.IsAny<int>())).Returns(true);

            var userAccountService = new Mock<IUserAccountService>();
            userAccountService.Setup(t => t.GetUserInfo(It.IsAny<string>())).Returns(new UserInfo()
            {
                UserName = "******",
                DatePreference = "en"
            });

            var fakeContext = new Mock<HttpContextBase>();
            var identity = new GenericIdentity("User");
            var principal = new GenericPrincipal(identity, null);
            fakeContext.Setup(t => t.User).Returns(principal);
            var controllerContext = new Mock<ControllerContext>();
            controllerContext.Setup(t => t.HttpContext).Returns(fakeContext.Object);

            UnitOfWork _unitOfWork = new UnitOfWork();
            var shippingInstruction = new List<ShippingInstruction>
                {
                    new ShippingInstruction { ShippingInstructionID = 1, Value = "40401/32664.23"},
                    new ShippingInstruction {ShippingInstructionID = 2, Value = "00020272"}
                };
            var shippingInstructionService = new Mock<IShippingInstructionService>();
            shippingInstructionService.Setup(m => m.GetAllShippingInstruction()).Returns(shippingInstruction);

            _giftCertificateController = new GiftCertificateController(giftCertificateService.Object, giftCertificateDetailService.Object, commonService.Object,
                                         transactionService.Object, letterTemplateService.Object, _unitOfWork, userAccountService.Object,shippingInstructionService.Object);
            _giftCertificateController.ControllerContext = controllerContext.Object;
        }
示例#3
0
 public GiftCertificateService(UnitOfWork unitOfWork)
 {
     this._unitOfWork = unitOfWork;
 }
示例#4
0
 public UserHubService(UnitOfWork unitOfWork)
 {
     this._unitOfWork = unitOfWork;
 }
        public static IEnumerable<NeedAssessmentDao> ReturnNeedAssessmentHeaderViewModel(int regionId)
        {
            IUnitOfWork _unitOfWork = new UnitOfWork();
            List<NeedAssessmentHeader> needAssessment = _unitOfWork.NeedAssessmentHeaderRepository.Get(r => r.NeedAssessment.Region == regionId).ToList();

            return needAssessment.Select(need => need.NeedAssessment.NeedADate != null ? new NeedAssessmentDao()
            {
                NeedAID = (int)need.NeedAID,
                NAHeaderId = need.NAHeaderId,
                RegionId = need.NeedAssessment.Region,
                Region = need.NeedAssessment.AdminUnit.Name,
                Zone = need.AdminUnit.Name,

            } : null);
        }
示例#6
0
 public TemplateTypeService(UnitOfWork unitOfWork)
 {
     this._unitOfWork = unitOfWork;
 }
示例#7
0
 public LetterTemplateService(UnitOfWork unitOfWork)
 {
     this._unitOfWork = unitOfWork;
 }
 public TemplateFieldService(UnitOfWork unitOfWork)
 {
     this._unitOfWork = unitOfWork;
 }
 public InKindContributionDetailService(UnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }