public ProductUnit Get(Guid code)
 {
     try
     {
         return(_commonDb.Query <ProductUnit>("select * from units where code = @code", new { code }).First());
     }
     catch (Exception e)
     {
         throw new ProductUnitOperationException($"Unit with code {code} get error!", e);
     }
 }
Ejemplo n.º 2
0
 public IEnumerable <ProductCategory> Get()
 {
     try
     {
         return(_commonDb.Query <ProductCategory>("select * from categories"));
     }
     catch (Exception e)
     {
         throw new CategoryOperationException($"Categories get error!", e);
     }
 }
 public ProductType Get(Guid code)
 {
     try
     {
         return(_commonDb.Query <ProductType>("select * from types where code = @code", new { code }).First());
     }
     catch (Exception e)
     {
         throw new ProductTypeOperationException($"Type with code {code} get error!", e);
     }
 }
Ejemplo n.º 4
0
        public IEnumerable <BinaryDataModel> GetResizeTo70Images(params string[] extensions)
        {
            var imagesInfo = GetImagesInfo(extensions);
            var dataModels = new List <BinaryDataModel>();

            foreach (var fileInfo in imagesInfo)
            {
                var bytes        = _commonDb.Query <byte[]>("select data from FileSystem where id = @id", new { id = fileInfo.Id }).First();
                var resizeStream = ResizeTo70(bytes);
                dataModels.Add(new BinaryDataModel()
                {
                    Id = fileInfo.Id, FileName = fileInfo.FileName, Stream = resizeStream
                });
            }

            return(dataModels);
        }
Ejemplo n.º 5
0
        public void Down(string name)
        {
            var migrationModels =
                _commonDb.Query <MigrationModel>(
                    "select * from __Migrations where date >= (select date from __Migrations where name = @name)", new { name });

            var migrations = migrationModels.Select(mm =>
            {
                var migration = _migrationCollection.First(m => m.GetType().Name == mm.Name);
                return(new MigrationInfo
                {
                    Attribute = migration.GetType().GetCustomAttribute <MigrationAttribute>(),
                    Name = mm.Name,
                    Migration = migration,
                    CreatedDate = mm.Date
                });
            }).OrderByDescending(mm => mm.CreatedDate);

            foreach (var migrationInfo in migrations)
            {
                Down(migrationInfo);
            }
        }
Ejemplo n.º 6
0
 internal static FileInfo GetFileInfo(Guid id, ICommonDb commonDb)
 {
     return(commonDb.Query <FileInfo>("select id, filename, hash from FileSystem where id = @id", new { id }).First());
 }
Ejemplo n.º 7
0
 internal static FileInfo GetFileInfo(string hash, ICommonDb commonDb)
 {
     return(commonDb.Query <FileInfo>("select id, filename, hash from FileSystem where hash = @hash", new { hash }).FirstOrDefault());
 }
Ejemplo n.º 8
0
 public Product Get(Guid id)
 {
     return(_commonDb.Query <Product>("select * from products where id = @id", new { id }).First());
 }
Ejemplo n.º 9
0
 public MenuOnDay Get(Guid id)
 {
     return(_commonDb.Query <MenuOnDay>($"select * from MenuOnDay where id = @id", new { id }).First());
 }
Ejemplo n.º 10
0
 public IEnumerable <DishList> Get()
 {
     return(_commonDb.Query <DishList>("select * from MenuDish"));
 }
Ejemplo n.º 11
0
 public Dish Get(Guid id)
 {
     return(_commonDb.Query <Dish>($"select * from Dish where id = @id", new { id }).First());
 }