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); } }
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); } }
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); }
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); } }
internal static FileInfo GetFileInfo(Guid id, ICommonDb commonDb) { return(commonDb.Query <FileInfo>("select id, filename, hash from FileSystem where id = @id", new { id }).First()); }
internal static FileInfo GetFileInfo(string hash, ICommonDb commonDb) { return(commonDb.Query <FileInfo>("select id, filename, hash from FileSystem where hash = @hash", new { hash }).FirstOrDefault()); }
public Product Get(Guid id) { return(_commonDb.Query <Product>("select * from products where id = @id", new { id }).First()); }
public MenuOnDay Get(Guid id) { return(_commonDb.Query <MenuOnDay>($"select * from MenuOnDay where id = @id", new { id }).First()); }
public IEnumerable <DishList> Get() { return(_commonDb.Query <DishList>("select * from MenuDish")); }
public Dish Get(Guid id) { return(_commonDb.Query <Dish>($"select * from Dish where id = @id", new { id }).First()); }