示例#1
0
        // GET: /Manage/DeleteDireccion
        public ActionResult DeleteDireccion(int id)
        {
            var        userId  = User.Identity.GetUserId();
            RepoDapper DirRepo = new RepoDapper();

            return(View(DirRepo.GetDirecciones(userId).Find(Dir => Dir.id == id)));
        }
示例#2
0
        public ActionResult Cliente(string cliente)
        {
            RepoDapper Repo = new RepoDapper();
            var        est  = Repo.ReporteCliente(cliente);

            return(View(est));
        }
        //
        // GET: /CarritoCompras/Compra
        public ActionResult Compra()
        {
            var userid = User.Identity.GetUserId();

            RepoDapper EmpRepo = new RepoDapper();

            //ViewBag.TarjetaId = new SelectList(EmpRepo.GetTarjetas(userid), "id", "Numero");
            ViewBag.DireccionID  = new SelectList(EmpRepo.GetDirecciones(userid), "id", "Direccion");
            ViewBag.DireccionID2 = EmpRepo.GetDirecciones(userid);
            ViewBag.TarjetaId2   = EmpRepo.GetTarjetas(userid);
            //ViewBag.PaqueteriaID = new SelectList(EmpRepo.GetEnvios(), "id", "Nombre");

            PaqueteriasContext paqueteriasDB = new PaqueteriasContext();
            List <Paqueterias> p             = paqueteriasDB.Paqueterias.Include(x => x.pqt).Where(t => t.Activo == true).ToList();

            ViewBag.PaqueteriaId = p;

            var cart = CarritoCompras.GetCart(this.HttpContext);

            ViewBag.Total = cart.GetTotal();

            List <Cart> carrito = cart.GetCartItems();

            ViewBag.Carrito      = carrito;
            ViewBag.CarritoTotal = carrito.Count();

            return(View());
        }
示例#4
0
        // Falta probarlo, jala pero no me esta funcionando, no ejecuta el procedure parece
        // GET: /Manage/EditTarjeta
        public ActionResult EditTarjeta(int id)
        {
            var        userId  = User.Identity.GetUserId();
            RepoDapper TarRepo = new RepoDapper();

            return(View(TarRepo.GetTarjetas(userId).Find(Tar => Tar.id == id)));
        }
示例#5
0
        // GET: Admin/GetRequests
        // Esto regrea una lista de las solicitudes para ser vendedor
        public ActionResult GetRequests()
        {
            RepoDapper Repo = new RepoDapper();
            List <RequestViewModel> requestViewModel = Repo.GetRequests();

            return(View(requestViewModel));
        }
示例#6
0
        public ActionResult RemoveTarjeta(int id)
        {
            RepoDapper TarRepo = new RepoDapper();

            TarRepo.BorrarTarjeta(id);
            return(RedirectToAction("Tarjetas"));
        }
        //Lista de categorias con dapper
        public ActionResult CategoriasDapper()
        {
            RepoDapper EmpRepo = new RepoDapper();
            var        categ   = EmpRepo.GetCategorias();

            return(View(categ));
        }
        //Lista de productos con dapper
        public ActionResult ProductosDapper(string categ)
        {
            //categ = "Ropa Mujeres";
            RepoDapper EmpRepo = new RepoDapper();
            var        prod    = EmpRepo.GetSubCategorias(categ);

            return(View(prod));
        }
示例#9
0
        // Regresa lista con las tarjetas del usuario
        // GET: /Manage/Tarjetas
        public ActionResult Tarjetas()
        {
            var        userid  = User.Identity.GetUserId();
            RepoDapper EmpRepo = new RepoDapper();
            var        tar     = EmpRepo.GetTarjetas(userid);

            return(View(tar));
        }
        //Lista de subcategorias con dapper
        public ActionResult SubCategoriaDapper(string categoria)
        {
            //categoria = "Ropa, Zapatos y Accesorios";
            RepoDapper EmpRepo = new RepoDapper();
            var        categ   = EmpRepo.GetSubCategorias(categoria);

            return(View(categ));
        }
示例#11
0
        public ActionResult Estado(string estado)
        {
            ViewBag.message = estado;
            RepoDapper Repo = new RepoDapper();
            var        est  = Repo.ReporteEstado(estado);

            return(View(est));
        }
示例#12
0
        public ActionResult Vendedor(string vendedor)
        {
            ViewBag.vendor = vendedor;
            RepoDapper Repo = new RepoDapper();
            var        est  = Repo.ReporteVendedor(vendedor);

            return(View(est));
        }
示例#13
0
        public ActionResult Categoria(string categoria)
        {
            ViewBag.message = categoria;
            RepoDapper Repo = new RepoDapper();
            var        est  = Repo.ReporteCategoria(categoria);

            return(View(est));
        }
示例#14
0
        public ActionResult VerSolicitud()
        {
            var            UserId = User.Identity.GetUserId();
            RepoDapper     Repo   = new RepoDapper();
            List <Request> Req    = Repo.GetSolicitud(UserId);

            return(View(Req));
        }
示例#15
0
        public ActionResult Producto(string producto)
        {
            ViewBag.message = producto;
            RepoDapper Repo = new RepoDapper();
            var        est  = Repo.ReporteProducto(producto);

            return(View(est));
        }
示例#16
0
        // GET: Compras
        public ActionResult Index()
        {
            var        userid      = User.Identity.GetUserId();
            RepoDapper Repo        = new RepoDapper();
            var        comprasList = Repo.GetMisPedidos(userid);

            //var comprasList = db.Compras.Where(x => x.UserId == userId).ToList();

            return(View(comprasList));
        }
示例#17
0
 public ActionResult BorrarDireccion(int id)
 {
     try
     {
         RepoDapper TarRepo = new RepoDapper();
         TarRepo.BorrarDireccion(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Delete(int id)
 {
     try
     {
         RepoDapper Repo = new RepoDapper();
         Repo.BorrarProducto(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#19
0
 public ActionResult EditTarjeta(Tarjeta tar)
 {
     try
     {
         RepoDapper TarRepo = new RepoDapper();
         TarRepo.EditarTarjeta(tar);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#20
0
 public ActionResult DeleteDireccion(Direccion dir)
 {
     try
     {
         RepoDapper DirRepo = new RepoDapper();
         DirRepo.BorrarDireccion(dir.id);
         return(RedirectToAction("Direcciones"));
     }
     catch
     {
         return(View());
     }
 }
示例#21
0
        // GET: Admin/EditRequests/5
        public ActionResult EditRequests(int id)
        {
            List <Statu> StatuList = new List <Statu>();

            using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                StatuList = db.Query <Statu>("Select * From Statu").ToList();
            }
            ViewBag.Statu = new SelectList(StatuList, "Id", "Stat");
            var        userId  = User.Identity.GetUserId();
            RepoDapper DirRepo = new RepoDapper();

            return(View(DirRepo.GetRequests().Find(Dir => Dir.id == id)));
        }
示例#22
0
        public ActionResult VerificarRegistroVendedor()
        {
            var            UserId = User.Identity.GetUserId();
            RepoDapper     Repo   = new RepoDapper();
            List <Request> Req    = Repo.GetSolicitud(UserId);

            if (Req.Count() != 0)
            {
                return(RedirectToAction("VerSolicitud"));
            }
            else
            {
                return(RedirectToAction("Solicitud"));
            }
        }
示例#23
0
        // GET: Compras/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RepoDapper Repo   = new RepoDapper();
            var        compra = Repo.GetMisPedidosDetalles(id);

            if (compra == null)
            {
                return(HttpNotFound());
            }
            return(View(compra));
        }
示例#24
0
 public ActionResult EditDireccion(Direccion dir)
 {
     try
     {
         // string Username = User.Identity.GetUserId();
         RepoDapper DirRepo = new RepoDapper();
         // dir.userId = Username;
         DirRepo.EditarDireccion(dir);
         return(RedirectToAction("Direcciones"));
     }
     catch
     {
         return(View());
     }
 }
示例#25
0
        // Esto no borra las direcciones de la BD, solo las hace invalidas y ya nunca las vuelve a ver el usuario
        //Falta probarla aqui
        // GET: /Manage/BorrarDireccion
        public ActionResult BorrarDireccion(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var        userId  = User.Identity.GetUserId();
            RepoDapper DirRepo = new RepoDapper();
            var        dir     = DirRepo.GetDirecciones(userId).Find(Dir => Dir.id == id);

            if (dir == null)
            {
                return(HttpNotFound());
            }
            return(View(dir));
        }
示例#26
0
        // Esto no borra las tarjetas de la BD, solo las hace invalidas y ya nunca las vuelve a ver el usuario
        //Falta probarla aqui
        // GET: /Manage/BorrarTarjeta
        public ActionResult BorrarTarjeta(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var        userId  = User.Identity.GetUserId();
            RepoDapper TarRepo = new RepoDapper();
            var        tar     = TarRepo.GetTarjetas(userId).Find(Tar => Tar.id == id);

            if (tar == null)
            {
                return(HttpNotFound());
            }
            return(View(tar));
        }
示例#27
0
        public ActionResult EditRequests(int id, int Statu)
        {
            try
            {
                Request requestUser = new Request();
                using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
                {
                    requestUser = db.Query <Request>("Select * From Request WHERE id=" + id, new { id }).SingleOrDefault();
                }

                RequestStatus statu = new RequestStatus();
                statu.RequestId = id;
                statu.StatusId  = Statu;
                RepoDapper Repo = new RepoDapper();
                Repo.Cambio_de_estado(statu);

                if (statu.StatusId == 2)
                {
                    using (var context = new ApplicationDbContext())
                    {
                        var usermanager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
                        usermanager.AddToRole(requestUser.UserId, "vendedor");
                        context.SaveChanges();
                    }
                }
                else
                {
                    if (statu.StatusId == 4)
                    {
                        using (var context = new ApplicationDbContext())
                        {
                            var usermanager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
                            usermanager.RemoveFromRole(requestUser.UserId, "vendedor");
                            context.SaveChanges();
                        }
                    }
                }


                return(RedirectToAction("GetRequests"));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
示例#28
0
 public ActionResult AddTarjeta(TarjetaViewModel tar)
 {
     try
     {
         if (ModelState.IsValid)
         {
             RepoDapper TarRepo = new RepoDapper();
             tar.UserId = User.Identity.GetUserId();
             TarRepo.CrearTarjeta(tar);
             ViewBag.Message = "La tarjeta se agrego.";
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         ViewBag.Message = "La tarjeta no se agrego.";
         return(View());
     }
 }
示例#29
0
 public ActionResult Solicitud(Request Req)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Req.UserId = User.Identity.GetUserId();
             RepoDapper Repo = new RepoDapper();
             Repo.LlenarSolicitud(Req);
             ViewBag.Message = "Su solicitud se envio.";
         }
         //return View();
         return(RedirectToAction("Index"));
     }
     catch
     {
         ViewBag.Message = "Su solicitud no se envio.";
         return(View());
     }
 }
示例#30
0
 public ActionResult AddDireccion(DireccionViewModel dir)
 {
     try
     {
         if (ModelState.IsValid)
         {
             string     Username = User.Identity.GetUserId();
             RepoDapper DirRepo  = new RepoDapper();
             dir.UserId = Username;
             DirRepo.CrearDireccion(dir);
             ViewBag.Message = "La direccion se agrego.";
         }
         return(RedirectToAction("Direcciones"));
     }
     catch
     {
         ViewBag.Message = "La direccion no se agrego.";
         return(View());
     }
 }