public IEnumerable <dynamic> Cores() { var context = new DaoContext(); var list = context.Cores.ToList(); return(list); }
public IEnumerable <dynamic> Tamanhos() { var context = new DaoContext(); var list = context.Tamanhos.ToList(); return(list); }
public IEnumerable <dynamic> UnidadeMedidas() { var context = new DaoContext(); var list = context.UnidadeMedidas.ToList(); return(list); }
public List <Filial> Filiais() { var context = new DaoContext(); var list = context.Filiais.ToList(); return(list.ToList()); }
public int New(string especie) { var context = new DaoContext(); int codigoNew = 1; IQueryable <ProdutoCodigo> produtoCodigo = context.ProdutoCodigos.Where(p => p.IDEspecie == Int32.Parse(especie)).DefaultIfEmpty(); if (produtoCodigo.ToList()[0] != null) { codigoNew += produtoCodigo.Max(m => m.Codigo); } Especie esp = context.Especies.Where(s => s.Id == Int32.Parse(especie)).Include(s => s.Secao).FirstOrDefault(); ProdutoCodigo pdc = new ProdutoCodigo(); pdc.Especie = esp; pdc.Codigo = codigoNew; context.ProdutoCodigos.Add(pdc); context.SaveChanges(); Produto prd = new Produto(pdc); prd.Descricao = "Produto teste"; context.Produtos.Add(prd); context.SaveChanges(); return(prd.Id); }
public void AddUser(UserModel user) { var command = DaoContext.CreateCommand(); command.CommandText = "INSERT INTO USER(name, age, mail) VALUES(:name, :age, :mail);"; var paramName = command.CreateParameter(); paramName.ParameterName = "name"; paramName.Value = user.Name; command.Parameters.Add(paramName); var paramAge = command.CreateParameter(); paramAge.ParameterName = "age"; paramAge.Value = user.Age; command.Parameters.Add(paramAge); var paramMail = command.CreateParameter(); paramMail.ParameterName = "mail"; paramMail.Value = user.MailAddress; command.Parameters.Add(paramMail); command.ExecuteNonQuery(); }
public IEnumerable <dynamic> Especies(int id = 0, short[] secoes = null) { List <short> listSecoes = new List <short>(); listSecoes.Add(0); if (secoes.Length > 0) { listSecoes = secoes.ToList(); } var context = new DaoContext(); var list = context.Especies.Where(e => e.Id == ((id == 0) ? e.Id : id)).Select(s => new { s.Id, s.Descricao, s.Codigo, SecaoId = s.Secao.Id, SecaoDescricao = s.Secao.Descricao, SegmentoId = s.Secao.Segmento.Id, SegmentoDescricao = s.Secao.Segmento.Descricao, RamoAtividadeId = s.Secao.Segmento.RamoAtividade.Id, RamoAtividadeDescricao = s.Secao.Segmento.RamoAtividade.Descricao, QtdeProdutos = 0//s.Produtos.Count }); return(list); }
public UserModel GetUser(long id) { var command = DaoContext.CreateCommand(); command.CommandText = "SELECT * FROM USER WHERE ID = :id"; // TODO ここらへんは拡張メソッドとかを作ると綺麗になる var param = command.CreateParameter(); param.ParameterName = "id"; param.Value = id; command.Parameters.Add(param); var reader = command.ExecuteReader(); // TODO DbDataReaderからModelを生成するBuilderクラスを作ると綺麗になる。 if (reader.HasRows && reader.Read()) { // 先頭1件のみ取得する return(new UserModel { ID = reader.GetInt64(0), Name = reader.GetString(1), Age = reader.GetInt32(2), MailAddress = reader.GetString(3), }); } else { // 見つからない場合 // TODO 独自のExceptionを作ってthrowすると良い。 throw new Exception("Not found."); } }
static void Main() { DaoContext.Initialize(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); new MainViewModel(); }
public TemplatesController(DaoContext context, JwtUserDto user, EncryptionProvider encryption, IConfiguration configuration) { this.context = context; this.user = user; this.encryption = encryption; this.configuration = configuration; }
public void initialize() { container = new UnityContainer(); DaoContext dao = new DaoContext(); container.RegisterInstance <DbContext>(dao); inventoryCategoryDao = container.Resolve <InventoryCategoryDao>(); }
public IEnumerable <dynamic> RamoAtividades() { var context = new DaoContext(); var list = context.RamosAtividades.Include(s => s.Segmentos).Select(s => new { s.Id, s.Descricao, QtdeSegmentos = s.Segmentos.Count }); return(list); }
public IEnumerable <dynamic> Marcas() { var context = new DaoContext(); var list = context.Marcas.Include(p => p.Produtos).Select(s => new { s.Id, s.Descricao, QtdeProdutos = s.Produtos.Count }); return(list.OrderBy(o => o.Descricao).ToList()); }
public void test1() { var context = new DaoContext(); User user = new User(); user.username = "******"; user.password = "******"; context.Users.Add(user); context.SaveChanges(); }
public void TestMethod1() { DaoContext dao = new DaoContext(); InventoryCategory inventoryCat = new InventoryCategory(); inventoryCat.Name = "testing"; dao.InventoryCategories.Add(inventoryCat); dao.SaveChanges(); }
/// <summary>Registers the type mappings with the Unity container.</summary> /// <param name="container">The unity container to configure.</param> /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks> public static void RegisterTypes(IUnityContainer container) { // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements. // container.LoadConfiguration(); // TODO: Register your types here // container.RegisterType<IProductRepository, ProductRepository>(); DaoContext dao = new DaoContext(); container.RegisterInstance <DbContext>(dao); container.RegisterType <IInventoryCategoryDao, InventoryCategoryDao>(); }
public IEnumerable <dynamic> Secoes() { var context = new DaoContext(); var list = context.Secoes.Include(s => s.Especies).Select(s => new { s.Id, s.Descricao, SegmentoId = s.Segmento.Id, SegmentoDescricao = s.Segmento.Descricao, QtdeProdutos = s.Especies.Count }); return(list); }
public IEnumerable <dynamic> Segmentos() { var context = new DaoContext(); var list = context.Segmentos.Include(s => s.Secoes).ThenInclude(s => s.Especies).Select(s => new { s.Id, s.Descricao, RamoAtividadeId = s.RamoAtividade.Id, RamoAtividadeDescricao = s.RamoAtividade.Descricao, QtdeProdutos = s.Secoes.Count }); return(list); }
public long GetCount() { var command = DaoContext.CreateCommand(); command.CommandText = "SELECT COUNT(*) FROM USER;"; if (command.ExecuteScalar() is long result) { return(result); } else { // SQLのミスで取得した型が違う場合 // TODO 独自のExceptionを作ってthrowすると良い。 throw new Exception("Error"); } }
public ActionResult Index() { var mvcName = typeof(Controller).Assembly.GetName(); var isMono = Type.GetType("Mono.Runtime") != null; ViewData ["Version"] = mvcName.Version.Major + "." + mvcName.Version.Minor; ViewData ["Runtime"] = isMono ? "Mono" : ".NET"; using (var db = new DaoContext()) { Console.WriteLine( db.Users.First().ToString() ); ViewData ["Runtime"] = db.Users.First().user_id; } return(View()); }
public IReadOnlyList <UserModel> GetUsers(UserFindParameter parameter) { var command = DaoContext.CreateCommand(); var builder = new StringBuilder(); builder.Append("SELECT * FROM USER WHERE 1=1 "); // TODO ここらへんは拡張メソッドとかを作ると綺麗になる if (parameter.AgeLower.HasValue) { builder.Append("AND age >= :age_lower "); var p = command.CreateParameter(); p.ParameterName = "age_lower"; p.Value = parameter.AgeLower.Value; command.Parameters.Add(p); } if (parameter.AgeUpper.HasValue) { builder.Append("AND age <= :age_upper "); var p = command.CreateParameter(); p.ParameterName = "age_upper"; p.Value = parameter.AgeUpper.Value; command.Parameters.Add(p); } command.CommandText = builder.Append(";").ToString(); var reader = command.ExecuteReader(); // TODO DbDataReaderからModelを生成するBuilderクラスを作ると綺麗になる。 var result = new List <UserModel>(); if (reader.HasRows) { while (reader.Read()) { result.Add(new UserModel { ID = reader.GetInt64(0), Name = reader.GetString(1), Age = reader.GetInt32(2), MailAddress = reader.GetString(3), }); } } return(result); }
public IEnumerable <dynamic> ListHierarquia(string nivel, string pais = "0") { List <int> listPai = new List <int>(); if (pais == null) { pais = "0"; } if (pais != "0") { listPai.AddRange(pais.Split(',').Select(int.Parse).ToList()); } var context = new DaoContext(); IEnumerable <dynamic> list = null; switch (nivel) { case "ram": list = GetRamoAtividades(listPai); break; case "seg": list = GetSegmentos(listPai); break; case "sec": list = GetSecoes(listPai); break; case "esp": list = GetEspecies(listPai); break; default: list = null; break; } return(list); }
public JwtSecurity(DaoContext daoContext) { userRepository = new UserRepository(daoContext); }
public AuthenticatedUserComponent(IHttpContextAccessor httpContextAccessor, DaoContext context) { this.httpContextAccessor = httpContextAccessor; this.context = context; }
public AuthenticatedUserProvider(IHttpContextAccessor httpContextAccessor, DaoContext context) { this.httpContextAccessor = httpContextAccessor; this.context = context; }
public UserDao(DaoContext context) : base(context) { }
public static LogEventData FromLogEvent(LogEvent logEvent) { return(FromLogEvent(logEvent, DaoContext.Get(LogEventData.ContextName).DatabaseAgent)); }
public UserRepository(DaoContext daoContext) { this.context = daoContext; }
private void OnDaoContextConnectionStringSet(DaoContext context, string logicalName) { if (DaoContextConnectionStringSet!= null) DaoContextConnectionStringSet(context, logicalName); }
public Crud(DaoContext daoContext) { context = daoContext; }
public FileController(JwtUserDto user, DaoContext context, ImageComponent typeProvider) { this.user = user; this.context = context; this.typeProvider = typeProvider; }