Ejemplo n.º 1
0
        public TreeItem AddTreeItem()
        {
            var treeItem = new TreeItem();

            treeItem.Level = 1;
            _treeDataProvider.Add(treeItem);
            return(_treeDataProvider.Get(treeItem.Id));
        }
Ejemplo n.º 2
0
        private void EntityTest <TEntity>(
            TEntity entity,
            DataFilter <TEntity> filter,
            Func <TEntity, DataFilter <TEntity> > getItemFilter,
            Action <TEntity> updateEntity,
            Func <TEntity, bool> testUpdate)
            where TEntity : Entity, new()
        {
            List <TEntity> list = provider.GetList <TEntity>(filter);

            Assert.AreNotEqual(0, list.Count);

            provider.Add(entity);

            var itemFilter = getItemFilter(entity);

            entity = provider.GetItem <TEntity>(itemFilter);

            Assert.IsNotNull(entity);

            updateEntity(entity);

            provider.Update(entity);

            entity = provider.GetItem <TEntity>(itemFilter);

            Assert.IsTrue(testUpdate(entity));

            provider.Delete(entity);

            entity = provider.GetItem <TEntity>(itemFilter);

            Assert.IsNull(entity);
        }
Ejemplo n.º 3
0
        public async Task <AddDrinkResult> Handle(AddDrinkCommand request, CancellationToken cancellationToken)
        {
            Entities.Models.Drink entity = _mapper.Map <Entities.Models.Drink>(request.DrinkDto);

            _provider.Add(entity);
            await _provider.SaveAsync();

            return(new AddDrinkResult(entity));
        }
Ejemplo n.º 4
0
        public void AddCategory(int id, string name, string description)
        {
            Category tmpCategory = new Category()
            {
                Id          = (id++),
                Name        = name,
                Description = description
            };

            _categoryDataProvider.Add(tmpCategory);
        }
        public void AddOrderStatus(int lastID, string name)
        {
            //TODO: modify AddProduct method and ModifyProduct make one method remove code duplication
            OrderState tmpProduct = new OrderState()
            {
                ID   = (lastID++),
                Name = name
            };

            _orderStateDataProvider.Add(tmpProduct);
        }
Ejemplo n.º 6
0
        public async Task <AddCoinResult> Handle(
            AddCoinCommand request,
            CancellationToken cancellationToken)
        {
            var coinEntity = _mapper.Map <Entities.Models.Coins>(request.CoinDto);

            _provider.Add(coinEntity);
            await _provider.SaveAsync();

            return(new AddCoinResult(coinEntity));
        }
Ejemplo n.º 7
0
        public void AddBasket(int lastID, DateTime?date)
        {
            //TODO: modify AddProduct method and ModifyProduct make one method remove code duplication
            Basket tmpProduct = new Basket()
            {
                ID           = (lastID++),
                CreationDate = date
            };

            _basketDataProvider.Add(tmpProduct);
        }
Ejemplo n.º 8
0
        public async Task <AddCardResult> Handle(
            AddCardCommand request,
            CancellationToken cancellationToken)
        {
            var cardEntity = _mapper.Map <Entities.Models.BusinessCard>(request.CardDto);

            _provider.Add(cardEntity);
            await _provider.SaveAsync();

            return(new AddCardResult(_mapper.Map <BusinessCardDto>(cardEntity)));
        }
Ejemplo n.º 9
0
        protected async Task <int> Add <T> ([NotNull] T e)
            where T : class, new()
        {
            if (null == e)
            {
                throw new NullArgumentException(nameof(e));
            }

            var id = Provider.Add(e);

            return(await Task.FromResult(id));
        }
Ejemplo n.º 10
0
        public bool Generate(string pattern, string domain, int count)
        {
            foreach (var user in _template.Generate(pattern, domain, count))
            {
                if (_users.Add(user) == null)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 11
0
 public Info Add(Info info)
 {
     if (info == null) return info;
     ModelIdHelper.GenerateId<Info>(info);
     if (Exists(info))
     {
         throw new Exception(string.Format("列表‘{0}’添加对象时,发现对象已存在", typeof(Info).Name));
     }
     Info rs = Provider.Add<Info>(info);
     Build();
     CacheKey.ReBuildCache();
     return rs;
 }
        public void AddOrderStatus(int lastID, DateTime?courierPassingDate,
                                   DateTime?deliveryDate, int orderStateID)
        {
            //TODO: modify AddProduct method and ModifyProduct make one method remove code duplication
            OrderStatus tmpProduct = new OrderStatus()
            {
                ID = (lastID++),
                CourierPassingDate = courierPassingDate,
                DeliveryDate       = deliveryDate,
                OrderStateID       = orderStateID
            };

            _orderStatusDataProvider.Add(tmpProduct);
        }
Ejemplo n.º 13
0
        public async Task <SmartUrlEntity> CreateSmartUrl(string url)
        {
            SmartUrlEntity objSmartUrlEntity = null;
            string         urlHash           = CalculateMD5Hash(url);
            string         uniqueUrlKey      = string.Empty;

            objSmartUrlEntity = await _dataProvider.GetSmartUrlByHash(urlHash);

            if (objSmartUrlEntity != null)
            {
                objSmartUrlEntity.ShortUrl  = new Uri(string.Format(_managedConfig.ApplicationPath, uniqueUrlKey)).ToString();
                objSmartUrlEntity.IsSuccess = true;
                return(objSmartUrlEntity);
            }

            uniqueUrlKey = GetUniqueKeyFromUrl(url);
            if (!string.IsNullOrEmpty(uniqueUrlKey))
            {
                objSmartUrlEntity = await _dataProvider.GetSmartUrlByKey(uniqueUrlKey);

                if (objSmartUrlEntity != null)
                {
                    objSmartUrlEntity.ShortUrl   = new Uri(string.Format(_managedConfig.ApplicationPath, uniqueUrlKey)).ToString();
                    objSmartUrlEntity.IsSuccess  = true;
                    objSmartUrlEntity.IsShortUrl = true;
                    return(objSmartUrlEntity);
                }
            }

            uniqueUrlKey = string.Empty;
            uniqueUrlKey = GenerateUniqueUrlKey().Result;

            if (!string.IsNullOrEmpty(uniqueUrlKey))
            {
                objSmartUrlEntity          = new SmartUrlEntity();
                objSmartUrlEntity.UrlKey   = uniqueUrlKey;
                objSmartUrlEntity.Url      = url;
                objSmartUrlEntity.UrlHash  = urlHash;
                objSmartUrlEntity.ShortUrl = new Uri(string.Format(_managedConfig.ApplicationPath, uniqueUrlKey)).ToString();

                await _dataProvider.Add(objSmartUrlEntity);

                objSmartUrlEntity.IsSuccess = true;
                return(objSmartUrlEntity);
            }

            objSmartUrlEntity           = new SmartUrlEntity();
            objSmartUrlEntity.IsSuccess = false;
            return(objSmartUrlEntity);
        }
Ejemplo n.º 14
0
        public void Add <TEntity>(TEntity entity) where TEntity : Entity
        {
            var repository = GetRepository <TEntity>();

            if (repository != null)
            {
                repository.Add(entity);
            }
            else
            {
                dataProvider.Add(entity);
            }

            SaveRepositories();
        }
Ejemplo n.º 15
0
        public void AddUserOrder(int userOrderID, int orderBasketID,
                                 int orderStatusID, int productID,
                                 string userName)
        {
            //TODO: modify AddProduct method and ModifyProduct make one method remove code duplication
            UserOrder tmpProduct = new UserOrder()
            {
                ID            = (userOrderID++),
                OrderBasketID = orderBasketID,
                OrderStatusID = orderStatusID,
                ProductID     = productID,
                UserName      = userName
            };

            _userOrderDataProvider.Add(tmpProduct);
        }
Ejemplo n.º 16
0
 public virtual TData this[TKey id]
 {
     get
     {
         if (dataRepository.HasKey(id))
         {
             return(dataRepository.GetById(id));
         }
         else
         {
             var newData = new TData();
             dataRepository.Add(id, newData);
             return(newData);
         }
     }
 }
Ejemplo n.º 17
0
        public async Task <AddProfileResult> Handle(
            AddProfileCommand request,
            CancellationToken cancellationToken)
        {
            var profileEntity = _mapper.Map <Entities.Models.Profile>(request.ProfileDto);

            var salt = SaltHelper.Generate();

            profileEntity.Secret = new Entities.Models.Secret
            {
                Salt = salt,
                Hash = SaltHelper.Hash(request.Password, salt)
            };

            _provider.Add(profileEntity);
            await _provider.SaveAsync();

            return(new AddProfileResult(_mapper.Map <ProfileDto>(profileEntity)));
        }
Ejemplo n.º 18
0
        public void AddProduct(int productId, int categoryId,
                               string name, string description,
                               string imageName, string thumbnailName,
                               double price, DateTime?placementDate)
        {
            //TODO: modify AddProduct method and ModifyProduct make one method remove code duplication
            Product tmpProduct = new Product()
            {
                ProductId     = (productId++),
                CategoryId    = categoryId,
                Name          = name,
                Description   = description,
                ImageName     = imageName,
                ThumbnailName = thumbnailName,
                Price         = price,
                PlacementDate = placementDate
            };

            _productDataProvider.Add(tmpProduct);
        }
Ejemplo n.º 19
0
        private void Configure(AttributeSet attributes, IDataProvider dataProvider)
        {
            if (dataProvider == null)
            {
                return;
            }

            if (attributes.IsDataProvider != null)
            {
                if (!string.IsNullOrEmpty(attributes.IsDataProvider.Name))
                {
                    dataProvider.Name = attributes.IsDataProvider.Name;
                }

                if (attributes.IsDataProvider.Type != null)
                {
                    dataProvider.Add(
                        attributes.IsDataProvider.Type,
                        attributes.IsDataProvider.Scope);
                }
            }
        }
Ejemplo n.º 20
0
        public int Add(OwnerAddRequest model)
        {
            //Pass in OwnerAddRequestModel and a userId to record in db. TODO
            string procName = "[dbo].[Owner_Insert]";
            int id = 0;
            var hashedPwd = BCrypt.Net.BCrypt.HashPassword(model.Password);
            model.Password = hashedPwd;

            _data.Add(procName,
                paramMapper: delegate (SqlParameterCollection col)
                {
                    AddParameters(model, col);
                    var idOut = new SqlParameter("@Id", SqlDbType.Int);
                    idOut.Direction = ParameterDirection.Output;
                    col.Add(idOut);
                },
                returnParams: delegate (SqlParameterCollection returnColl)
                {
                    var oId = returnColl["@Id"].Value;
                    Int32.TryParse(oId.ToString(), out id);
                });

            return id;
        }
Ejemplo n.º 21
0
 public void Add(PolicyModel model)
 {
     _dataProvider.Add(model);
 }
Ejemplo n.º 22
0
 public void Add(RiskModel model)
 {
     _dataProvider.Add(model);
 }
Ejemplo n.º 23
0
 public void Add(TodoItem item)
 {
     item.Id = _itemCount++;
     _provider.Add(item);
 }
Ejemplo n.º 24
0
 private void AddCandidate(ChatMember newChatMember)
 {
     _dbProvider.Add(newChatMember);
 }
Ejemplo n.º 25
0
 public virtual void Add(T item)
 {
     innerRepository.Add(item);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// 新增角色
 /// </summary>
 /// <param name="t">要新增的角色</param>
 /// <returns>成功返回非0值,不成功返回0</returns>
 public int Add(AppRole t)
 {
     return(mProvider.Add(t));
 }
Ejemplo n.º 27
0
 public virtual void Add(T item)
 {
     innerRepository.Add(item);
     ClearObjectCache(item);
 }