Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre")] UbicacionVendedor ubicacion)
        {
            if (id != ubicacion.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _ubicacionesService.EditUbicacionVendedorPost(ubicacion);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UbicacionExists(ubicacion.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(ubicacion));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Pais,CCAA,Provincia,Poblacion,CP,Calle,Numero,Letra")] UbicacionVendedor ubicacion)
        {
            if (ModelState.IsValid)
            {
                await _ubicacionesService.CreateUbicacionVendedor(ubicacion);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ubicacion));
        }
Ejemplo n.º 3
0
        // GET: Ubicaciones/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            UbicacionVendedor ubicacion = await _ubicacionesService.EditUbicacionVendedorGet(id);

            if (ubicacion == null)
            {
                return(NotFound());
            }
            return(View(ubicacion));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create(VendedorUbicacionVM vendedorUbicacionVM)
        {
            if (ModelState.IsValid)
            {
                Vendedor vendedor = vendedorUbicacionVM.vendedor;
                await _vendedoresService.CreateVendedor(vendedor);

                UbicacionVendedor ubicacionVendedor = vendedorUbicacionVM.ubicacion;
                await _ubicacionesVendedoresService.CreateUbicacionVendedor(ubicacionVendedor);

                return(RedirectToAction("Inscrito", "Vendedores"));
            }
            return(RedirectToAction("Inscrito", "Vendedores"));

            //NOTA: Tenemos que añadir una página error a la que enviar al vendedor si se da algún problema en la creación del mismo
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Miperfil()
        {
            string   vendedorId    = _userManager.GetUserId(User);
            Vendedor nuevoVendedor = await _vendedoresService.ObtenerVendedorDesdedIdentity(vendedorId);

            UbicacionVendedor ubicacionVendedor = await _ubicacionesVendedoresService.GetUbicacionVendedorById(nuevoVendedor.Id);

            VendedorUbicacionVM vendedorUbicacionVM = new VendedorUbicacionVM()
            {
                vendedor  = nuevoVendedor,
                ubicacion = ubicacionVendedor
            };

            ViewData["VendedorUbicacionVM"] = vendedorUbicacionVM;
            return(View(nuevoVendedor));
        }
Ejemplo n.º 6
0
 public async Task EditUbicacionVendedorPost(UbicacionVendedor ubicacion)
 {
     _context.Update(ubicacion);
     await _context.SaveChangesAsync();
 }
Ejemplo n.º 7
0
 public async Task CreateUbicacionVendedor(UbicacionVendedor ubicacion)
 {
     _context.Add(ubicacion);
     await _context.SaveChangesAsync();
 }