public async Task <IActionResult> Edit(string id, [Bind("Email,Contraseña,Nombre,Puntos")] Cliente cliente) { if (id != cliente.Email) { return(NotFound()); } if (ModelState.IsValid) { using (var db = new EmpresaContext()) { try { Cliente aux = db.Cliente.Find(id); aux.Contraseña = cliente.Contraseña; aux.Nombre = cliente.Nombre; //db.Update(cliente); await db.SaveChangesAsync(); } catch (Exception) { } } return(RedirectToAction("Acceder", "Home")); } return(View(cliente)); }
public IActionResult Acceder(string email, string contraseña) { try { using (var db = new EmpresaContext()) { Cliente cli = db.Cliente.Find(email); if (cli != null) { if (cli.Contraseña == contraseña) { return(RedirectToAction("Index", "Perfiles", cli)); } else { ModelState.AddModelError("", "Contraseña incorrecta"); return(View()); } } else { ModelState.AddModelError("", "No se encontro el usuario"); return(View()); } } } catch (Exception) { throw; } }
private bool TurnoDisponible(Turno t) { bool TurnoDips = true; try { using (var db = new EmpresaContext()) { foreach (Turno item in db.Turno) { if (item.FechaHora == t.FechaHora) { if (item.NroCancha == t.NroCancha) { TurnoDips = false; } } } return(TurnoDips); } } catch (Exception) { throw; } }
public IActionResult Create(Cancha c) { if (!ModelState.IsValid) { return(View()); } try { using (var db = new EmpresaContext()) { if (!db.Cancha.Any(a => a.NombreCancha == c.NombreCancha)) { db.Cancha.Add(c); db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Ya existe una cancha con ese nombre"); return(View()); } } } catch (Exception) { throw; } }
public async Task <IActionResult> Edit(int id) { try { using (var db = new EmpresaContext()) { var turno = await db.Turno.FindAsync(id); //Turno t = db.Turno.Find(id); return(View(turno)); } } catch (Exception) { throw; } //if (id == null) //{ // return NotFound(); //} //using (var db = new EmpresaContext()) //{ // var turno = await db.Turno.FindAsync(id); // if (turno == null) // { // return NotFound(); // } // ViewData["EmailCliente"] = new SelectList(db.Cliente, "Email", "Email", turno.EmailCliente); // ViewData["NroCancha"] = new SelectList(db.Cancha, "NroCancha", "NombreCancha", turno.NroCancha); // return View(turno); //} }
public ActionResult Login(string Mail, string Password) { try { using (EmpresaContext db = new EmpresaContext()) { var usr = db.Usuarios.SingleOrDefault (u => u.Mail.ToUpper() == Mail.ToUpper() && u.Password == Password); if (usr != null) { Session["Mail"] = usr.Mail; if (usr.RolCliente) { Session["Tipo"] = "Cliente"; Session["Carrito"] = new List <LineaPedido>(); } else { Session["Tipo"] = "Empleado"; } return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("LoginIncorrecto", "El mail o contraseña no coinciden."); return(View()); } } catch (Exception ex) { return(View()); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, EmpresaContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSession(); app.UseAuthentication(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); AppDbContext.Initialize(context); }
public IActionResult Registrar(Cliente cli) { if (!ModelState.IsValid) { return(View()); } try { using (var db = new EmpresaContext()) { if (!db.Cliente.Any(c => c.Email == cli.Email)) { cli.Puntos = 0; db.Cliente.Add(cli); db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Ya existe ese usuario"); return(View()); } } } catch (Exception) { throw; } }
public IActionResult Edit(int id, Cancha c) { if (!ModelState.IsValid) { return(View(c)); } try { using (var db = new EmpresaContext()) { if (c.Importe > 0) { db.Update(c); db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "El importe debe ser positivo"); return(View()); } } } catch (Exception) { throw; } }
public ActionResult Reservar() { using (var db = new EmpresaContext()) { //ViewData["NroCancha"] = new SelectList(db.Cancha, "NroCancha", "NombreCancha"); return(View()); } }
public IActionResult Index() { using (var db = new EmpresaContext()) { List <Cliente> lista = db.Cliente.ToList(); return(View(lista)); } }
public EmpresaIntegrationEventService(IEventBus eventBus, EmpresaContext empresaContext, Func <DbConnection, IIntegrationEventLogService> integrationEventLogServiceFactory) { _empresaContext = empresaContext ?? throw new ArgumentNullException(nameof(empresaContext)); _integrationEventLogServiceFactory = integrationEventLogServiceFactory ?? throw new ArgumentNullException(nameof(integrationEventLogServiceFactory)); _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus)); _eventLogService = _integrationEventLogServiceFactory(_empresaContext.Database.GetDbConnection()); }
public EmpresaController(EmpresaContext context, IOptionsSnapshot <EmpresaSettings> settings, IEmpresaIntegrationEventService empresaIntegrationEventService) { _empresaContext = context ?? throw new ArgumentNullException(nameof(context)); _empresaIntegrationEventService = empresaIntegrationEventService ?? throw new ArgumentNullException(nameof(empresaIntegrationEventService)); _settings = settings.Value; ((DbContext)context).ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }
public List <CodigoBarra> getCodigosBarra(string GrupoId, string SubGrupoId, string ArticuloId) { try { EmpresaContext db = new EmpresaContext(); List <Articulo> LstArticulos = new List <Articulo>(); //Selecciono el filtro subgrupo if (SubGrupoId != null && SubGrupoId != "") { var filter = Builders <Articulo> .Filter.Eq("SubGrupoComponente._id", SubGrupoId); LstArticulos = db.Articulo.Filters(filter, "Clave,Peso,Pureza,Paises.Abreviatura"); } //Selecciono el filtro grupo else if (GrupoId != null && GrupoId != "") { var filter = Builders <Articulo> .Filter.Eq("GrupoComponente._id", GrupoId); LstArticulos = db.Articulo.Filters(filter, "Clave,Peso,Pureza,Paises.Abreviatura"); } //Selecciono el filtro articulo else if (ArticuloId != null && ArticuloId != "") { var filter = Builders <Articulo> .Filter.Eq("_id", ArticuloId); LstArticulos = db.Articulo.Filters(filter, "Clave,Peso,Pureza,Paises.Abreviatura"); } List <CodigoBarra> LstCodigos = new List <CodigoBarra>(); foreach (Articulo articulo in LstArticulos) { CodigoBarra codigo = new CodigoBarra(); codigo.codigo = articulo.Clave; codigo.peso = articulo.Peso + " GRS"; codigo.procedencia = articulo.Paises != null ? "HECHO " + articulo.Paises.Abreviatura : "HECHO N/A"; //codigo.pureza = articulo.Pureza.ToString(); codigo.pureza = ".925"; codigo.precio = "78 USD"; LstCodigos.Add(codigo); } return(LstCodigos); } catch (Exception) { return(null); } }
public IActionResult Details(string email) { try { using (var db = new EmpresaContext()) { return(View(db.Cliente.Find(email))); } } catch (Exception) { throw; } }
//[HttpPost] //[ValidateAntiForgeryToken] //public async Task<IActionResult> Edit(int id, [Bind("NroTurno,EmailCliente,NroCancha,FechaHora")] Turno turno) //{ // if (id != turno.NroTurno) // { // return NotFound(); // } // if (ModelState.IsValid) // { // try // { using (var db = new EmpresaContext()) // { // db.Update(turno); // await db.SaveChangesAsync(); // } // } // catch (DbUpdateConcurrencyException) // { // if (!TurnoExists(turno.NroTurno)) // { // return NotFound(); // } // else // { // throw; // } // } // return RedirectToAction(nameof(Index)); // } // using (var db = new EmpresaContext()) // { // ViewData["EmailCliente"] = new SelectList(db.Cliente, "Email", "Email", turno.EmailCliente); // ViewData["NroCancha"] = new SelectList(db.Cancha, "NroCancha", "NombreCancha", turno.NroCancha); // return View(turno); // } //} public ActionResult Detalles(int NroTurno) { try { using (var db = new EmpresaContext()) { return(View(db.Turno.Find(NroTurno))); } } catch (Exception) { throw; } }
public ActionResult ListarCanchas() { try { using (var db = new EmpresaContext()) { return(PartialView(db.Cancha.ToList())); } } catch (Exception) { throw; } }
public IActionResult Index() { try { using (var db = new EmpresaContext()) { return(View(db.Cancha.ToList())); } } catch (Exception) { throw; } }
public IActionResult Edit(int nroCancha) { try { using (var db = new EmpresaContext()) { return(View(db.Cancha.Find(nroCancha))); } } catch (Exception) { throw; } }
//private readonly EmpresaContext _context; //public UsuariosController(EmpresaContext context) //{ // _context = context; //} public ActionResult Index(Cliente cli) { try { using (var db = new EmpresaContext()) { TempData["EmailUsuario"] = cli.Email; var lista = db.Turno.Include(t => t.EmailClienteNavigation).Include(t => t.NroCanchaNavigation); return(View(lista.Where(a => a.EmailCliente == cli.Email).ToList())); } } catch (Exception) { throw; } }
public ActionResult Reservar(Turno t) { try { using (var db = new EmpresaContext()) { if (db.Cliente.Any(c => c.Email == t.EmailCliente)) { Cancha cancha = db.Cancha.Find(t.NroCancha); //validar fecha no pasada if (cancha.Habilitada) { if (!this.TurnoNoDisponible(t)) { t.NroCanchaNavigation = cancha; Cliente cli = db.Cliente.Find(t.EmailCliente); t.EmailClienteNavigation = cli; db.Turno.Add(t); cli.Puntos += 100; cli.Turno.Add(t); db.SaveChanges(); return(RedirectToAction("Index", cli)); } else { ModelState.AddModelError("", "Turno no disponible"); return(View()); } } else { ModelState.AddModelError("", "La cancha no esta disponible"); return(View()); } } else { ModelState.AddModelError("", "Email inexistente"); return(View()); } } } catch (Exception) { throw; } }
public async Task <IActionResult> Edit(string id) { if (id == null) { return(NotFound()); } using (var db = new EmpresaContext()) { var cliente = await db.Cliente.FindAsync(id); if (cliente == null) { return(NotFound()); } return(View(cliente)); } }
static void Main(string[] args) { EmpresaContext context = new EmpresaContext(); #region Crear Country //CountryService service = new CountryService(new UnitOfWork(context), new CountryRepository(context)); //Country country = new Country() { Name = "Colombia" }; //service.Create(country); //List<Country> countries=service.GetAll().ToList(); //foreach (var item in countries) //{ // System.Console.WriteLine(item.Name); //} #endregion //CrearCuentaBancaria(context); //ConsignarCuentaBancaria(context); }
public ActionResult FinalizarCompra() { EmpresaContext db = new EmpresaContext(); var carrito = (List <LineaPedido>)Session["Carrito"]; double total = 0; string sesionmail = (string)Session["Mail"]; Pedido pedido = new Pedido(); pedido.Fecha = DateTime.Now; pedido.Usuario = db.Usuarios.FirstOrDefault(u => u.Mail == sesionmail); pedido.Pedidos = new List <LineaPedido>(); foreach (LineaPedido p in carrito) { if (p.Cantidad < 0) { return(View(carrito.ToList())); } if (p.Cantidad > 0) { pedido.Pedidos.Add(p); total += p.Cantidad * p.PrecioVenta; } } db.Pedidos.Add(pedido); db.SaveChanges(); Session["Carrito"] = new List <LineaPedido>(); TempData["montoCarrito"] = "Total de la compra:" + "$" + total; TempData["ur"] = pedido.Usuario.Mail; TempData["fecha"] = pedido.Fecha; return(View(pedido.Pedidos)); }
public ActionResult Edit(int id, [Bind("NroTurno,EmailCliente,NroCancha,FechaHora")] Turno t) { try { using (var db = new EmpresaContext()) { Cancha cancha = db.Cancha.Find(t.NroCancha); //validar fecha no pasada if (cancha.Habilitada) { if (!this.TurnoNoDisponible(t)) { Turno turno = db.Turno.Find(id); turno.FechaHora = t.FechaHora; turno.EmailCliente = t.EmailCliente; turno.NroCancha = t.NroCancha; db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Turno no disponible"); return(View()); } } else { ModelState.AddModelError("", "La cancha no esta disponible"); return(View()); } } } catch (Exception) { throw; } }
public FuncionarioRepository(EmpresaContext db) : base(db) { }
public SalesController(EmpresaContext context) { _context = context; }
public HomeController(EmpresaContext context) { _context = context; }
public Canchas1Controller(EmpresaContext context) { _context = context; }
public Empresa() { _contexto = new EmpresaContext(); }