Exemple #1
0
 public bool Exist(string key)
 {
     if (ValidateService.IsNullOrEmpty(key))
     {
         throw new ArgumentNullException("key", string.Format("key is null or empty in the {0} cahced.", _name));
     }
     lock (_locker)
     {
         if (_ht.ContainsKey(key))
         {
             WeakReference objWeak = (WeakReference)_ht[key];
             if (null == objWeak || !objWeak.IsAlive || null == objWeak.Target)
             {
                 _ht.Remove(key);
                 return(false);
             }
             IAlbianCachedObject obj = (IAlbianCachedObject)objWeak.Target;
             if (((int)DateTime.Now.Subtract(obj.CreateTime).TotalSeconds) <= obj.Timespan)
             {
                 if (_logger != null)
                 {
                     _logger.WarnFormat("key:{0} in {1} cached is expired.", key, _name);
                 }
                 return(true);
             }
             return(false);
         }
         return(false);
     }
 }
Exemple #2
0
        public void Update(string key, object value, int seconds)
        {
            if (ValidateService.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key", string.Format("key is null or empty in the {0} cahced.", _name));
            }
            if (0 >= seconds)
            {
                throw new ArgumentNullException("seconds",
                                                string.Format("seconds is less or eq 0 in the {0} cahced.", _name));
            }

            lock (_locker)
            {
                if (!_ht.ContainsKey(key))
                {
                    throw new AlbianCachedException(string.Format("the {0} cached is not exist in the {1} cached.", key,
                                                                  _name));
                }
                IAlbianCachedObject obj = new AlbianCachedObject
                {
                    Timespan   = seconds,
                    Key        = key,
                    Value      = value,
                    CreateTime = DateTime.Now
                };
                _ht[key] = WeakReferenceObject.CreateWeakReferenceObject(obj);
            }
        }
Exemple #3
0
 public UploadSong()
 {
     this.InitializeComponent();
     this.songService         = new SongService();
     this.validateService     = new ValidateService();
     this.NavigationCacheMode = NavigationCacheMode.Enabled;
 }
Exemple #4
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] ExternalPurchaseOrderViewModel vm)
        {
            identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

            ExternalPurchaseOrder m = _mapper.Map <ExternalPurchaseOrder>(vm);

            ValidateService validateService = (ValidateService)_facade.serviceProvider.GetService(typeof(ValidateService));

            try
            {
                validateService.Validate(vm);

                int result = await _facade.Update(id, m, identityService.Username);

                return(NoContent());
            }
            catch (ServiceValidationExeption e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE)
                    .Fail(e);
                return(BadRequest(Result));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
Exemple #5
0
 public void Set(string key, object value)
 {
     if (ValidateService.IsNullOrEmpty(key))
     {
         throw new ArgumentNullException("key", string.Format("key is null or empty in the {0} chunk.", _name));
     }
     lock (_locker)
     {
         if (_ht.ContainsKey(key))
         {
             IAlbianChunkObject obj = new AlbianChunkObject
             {
                 Key        = key,
                 Value      = value,
                 CreateTime = DateTime.Now
             };
             _ht[key] = obj;
         }
         else
         {
             IAlbianChunkObject obj = new AlbianChunkObject
             {
                 Key        = key,
                 Value      = value,
                 CreateTime = DateTime.Now
             };
             _ht.Add(key, obj);
         }
     }
 }
Exemple #6
0
 public Register()
 {
     this.InitializeComponent();
     this.memberService       = new MemberServiceApi();
     this.validateService     = new ValidateService();
     this.NavigationCacheMode = NavigationCacheMode.Enabled;
 }
        public void Test_Validate_Should_Return_Errors()
        {
            // Arrange
            var ValidateService = new ValidateService();
            var testClass       = new TestClassWithAttrs();

            // Act
            var errors = ValidateService.Validate(testClass);

            // Assert
            Assert.AreSame(testClass, errors.Object);
            Assert.AreEqual(10, errors.Errors.Length);

            CollectionAssert.AreEquivalent(
                new[]
            {
                new ValidationError("staticproperty", "Static_Property"),
                new ValidationError("publicproperty", "Public_Property"),
                new ValidationError("internalproperty", "Internal_Property"),
                new ValidationError("protectedproperty", "Protected_Property"),
                new ValidationError("privateproperty", "Private_Property"),

                new ValidationError("staticmethod", "Static_Method"),
                new ValidationError("publicmethod", "Public_Method"),
                new ValidationError("internalmethod", "Internal_Method"),
                new ValidationError("protectedmethod", "Protected_Method"),
                new ValidationError("privatemethod", "Private_Method")
            },
                errors.Errors);
        }
Exemple #8
0
        public override async Task <ActionResult> Post([FromBody] COAViewModel viewModel)
        {
            try
            {
                VerifyUser();
                ValidateService.Validate(viewModel);

                COAModel model = Mapper.Map <COAModel>(viewModel);
                Transfrom(model);
                await Service.CreateAsync(model);

                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE)
                    .Ok();
                return(Created(String.Concat(Request.Path, "/", 0), Result));
            }
            catch (ServiceValidationException e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE)
                    .Fail(e);
                return(BadRequest(Result));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
        private void btn_Modity_Click(object sender, EventArgs e)
        {
            string _price = txt_Price.Text.Trim();

            if (!ValidateService.IsNumber(_price))  // 项目 Common 的 ValidateService 类
            {
                MessageBox.Show("价格格式错误!");
                txt_Price.Focus();
                return;
            }
            //if (_model.Exists(_name))
            //{
            //    MessageBox.Show("该名称已存在!");
            //    txt_Price.Focus();
            //    return;
            //}
            _model.Price = decimal.Parse(_price);
            bool re = _model.Update();

            if (re)
            {
                MessageBox.Show("修改成功!");
                this._isTrue = true;
                this.Close();
            }
            else
            {
                MessageBox.Show("修改失败!");
            }
        }
        private void btn_Add_Click(object sender, EventArgs e)
        {
            Norm   user  = new Norm();
            string _name = txt_Name.Text.Trim();

            if (!ValidateService.IsNumber(_name))   // 项目 Common 的 ValidateService 类
            {
                MessageBox.Show("必须为数字!");
                txt_Name.Focus();
                return;
            }
            if (user.Exists(_name))
            {
                MessageBox.Show("该规格已存在!");
                txt_Name.Focus();
                return;
            }

            user.NormName = _name;
            int re = user.Add();

            if (re > 0)
            {
                MessageBox.Show("添加成功!");
                txt_Name.Text = "";
                txt_Name.Focus();
                BindDGV();
            }
            else
            {
                MessageBox.Show("添加失败!");
            }
        }
        /// <summary>
        /// 注册表单校验
        /// </summary>
        /// <param name="registerInfo"></param>
        /// <returns></returns>
        public bool RegisterCheck(RegisterDto registerInfo, out string errMsg)
        {
            errMsg = string.Empty;
            if (!ValidateService.CheckNumberExist(registerInfo.DirectNumber))
            {
                errMsg = "推荐编号不存在!";
                return(false);
            }

            if (!ValidateService.CheckIDCard(registerInfo.IdentityId))
            {
                errMsg = "身份证号码错误!";
                return(false);
            }

            if (!ValidateService.CheckAge(registerInfo.IdentityId, !registerInfo.InsuranceType.Equals(InsuranceType.None), out errMsg))
            {
                return(false);
            }

            if (ValidateService.IsIdentiyIdRegistOver7(registerInfo.IdentityId, registerInfo.Level == LevelInt.SpecialVip))
            {
                errMsg = "一个身份证最多可以注册7个会员!";
                return(false);
            }

            if (ValidateService.IsMobilePhoneRegistOver7(registerInfo.MobilePhone, registerInfo.Level == LevelInt.SpecialVip))
            {
                errMsg = "一个身份证最多可以注册7个会员!";
                return(false);
            }

            return(true);
        }
Exemple #12
0
        protected override ICacheGroup ParserLocalGroup(XmlNode node)
        {
            if (ValidateService.IsNull(node))
            {
                throw new ArgumentNullException("node");
            }
            object oName;
            object oSize;

            if (!XmlFileParserService.TryGetAttributeValue(node, "Name", out oName))
            {
                if (null != _logger)
                {
                    _logger.Error("no the name of cache group.");
                }
                return(null);
            }
            ICacheGroup group = new CacheGroup();

            group.Name = oName.ToString();
            if (!XmlFileParserService.TryGetAttributeValue(node, "Size", out oSize))
            {
                if (null != _logger)
                {
                    _logger.Error("no the servers of cache group.");
                }
                return(null);
            }
            group.Size = int.Parse(oSize.ToString());
            return(group);
        }
 public BasePost(TFacade facade, string apiVersion, ValidateService validateService, string requestPath)
 {
     this.facade          = facade;
     this.apiVersion      = apiVersion;
     this.validateService = validateService;
     this.requestPath     = requestPath;
 }
Exemple #14
0
        private void button2_Click(object sender, EventArgs e)
        {
            string txt = richTextBox1.Text.Trim().Replace("\n", "");

            if (!ValidateService.IsAllNumber(txt))
            {
                MessageBox.Show("包含非数字字符,请认真核对!");
                return;
            }
            //else if(txt))
            //{
            //    MessageBox.Show("内容为空!");
            //    return;
            //}
            else
            {
                int x = txt.Length / 14;
                for (int i = 0; i < x; i++)
                {
                    string s = txt.Substring(0, 14);
                    txt = txt.Remove(0, 14);
                    batchList.Add(s);
                }
                this.Close();
            }
        }
Exemple #15
0
        public async Task <IActionResult> Post([FromBody] DeliveryOrderViewModel viewModel)
        {
            identityService.Token    = Request.Headers["Authorization"].First().Replace("Bearer ", "");
            identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

            ValidateService validateService = (ValidateService)facade.serviceProvider.GetService(typeof(ValidateService));

            try
            {
                validateService.Validate(viewModel);

                DeliveryOrder model = mapper.Map <DeliveryOrder>(viewModel);

                int result = await facade.Create(model, identityService.Username);

                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE)
                    .Ok();
                return(Created(String.Concat(Request.Path, "/", 0), Result));
            }
            catch (ServiceValidationExeption e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE)
                    .Fail(e);
                return(BadRequest(Result));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
Exemple #16
0
        public ActionResult Register(RegisterViewModel form)
        {
            if (Request.Form.Count > 0)
            {
                ValidateService _dvs = new ValidateService();

                string _guid = Guid.NewGuid().ToString("N");

                User _usertable = new User();

                string _Pas = form.UserPassword;

                _usertable.UserName         = form.UserName;
                _usertable.UserPassword     = _dvs.SHAcode(_Pas, _guid);
                _usertable.Email            = form.Email;
                _usertable.Phone            = form.Phone;
                _usertable.GUID             = _guid;
                _usertable.RegistrationDate = DateTime.Now;
                _usertable.RegionID         = form.RegionID;
                _usertable.Enabled          = true;
                _usertable.Address          = form.Address;
                _usertable.Gender           = form.Gender;

                db.Users.Add(_usertable);
                db.SaveChanges();

                return(RedirectToAction("Login", "MyLogin", new { area = "SK_AREA" }));
            }
            return(View());
        }
        public async Task <ActionResult> Post([FromBody] PurchasingDocumentAcceptanceViewModel viewModel)
        {
            this.identityService.Token    = Request.Headers["Authorization"].First().Replace("Bearer ", "");
            this.identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

            ValidateService validateService = (ValidateService)purchasingDocumentExpeditionFacade.serviceProvider.GetService(typeof(ValidateService));

            try
            {
                validateService.Validate(viewModel);

                await purchasingDocumentExpeditionFacade.PurchasingDocumentAcceptance(viewModel, this.identityService.Username);

                return(NoContent());
            }
            catch (ServiceValidationExeption e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE)
                    .Fail(e);
                return(BadRequest(Result));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
 public SongCreate()
 {
     this.InitializeComponent();
     this.songService         = new SongService();
     this.fileService         = new FileService();
     this.validateService     = new ValidateService();
     this.NavigationCacheMode = NavigationCacheMode.Enabled;
 }
Exemple #19
0
 public WeeklyplanFacade(IServiceProvider serviceProvider, MasterplanDbContext dbContext)
 {
     this.DbContext       = dbContext;
     this.DbSet           = this.DbContext.Set <WeeklyPlan>();
     this.IdentityService = serviceProvider.GetService <IdentityService>();
     this.WeeklyPlanLogic = serviceProvider.GetService <WeeklyPlanLogic>();
     this.ValidateService = serviceProvider.GetService <ValidateService>();
 }
 public Login()
 {
     this.InitializeComponent();
     this.fileService         = new FileService();
     this.memberService       = new MemberService();
     this.validateService     = new ValidateService();
     this.NavigationCacheMode = NavigationCacheMode.Enabled;
 }
Exemple #21
0
 public BaseController(IMapper mapper, IdentityService identityService, ValidateService validateService, TFacade facade, string apiVersion)
 {
     this.Mapper          = mapper;
     this.IdentityService = identityService;
     this.ValidateService = validateService;
     this.Facade          = facade;
     this.ApiVersion      = apiVersion;
 }
Exemple #22
0
        public void Should_Exception_ValidationVM()
        {
            var repoMock                = new Mock <IDyeingPrintingAreaInputRepository>();
            var movementRepoMock        = new Mock <IDyeingPrintingAreaMovementRepository>();
            var summaryRepoMock         = new Mock <IDyeingPrintingAreaSummaryRepository>();
            var outputRepoMock          = new Mock <IDyeingPrintingAreaOutputRepository>();
            var productionOrderRepoMock = new Mock <IDyeingPrintingAreaInputProductionOrderRepository>();
            var outputSPPRepoMock       = new Mock <IDyeingPrintingAreaOutputProductionOrderRepository>();


            var serviceProvider = GetServiceProvider(repoMock.Object, movementRepoMock.Object, summaryRepoMock.Object, outputRepoMock.Object, productionOrderRepoMock.Object, outputSPPRepoMock.Object).Object;
            var service         = GetService(serviceProvider);

            var vm = new InputAvalTransformationViewModel();
            var validateService = new ValidateService(serviceProvider);

            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Date         = DateTimeOffset.UtcNow.AddDays(-1);
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Date         = DateTimeOffset.UtcNow.AddDays(3);
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Date = DateTimeOffset.UtcNow.AddHours(-2);

            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Date         = DateTimeOffset.UtcNow.AddHours(2);
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Id           = 1;
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Id = 0;
            vm.AvalTransformationProductionOrders.Add(new InputAvalTransformationProductionOrderViewModel()
            {
                IsSave = false
            });
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.AvalTransformationProductionOrders.Add(new InputAvalTransformationProductionOrderViewModel()
            {
                IsSave = true
            });
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Id           = 1;
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));
        }
Exemple #23
0
        public void Insert(string key, object value, int seconds)
        {
            if (ValidateService.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key", string.Format("key is null or empty in the {0} cahced.", _name));
            }
            if (0 >= seconds)
            {
                throw new ArgumentNullException("seconds", string.Format("seconds is less or eq 0 in the {0} cahced.", _name));
            }

            lock (_locker)
            {
                if (_ht.ContainsKey(key))
                {
                    WeakReference objWeak = (WeakReference)_ht[key];
                    if (null == objWeak || !objWeak.IsAlive || null == objWeak.Target)
                    {
                        IAlbianCachedObject obj = new AlbianCachedObject
                        {
                            Timespan   = seconds,
                            Key        = key,
                            Value      = value,
                            CreateTime = DateTime.Now
                        };
                        _ht[key] = WeakReferenceObject.CreateWeakReferenceObject(obj);
                    }
                    else
                    {
                        IAlbianCachedObject objOld = (IAlbianCachedObject)objWeak.Target;
                        if (((int)DateTime.Now.Subtract(objOld.CreateTime).TotalSeconds) <= objOld.Timespan)
                        {
                            throw new AlbianCachedException(string.Format("the {0} cached is exist in the {1} cached.", key,
                                                                          _name));
                        }
                        IAlbianCachedObject obj = new AlbianCachedObject
                        {
                            Timespan   = seconds,
                            Key        = key,
                            Value      = value,
                            CreateTime = DateTime.Now
                        };
                        _ht[key] = WeakReferenceObject.CreateWeakReferenceObject(obj);
                    }
                }
                else
                {
                    IAlbianCachedObject obj = new AlbianCachedObject
                    {
                        Timespan   = seconds,
                        Key        = key,
                        Value      = value,
                        CreateTime = DateTime.Now
                    };
                    _ht.Add(key, WeakReferenceObject.CreateWeakReferenceObject(obj));
                }
            }
        }
Exemple #24
0
        static void Main(string[] args)
        {
            ILoggerService             fileLogger                = new FileLoggerService();
            ILoggerService             databaseLogger            = new DatabaseLoggerService();
            IPersonVerificationService personVerificationService = new ValidateService();
            ICustomerService           gameManager               = new GameManager(new List <ILoggerService> {
                databaseLogger
            });
            ICustomerService customerManager = new CustomerManager(new List <ILoggerService> {
                databaseLogger, fileLogger
            }, new
                                                                   List <IPersonVerificationService> {
                personVerificationService
            });
            IDiscountService summerSale = new DiscountSummerManager();

            IEntity game1 = new Game()
            {
                Name = "Game-1", Price = 100, StockQuantity = 5, Id = 1
            };
            IEntity game2 = new Game()
            {
                Name = "Game-2", Price = 200, StockQuantity = 7, Id = 2
            };
            IEntity game3 = new Game()
            {
                Name = "Game-3", Price = 300, StockQuantity = 12, Id = 3
            };

            Customer customer1 = new Customer()
            {
                Name = "Atakan", Lastname = "Çiğdem", DateOfBirth = 2001, NationalityId = "1111111", Id = 1
            };
            Customer customer2 = new Customer()
            {
                Name = "Furkan", Lastname = "Çiğdem", DateOfBirth = 1991, NationalityId = "2222222", Id = 2
            };
            Customer customer3 = new Customer()
            {
                Name = "Melek", Lastname = "Gül", DateOfBirth = 1974, NationalityId = "3333333", Id = 3
            };

            customerManager.Add(customer1);
            customerManager.Add(customer2);
            customerManager.Add(customer3);

            gameManager.Add(game1);
            gameManager.Add(game2);
            gameManager.Add(game3);

            IGameTradeService epic = new EpicGamesManager(new List <IDiscountService> {
                summerSale
            });

            epic.BuyGame(game1, customer1);
            epic.BuyGame(game2, customer2);
            epic.BuyGame(game3, customer3);
        }
Exemple #25
0
        public void Should_Exception_ValidationVM()
        {
            var repoMock         = new Mock <IDyeingPrintingAreaInputRepository>();
            var movementRepoMock = new Mock <IDyeingPrintingAreaMovementRepository>();
            var summaryRepoMock  = new Mock <IDyeingPrintingAreaSummaryRepository>();
            var sppRepoMock      = new Mock <IDyeingPrintingAreaInputProductionOrderRepository>();


            var serviceProvider = GetServiceProvider(repoMock.Object, movementRepoMock.Object, summaryRepoMock.Object, sppRepoMock.Object).Object;
            var service         = GetService(serviceProvider);

            var vm = new InputInspectionMaterialViewModel();
            var validateService = new ValidateService(serviceProvider);

            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Date = DateTimeOffset.UtcNow.AddDays(-1);
            vm.InspectionMaterialProductionOrders = new List <InputInspectionMaterialProductionOrderViewModel>()
            {
                new InputInspectionMaterialProductionOrderViewModel()
            };
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Date = DateTimeOffset.UtcNow.AddDays(3);
            vm.InspectionMaterialProductionOrders = new List <InputInspectionMaterialProductionOrderViewModel>()
            {
                new InputInspectionMaterialProductionOrderViewModel()
            };
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Date = DateTimeOffset.UtcNow.AddHours(-2);
            vm.InspectionMaterialProductionOrders = new List <InputInspectionMaterialProductionOrderViewModel>()
            {
                new InputInspectionMaterialProductionOrderViewModel()
                {
                    ProductionOrder = new ProductionOrder()
                }
            };
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Date = DateTimeOffset.UtcNow.AddHours(2);
            vm.InspectionMaterialProductionOrders = new List <InputInspectionMaterialProductionOrderViewModel>()
            {
                new InputInspectionMaterialProductionOrderViewModel()
                {
                    ProductionOrder = new ProductionOrder()
                }
            };
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));

            vm.Id           = 1;
            validateService = new ValidateService(serviceProvider);
            Assert.ThrowsAny <ServiceValidationException>(() => validateService.Validate(vm));
        }
        public void Validate_Success()
        {
            Mock <IServiceProvider>   serviceProvider = new Mock <IServiceProvider>();
            ColorReceiptItemViewModel viewModel       = new ColorReceiptItemViewModel();

            ValidateService service = new ValidateService(serviceProvider.Object);

            service.Validate(viewModel);
        }
        public void Validate_Throws_ServiceValidationExeption()
        {
            Mock <IServiceProvider> serviceProvider = new Mock <IServiceProvider>();
            BuyerBrandViewModel     viewModel       = new BuyerBrandViewModel();

            ValidateService service = new ValidateService(serviceProvider.Object);

            Assert.Throws <ServiceValidationException>(() => service.Validate(viewModel));
        }
        public void Validate_Throws_ServiceValidationExeption()
        {
            Mock <IServiceProvider>    serviceProvider = new Mock <IServiceProvider>();
            StockTransferNoteViewModel viewModel       = new StockTransferNoteViewModel();

            ValidateService service = new ValidateService(serviceProvider.Object);

            Assert.Throws <ServiceValidationExeption>(() => service.Validate(viewModel));
        }
Exemple #29
0
        public void Initialize()
        {
            #region portfolio inizialize
            Portfolio portfolio1 = new Portfolio
            {
                Id             = 1,
                Name           = "Strategic Investment Open Portfolio",
                Notes          = "A portfolio is a grouping of financial assets such as stocks,",
                DisplayIndex   = 1,
                LastUpdateDate = new DateTime(2017, 4, 28),
                Visibility     = false,
                Quantity       = 2,
                PercentWins    = 73.23m,
                BiggestWinner  = 234.32m,
                BiggestLoser   = 12.65m,
                AvgGain        = 186.65m,
                MonthAvgGain   = 99.436m,
                PortfolioValue = 1532.42m,
                Positions      = new List <Position> {
                    position1, position2
                }
            };

            Portfolio portfolio2 = new Portfolio
            {
                Id             = 2,
                Name           = "Strategic Investment Income Portfolio",
                Notes          = "A portfolio is a grouping of financial assets such as stocks,",
                DisplayIndex   = 2,
                LastUpdateDate = new DateTime(2017, 3, 12),
                Visibility     = true,
                Quantity       = 3,
                PercentWins    = 93.23m,
                BiggestWinner  = 534.32m,
                BiggestLoser   = 123.46m,
                AvgGain        = 316.65m,
                MonthAvgGain   = 341.436m,
                PortfolioValue = 5532.42m,
                Positions      = null
            };
            #endregion
            ListPositions = new List <Position> {
                position1, position2, position3
            };
            ListPortfolios = new List <Portfolio> {
                portfolio1, portfolio2
            };
            UnitOfWork               = new Mock <IUnitOfWork>();
            positionRepository       = new Mock <IPositionRepository>();
            portfolioRepository      = new Mock <IPortfolioRepository>();
            symbolDividendRepository = new Mock <ISymbolDividendRepository>();
            validateService          = new ValidateService();
            tradeSybolService        = new Mock <ITradeSybolService>();
            calculationService       = new CalculationService();
            map = new AutoMapperConfiguration().Configure().CreateMapper();
        }
Exemple #30
0
        public async Task <ActionResult> Post([FromBody] FPReturnInvToPurchasingViewModel viewModel)
        {
            this.identityService.Token    = Request.Headers["Authorization"].First().Replace("Bearer ", "");
            this.identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value;

            ValidateService validateService = (ValidateService)fpReturnInvToPurchasingFacade.serviceProvider.GetService(typeof(ValidateService));

            return(await new BasePost <FPReturnInvToPurchasing, FPReturnInvToPurchasingViewModel, FPReturnInvToPurchasingFacade>(fpReturnInvToPurchasingFacade, ApiVersion, validateService, Request.Path)
                   .Post(viewModel));
        }