示例#1
0
        public ProductDirectionInfo GetProductDirection(SecurityInfo securityInfo, long id)
        {
            ProductDirectionInfo productDirectionInfo = null;

            if (ValidatePassword(securityInfo))
            {
                IShapingProductDirections shaping = new ShapingProductDirections(dataService, optionService);
                productDirectionInfo = shaping.GetItem(id);
            }

            return(productDirectionInfo);
        }
示例#2
0
        private void AddProductDirectionDataRow(DataTable directoriesTable, ProductDirectionInfo item)
        {
            DataRow row = directoriesTable.NewRow();

            row.SetField("Id", item.Id);
            row.SetField("Direction", item.Direction);
            row.SetField("Directory_Id", item.DirectoryId);
            row.SetField("DateOfCreation", item.DateOfCreation);
            row.SetField("LastUpdated", item.LastUpdated);
            row.SetField("ForceUpdated", item.ForceUpdated);

            directoriesTable.Rows.Add(row);
        }
示例#3
0
        public static ProductDirectionEntity Assemble(ProductDirectionInfo productDirectionInfo, DirectoryEntity directory)
        {
            ProductDirectionEntity productDirection = new ProductDirectionEntity
            {
                Id             = productDirectionInfo.Id,
                Direction      = Convert(productDirectionInfo.Direction),
                LastUpdated    = productDirectionInfo.LastUpdated,
                ForceUpdated   = productDirectionInfo.ForceUpdated,
                DateOfCreation = productDirectionInfo.DateOfCreation,
                Directory      = directory
            };

            return(productDirection);
        }
示例#4
0
        private ProductDirectionInfo Assemble(ProductDirectionEntity item)
        {
            ProductDirectionInfo result = null;

            if (item != null)
            {
                result = new ProductDirectionInfo
                {
                    Id             = item.Id,
                    Direction      = item.Direction,
                    DirectoryId    = item.Directory.Id,
                    DateOfCreation = item.DateOfCreation,
                    ForceUpdated   = item.ForceUpdated,
                    LastUpdated    = item.LastUpdated
                };
            }

            return(result);
        }
示例#5
0
        private List <ProductDirectionInfo> GetProductDirectionInfos(string login)
        {
            //List<long> productDirectionIds = dataService.Select<SendItemsEntity>()
            //    .Include(x => x.Contragent)
            //    .Where(x => x.Contragent.Login == login)
            //    .Where(x => x.EntityName == EntityName.ProductDirectionEntity)
            //    .Take(optionService.CountSendItems)
            //    .Select(x => x.EntityId)
            //    .ToList();

            //List<ProductDirectionInfo> result =
            //    dataService.Select<ProductDirectionEntity>()
            //        .Where(x => productDirectionIds.Contains(x.Id))
            //        .Select(Assemble)
            //        .ToList();

            //return result;

            var loginParametr = new SqlParameter();

            loginParametr.ParameterName = "@login";
            loginParametr.SqlDbType     = SqlDbType.NVarChar;
            loginParametr.Value         = login;
            loginParametr.Direction     = ParameterDirection.Input;

            var countToUpdateParametr = new SqlParameter();

            countToUpdateParametr.ParameterName = "@countToUpdate";
            countToUpdateParametr.SqlDbType     = SqlDbType.BigInt;
            countToUpdateParametr.Direction     = ParameterDirection.Input;
            countToUpdateParametr.Value         = optionService.CountSendItems;

            List <DbProductDirectionInfo> productDirectionInfos = null;

            try
            {
                productDirectionInfos = dataService.DataBaseContext.Database
                                        .SqlQuery <DbProductDirectionInfo>("GetProductDirectionItems @login, @countToUpdate",
                                                                           loginParametr, countToUpdateParametr).ToList();
            }
            catch (Exception e)
            {
                ; //TODO Записать в LOG-file ошибку
            }

            var result = new List <ProductDirectionInfo>();

            if (productDirectionInfos != null && productDirectionInfos.Any())
            {
                productDirectionInfos.ForEach(
                    x =>
                {
                    ProductDirectionInfo productDirectionInfo = Assemble(x);

                    if (productDirectionInfo != null)
                    {
                        result.Add(productDirectionInfo);
                    }
                });
            }

            return(result);
        }