Beispiel #1
0
        public TreeItem AddTreeItem()
        {
            var treeItem = new TreeItem();

            treeItem.Level = 1;
            _treeDataProvider.Add(treeItem);
            return(_treeDataProvider.Get(treeItem.Id));
        }
        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);
        }
        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));
        }
Beispiel #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);
        }
        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));
        }
Beispiel #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);
        }
Beispiel #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)));
        }
Beispiel #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));
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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();
        }
        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);
        }
Beispiel #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);
         }
     }
 }
Beispiel #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)));
        }
        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);
        }
Beispiel #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);
                }
            }
        }
Beispiel #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;
        }
Beispiel #21
0
 public void Add(PolicyModel model)
 {
     _dataProvider.Add(model);
 }
Beispiel #22
0
 public void Add(RiskModel model)
 {
     _dataProvider.Add(model);
 }
 public void Add(TodoItem item)
 {
     item.Id = _itemCount++;
     _provider.Add(item);
 }
Beispiel #24
0
 private void AddCandidate(ChatMember newChatMember)
 {
     _dbProvider.Add(newChatMember);
 }
 public virtual void Add(T item)
 {
     innerRepository.Add(item);
 }
 /// <summary>
 /// 新增角色
 /// </summary>
 /// <param name="t">要新增的角色</param>
 /// <returns>成功返回非0值,不成功返回0</returns>
 public int Add(AppRole t)
 {
     return(mProvider.Add(t));
 }
Beispiel #27
0
 public virtual void Add(T item)
 {
     innerRepository.Add(item);
     ClearObjectCache(item);
 }