public async Task<IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,MiddleName,PostCode,Relationship,State,StreetName,StreetNumber,StreetType,Suburb,TestatorID")] Executor executor)
        {
            if (id != executor.ID)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(executor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExecutorExists(executor.ID))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction("Index");
            }
            ViewData["TestatorID"] = new SelectList(_context.Testators, "ID", "Testator", executor.TestatorID);
            return View(executor);
        }
        public async Task <IActionResult> AdicionarCapacitaciones(string id)
        {
            var lista = new List <Capacitacion>();

            try
            {
                var indiceOcupacional = new IndiceOcupacional
                {
                    IdIndiceOcupacional = Convert.ToInt32(id),
                };
                lista = await apiServicio.Listar <Capacitacion>(indiceOcupacional,
                                                                new Uri(WebApp.BaseAddress),
                                                                "/api/IndiceOcupacionalCapacitaciones/ListaFiltradaCapacitaciones");

                ViewData["IdCapacitacion"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(lista, "IdCapacitacion", "Nombre");

                //ViewBag.listacap = new SelectList(lista, "IdCapacitacion", "Nombre");


                var Indice = new IndiceOcupacionalCapacitaciones
                {
                    IdIndiceOcupacional = Convert.ToInt32(id),
                };

                return(PartialView("..//IndicesOcupacionales//AdicionarCapacitaciones", Indice));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Пример #3
0
        //public override void Process(TagHelperContext context, TagHelperOutput output)
        //{
        //    base.Process(context, output);
        //}

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            TagHelperUtil.CreateOrMergeAttribute("class", "form-control form-control-sm", output);
            output.TagName = "select";
            output.TagMode = TagMode.StartTagAndEndTag;

            TagHelperAttribute aspItemsAttribute = context.AllAttributes["asp-items"];
            object             aspItems          = aspItemsAttribute.Value;
            object             newValue          = null;

            if (aspItems is IEnumerable <CodeNameModel> )
            {
                newValue = new Microsoft.AspNetCore.Mvc.Rendering.SelectList((IEnumerable <CodeNameModel>)aspItems, "Code", "Name");
            }
            else if (aspItems is IEnumerable <IdNameModel> )
            {
                newValue = new Microsoft.AspNetCore.Mvc.Rendering.SelectList((IEnumerable <IdNameModel>)aspItems, "Id", "Name");
            }

            if (newValue != null)
            {
                base.Items = (Microsoft.AspNetCore.Mvc.Rendering.SelectList)newValue;
            }
            else
            {
                base.Items = (Microsoft.AspNetCore.Mvc.Rendering.SelectList)aspItems;
            }
            await base.ProcessAsync(context, output);
        }
Пример #4
0
        // GET: Movies


        public IActionResult Index(string movieGenre, string searchString)
        {
            var GenreQry = from m in _context.Movie
                           orderby m.Genre
                           select m.Genre;

            var GenreList = new List<string>();
            GenreList.AddRange(GenreQry.Distinct());
            ViewData["movieGenre"] = new SelectList(GenreList);

            var movies = from m in _context.Movie
                         select m;

            if (!String.IsNullOrEmpty(searchString))
            {
                movies = movies.Where(s => s.Title.Contains(searchString));
            }

            if (!string.IsNullOrEmpty(movieGenre))
            {
                movies = movies.Where(x => x.Genre == movieGenre);
            }

            return View(movies);
        }
Пример #5
0
        public async Task <IActionResult> Edit(string id)
        {
            try
            {
                ViewData["IdCiudad"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <Ciudad>(new Uri(WebApp.BaseAddress), "api/Ciudad/ListarCiudad"), "IdCiudad", "Nombre");

                if (!string.IsNullOrEmpty(id))
                {
                    var respuesta = await apiServicio.SeleccionarAsync <entidades.Utils.Response>(id, new Uri(WebApp.BaseAddress),
                                                                                                  "api/Sucursal");


                    respuesta.Resultado = JsonConvert.DeserializeObject <Sucursal>(respuesta.Resultado.ToString());
                    if (respuesta.IsSuccess)
                    {
                        InicializarMensaje(null);
                        return(View(respuesta.Resultado));
                    }
                }

                return(BadRequest());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Пример #6
0
        public async Task <IActionResult> Create()
        {
            //ViewData["IdIndiceOcupacional"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar<IndiceOcupacional>(new Uri(WebApp.BaseAddress), "api/IndicesOcupacionales/ListarIndicesOcupacionales"), "IdIndiceOcupacional", "Nombre");
            ViewData["IdComportamientoObservable"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <ComportamientoObservable>(new Uri(WebApp.BaseAddress), "api/ComportamientosObservables/ListarComportamientosObservables"), "IdComportamientoObservable", "Nombre");

            return(View());
        }
Пример #7
0
        public async Task <IActionResult> Create()
        {
            var lista = await apiServicio.Listar <Ciudad>(new Uri(WebApp.BaseAddress), "/api/Ciudad/ListarCiudad");

            ViewData["IdCiudad"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <Ciudad>(new Uri(WebApp.BaseAddress), "/api/Ciudad/ListarCiudad"), "IdCiudad", "Nombre");

            return(View());
        }
Пример #8
0
 public async Task<IActionResult> NuevoMensaje()
 {            
     SelectList personajes = new SelectList(await _servicioPersonajes.GetEnumeradoPersonajes(), "Id", "Descripcion");
     personajes.Append(new SelectListItem() { Value = "", Text = "" });
     ViewBag.PersonajesPara = personajes;
     ViewBag.PersonajesCopiaOculta = personajes;
     ViewBag.Titulo = "Nuevo Mensaje";
     return View();
 }
Пример #9
0
        public async Task <IActionResult> RevisaPermisos()
        {
            var claim         = HttpContext.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault();
            var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value;

            Empleado jefe = await apiServicio.ObtenerElementoAsync1 <Empleado>(NombreUsuario, new Uri(WebApp.BaseAddress), "api/Empleados/EmpleadoSegunNombreUsuario");

            ViewData["IdEmpleado"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <ListaEmpleadoViewModel>(jefe, new Uri(WebApp.BaseAddress), "api/Empleados/EmpleadosAsuCargo"), "IdEmpleado", "NombreApellido", jefe);

            return(View());
        }
 public async Task<IActionResult> Create([Bind("ID,FirstName,LastName,MiddleName,PostCode,Relationship,State,StreetName,StreetNumber,StreetType,Suburb,TestatorID")] Executor executor)
 {
     if (ModelState.IsValid)
     {
         _context.Add(executor);
         await _context.SaveChangesAsync();
         return RedirectToAction("Index");
     }
     ViewData["TestatorID"] = new SelectList(_context.Testators, "ID", "Testator", executor.TestatorID);
     return View(executor);
 }
Пример #11
0
 public async Task<IActionResult> Create([Bind("DepartmentID,Budget,InstructorID,Name,RowVersion,StartDate")] Department department)
 {
     if (ModelState.IsValid)
     {
         _context.Add(department);
         await _context.SaveChangesAsync();
         return RedirectToAction("Index");
     }
     ViewData["InstructorID"] = new SelectList(_context.Instructors, "ID", "FullName", department.InstructorID);
     return View(department);
 }
Пример #12
0
        protected override async System.Threading.Tasks.Task <object> AddViewDataAsync(
            Models.Agenda.Reserva resource = null
            )
        {
            ViewData["LocalId"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(
                await _serviceLocal.GetAllAsync(),
                nameof(Models.Agenda.Local.Id),
                nameof(Models.Agenda.Local.Nome),
                resource?.LocalId);

            return(base.AddViewDataAsync(resource));
        }
 public async Task<IActionResult> Create([Bind("Id,AppicationUserId,CateBlogId,Content,DateEdited,DatePosted,ImageUrl,IsDeleted,IsLocked,LikeNo,Status,Summary,TextSearch,Title,UrlSlug,UserId,ViewNo")] Blog blog)
 {
     if (ModelState.IsValid)
     {
         _context.Add(blog);
         await _context.SaveChangesAsync();
         return RedirectToAction("Index");
     }
     ViewData["AppicationUserId"] = new SelectList(_context.Users, "Id", "", blog.AppicationUserId);
     ViewData["CateBlogId"] = new SelectList(_context.CategoryBlogs, "Id", "Description", blog.CateBlogId);
     return View(blog);
 }
        // GET: Categories
        public IActionResult Index()
        {
            ViewData["ParentId"] = new SelectList(_cateRepo.FindBy(c => c.Level == 0), "Id", "Name");

            IEnumerable<Level> _level = new List<Level>()
            {
                new Level { Id=0,Value=0},
                new Level { Id=1,Value=1}
            };

            ViewData["Level"] = new SelectList(_level, "Id", "Value");
            return View();
        }
Пример #15
0
        public async Task <IActionResult> Create(Sucursal sucursal)
        {
            if (!ModelState.IsValid)
            {
                InicializarMensaje(null);
                ViewData["IdCiudad"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <Ciudad>(new Uri(WebApp.BaseAddress), "api/Ciudad/ListarCiudad"), "IdCiudad", "Nombre");
                return(View(sucursal));
            }
            entidades.Utils.Response response = new entidades.Utils.Response();

            try
            {
                response = await apiServicio.InsertarAsync(sucursal,
                                                           new Uri(WebApp.BaseAddress),
                                                           "api/Sucursal/InsertarSucursal");

                if (response.IsSuccess)
                {
                    var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                        ExceptionTrace       = null,
                        Message              = "Se ha creado una Sucursal",
                        UserName             = "******",
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                        EntityID             = string.Format("{0} {1}", "Sucursal:", sucursal.IdSucursal),
                    });

                    return(RedirectToAction("Index"));
                }
                ViewData["IdCiudad"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <Ciudad>(new Uri(WebApp.BaseAddress), "api/Ciudad/ListarCiudad"), "IdCiudad", "Nombre");
                ViewData["Error"]    = response.Message;
                return(View(sucursal));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Creando Sucursal",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
        // GET: Executors/Edit/5
        public async Task<IActionResult> Edit(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            var executor = await _context.Executors.SingleOrDefaultAsync(m => m.ID == id);
            if (executor == null)
            {
                return NotFound();
            }
            ViewData["TestatorID"] = new SelectList(_context.Testators, "ID", "Testator", executor.TestatorID);
            return View(executor);
        }
        private async Task <bool> CargarComboCapacitaciones(IndiceOcupacional indiceOcupacional)
        {
            var listaComportamientosObservables = await apiServicio.Listar <Capacitacion>(indiceOcupacional,
                                                                                          new Uri(WebApp.BaseAddress),
                                                                                          "api/Capacitaciones/ListarCapacitacionesNoAsignadasIndiceOcupacional");

            var resultado = false;

            if (listaComportamientosObservables.Count != 0)
            {
                ViewData["IdCapacitacion"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(listaComportamientosObservables, "IdCapacitacion", "Nombre");
                resultado = true;
            }

            return(resultado);
        }
        private async Task <bool> CargarComboConocimientosAdicionales(IndiceOcupacional indiceOcupacional)
        {
            var listaConocimientosAdicionales = await apiServicio.Listar <ConocimientosAdicionales>(indiceOcupacional,
                                                                                                    new Uri(WebApp.BaseAddress),
                                                                                                    "api/ConocimientosAdicionales/ListarConocimientosAdicionalesNoAsignadasIndiceOcupacional");

            var resultado = false;

            if (listaConocimientosAdicionales.Count != 0)
            {
                ViewData["IdConocimientosAdicionales"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(listaConocimientosAdicionales, "IdConocimientosAdicionales", "Descripcion");
                resultado = true;
            }

            return(resultado);
        }
Пример #19
0
        public async Task <IActionResult> Create(int id, string mensaje)
        {
            try
            {
                if (id != 0)
                {
                    //var respuesta = await apiServicio.SeleccionarAsync<Response>(id.ToString(), new Uri(WebApp.BaseAddress),
                    //                                              "api/CeseFunciones");

                    //if (respuesta.IsSuccess && respuesta.Resultado != null)
                    //{
                    //    respuesta.Resultado = JsonConvert.DeserializeObject<CeseFuncion>(respuesta.Resultado.ToString());
                    //    ViewData["IdTipoCesacionFuncion"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar<TipoCesacionFuncion>(new Uri(WebApp.BaseAddress), "api/TipoCesacionFunciones/ListarTipoCesacionFunciones"), "IdTipoCesacionFuncion", "Nombre");
                    //    return View(respuesta.Resultado);
                    //}
                    //else
                    //{

                    var empleadoEnviar = new Empleado
                    {
                        IdEmpleado = id,
                    };
                    var empleado = await apiServicio.ObtenerElementoAsync1 <EmpleadoSolicitudViewModel>(empleadoEnviar, new Uri(WebApp.BaseAddress), "api/Empleados/ObtenerDatosEmpleadoSeleccionado");

                    ViewData["IdTipoCesacionFuncion"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <TipoCesacionFuncion>(new Uri(WebApp.BaseAddress), "api/TipoCesacionFunciones/ListarTipoCesacionFunciones"), "IdTipoCesacionFuncion", "Nombre");
                    ViewData["NombresApellidos"]      = empleado.NombreApellido;
                    ViewData["Identificacion"]        = empleado.Identificacion;

                    var ceseFuncion = new CeseFuncion
                    {
                        IdEmpleado = id,
                    };
                    InicializarMensaje(mensaje);
                    return(View(ceseFuncion));
                    //}
                }



                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
Пример #20
0
        public async Task <IActionResult> Edit(string id, Sucursal sucursal)
        {
            entidades.Utils.Response response = new entidades.Utils.Response();
            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    response = await apiServicio.EditarAsync(id, sucursal, new Uri(WebApp.BaseAddress),
                                                             "api/Sucursal");

                    if (!response.IsSuccess)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                            EntityID             = string.Format("{0} : {1}", "Sistema", id),
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                            Message  = "Se ha actualizado un registro sistema",
                            UserName = "******"
                        });

                        return(RedirectToAction("Index"));
                    }
                    ViewData["IdCiudad"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <Ciudad>(new Uri(WebApp.BaseAddress), "api/Ciudad/ListarCiudad"), "IdCiudad", "Nombre");
                    //ViewData["Error"] = response.Message;
                    //return View(sucursal);
                    return(RedirectToAction("Index"));
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Editando una Sucursal",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
Пример #21
0
        public async Task OnGetAsync(string sortOrder)
        {
            pageNo       = 1;
            CustomerSort = String.IsNullOrEmpty(sortOrder) ? "customer" : "";
            DateSort     = sortOrder == "date" ? "date_desc" : "date";

            IQueryable <Desk> desks = from d in _context.Desk
                                      select d;

            switch (sortOrder)
            {
            case "customer":
                desks = desks.OrderBy(d => d.CustomerName);
                break;

            case "date":
                desks = desks.OrderBy(d => Convert.ToDateTime(d.Date));
                break;

            default:
                desks = desks.OrderBy(d => d.ID);
                break;
            }

            Desk = await desks.ToListAsync();

            // Use LINQ to get list of genres.
            IQueryable <string> customerQuery = from d in _context.Desk
                                                orderby d.CustomerName
                                                select d.CustomerName;



            if (!string.IsNullOrEmpty(CustomerName))
            {
                desks = desks.Where(x => x.CustomerName == CustomerName);
            }



            Customers = new SelectList(await customerQuery.Distinct().ToListAsync());
            Desk      = await desks.ToListAsync();

            deskToPageList = Desk.ToPagedList(pageNo, 5);
            NoOfPages      = deskToPageList.PageCount;
        }
Пример #22
0
        public async Task <IActionResult> Create(IndiceOcupacionalComportamientoObservable indiceOcupacionalComportamientoObservable)
        {
            Response response = new Response();

            try
            {
                response = await apiServicio.InsertarAsync(indiceOcupacionalComportamientoObservable,
                                                           new Uri(WebApp.BaseAddress),
                                                           "api/IndiceOcupacionalComportamientosObservables/InsertarIndiceOcupacionalComportamientoObservable");

                if (response.IsSuccess)
                {
                    var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                        ExceptionTrace       = null,
                        Message              = "Se ha creado un Rol de Brigada Salud y Seguridad Ocupacional",
                        UserName             = "******",
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                        EntityID             = string.Format("{0} {1}", "Rol de Brigada Salud y Seguridad Ocupacional:", indiceOcupacionalComportamientoObservable.IdIndiceOcupacionalComportamientoObservable),
                    });

                    return(RedirectToAction("Index"));
                }

                //ViewData["IdIndiceOcupacional"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar<IndiceOcupacional>(new Uri(WebApp.BaseAddress), "api/IndicesOcupacionales/ListarIndicesOcupacionales"), "IdIndiceOcupacional", "Nombre");
                ViewData["IdComportamientoObservable"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <ComportamientoObservable>(new Uri(WebApp.BaseAddress), "api/ComportamientosObservables/ListarComportamientosObservables"), "IdComportamientoObservable", "Nombre");
                return(View(indiceOcupacionalComportamientoObservable));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Creando Rol de Brigada Salud y Seguridad Ocupacional",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
Пример #23
0
        // GET: Patrones/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var patrones = await _context.Patrones.FindAsync(id);

            if (patrones == null)
            {
                return(NotFound());
            }
            ViewData["IdAutorPatron"]  = new SelectList(_context.AutorPatron, "IdAutorPatron", "NombreAutor", patrones.IdAutorPatron);
            ViewData["IdGenEdad"]      = new SelectList(_context.GeneroEdad, "IdGenEd", "GenEdad", patrones.IdGenEdad);
            ViewData["IdLana"]         = new SelectList(_context.Lanas, "IdLana", "NombreLana", patrones.IdLana);
            ViewData["IdPrendas"]      = new SelectList(_context.Prendas, "IdPrendas", "NombrePrendas", patrones.IdPrendas);
            ViewData["IdRevistas"]     = new SelectList(_context.Revistas, "IdRevistas", "NombreRevista", patrones.IdRevistas);
            ViewData["IdTiposCaract"]  = new SelectList(_context.TiposCaracteristicas, "IdTiposCaract", "NombreCaracteristicas", patrones.IdTiposCaract);
            ViewData["IdTiposdeTejer"] = new SelectList(_context.TiposDeTejer, "IdTiposTejer", "NombreDeTejer", patrones.IdTiposdeTejer);
            return(View(patrones));
        }
Пример #24
0
        public async Task <IActionResult> Edit(int id, [Bind("IdNombrePatron,NombrePatron,IdAutorPatron,IdLana,IdPrendas,IdRevistas,IdTiposCaract,IdTiposdeTejer,IdGenEdad,Patron")] Patrones patrones)
        {
            if (id != patrones.IdNombrePatron)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(patrones);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PatronesExists(patrones.IdNombrePatron))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdAutorPatron"]  = new SelectList(_context.AutorPatron, "IdAutorPatron", "IdAutorPatron", patrones.IdAutorPatron);
            ViewData["IdGenEdad"]      = new SelectList(_context.GeneroEdad, "IdGenEd", "IdGenEd", patrones.IdGenEdad);
            ViewData["IdLana"]         = new SelectList(_context.Lanas, "IdLana", "IdLana", patrones.IdLana);
            ViewData["IdPrendas"]      = new SelectList(_context.Prendas, "IdPrendas", "IdPrendas", patrones.IdPrendas);
            ViewData["IdRevistas"]     = new SelectList(_context.Revistas, "IdRevistas", "IdRevistas", patrones.IdRevistas);
            ViewData["IdTiposCaract"]  = new SelectList(_context.TiposCaracteristicas, "IdTiposCaract", "IdTiposCaract", patrones.IdTiposCaract);
            ViewData["IdTiposdeTejer"] = new SelectList(_context.TiposDeTejer, "IdTiposTejer", "NombreDeTejer", patrones.IdTiposdeTejer);
            return(View(patrones));
        }
 // GET: Executors/Create
 public IActionResult Create()
 {
     ViewData["TestatorID"] = new SelectList(_context.Testators, "ID", "Testator");
     return View();
 }
Пример #26
0
 // GET: Departments/Create
 public IActionResult Create()
 {
     ViewData["InstructorID"] = new SelectList(_context.Instructors.AsNoTracking(), "ID", "FullName");
     return View();
 }
        public async Task<IActionResult> Edit(int id, [Bind("Id,AppicationUserId,CateBlogId,Content,DateEdited,DatePosted,ImageUrl,IsDeleted,IsLocked,LikeNo,Status,Summary,TextSearch,Title,UrlSlug,UserId,ViewNo")] Blog blog)
        {
            if (id != blog.Id)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(blog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BlogExists(blog.Id))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction("Index");
            }
            ViewData["AppicationUserId"] = new SelectList(_context.Users, "Id", "Id", blog.AppicationUserId);
            ViewData["CateBlogId"] = new SelectList(_context.CategoryBlogs, "Id", "Description", blog.CateBlogId);
            return View(blog);
        }
        // GET: Blogs/Edit/5
        public async Task<IActionResult> Edit(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            var blog = await _context.Blogs.SingleOrDefaultAsync(m => m.Id == id);
            if (blog == null)
            {
                return NotFound();
            }
            ViewData["AppicationUserId"] = new SelectList(_context.Users, "Id", "UserName", blog.AppicationUserId);
            ViewData["CateBlogId"] = new SelectList(_context.CategoryBlogs, "Id", "Title", blog.CateBlogId);
            return View(blog);
        }
Пример #29
0
        public async Task<IActionResult> Edit(int id, [Bind("SwimmerId,Age,DateCreated,DateModified,DateOfBirth,FirstName,GenderId,LastName,LocationId,WallSwimmer")] Entities.Swimmer swimmer)
        {
            if (id != swimmer.SwimmerId)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(swimmer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SwimmerExists(swimmer.SwimmerId))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction("Index");
            }
            ViewData["GenderId"] = new SelectList(_context.Genders, "Id", "Gender", swimmer.GenderId);
            ViewData["LocationId"] = new SelectList(_context.Locations, "LocationId", "Location", swimmer.LocationId);
            return View(swimmer);
        }
 // GET: Blogs/Create
 public IActionResult Create()
 {
     ViewData["AppicationUserId"] = new SelectList(_context.Users, "Id", "UserName");
     ViewData["CateBlogId"] = new SelectList(_context.CategoryBlogs, "Id", "Title");
     return View();
 }
Пример #31
0
 public async Task<IActionResult> NuevoMensaje(Mensaje mensaje, List<string> Para, List<string> CopiaOculta)
 {
     if (ModelState.IsValid)
     {
         if (Para.Count() > 0 || CopiaOculta.Count() > 0)
         {
             if (await _servicioMensajeria.EnviarMensaje(mensaje, Para, CopiaOculta))
             {
                 ViewBag.MensajeExito = "Mensaje enviado";
                 _servicioMensajeria.EnviarEmails(Para, CopiaOculta); //todo enviar de forma asincrona
                 return View();
             }
         }
         else
         {
             ViewBag.MensajeError = $"Iiiioooo... sipote... selecciona a alguien pa' mandarle el mensaje, ¿no?";
         }                
     }
     else
     {
         ViewBag.MensajeError = $"Uppss... parece que los datos no son válidos";
     }
     SelectList personajes = new SelectList(await _servicioPersonajes.GetEnumeradoPersonajes(), "Id", "Descripcion");
     ViewBag.PersonajesPara = personajes;
     ViewBag.PersonajesCopiaOculta = personajes;
     ViewBag.Titulo = "Nuevo Mensaje";
     return View(mensaje);
 }
 // GET: Cards
 public IActionResult Index()
 {
     ViewData["CateId"] = new SelectList(_cateRepo.GetAll().Where(c=>c.Level==1), "Id", "Name");
     return View();
 }
Пример #33
0
 public async Task<IActionResult> ResponderMensaje(int id)
 {
     ApplicationUser usuario = await _servicioUsuarios.GetUser(User);
     ViewBag.Titulo = "Responder Mensaje";
     Mensaje mensaje = await _servicioMensajeria.GetMensaje(id);
     if (mensaje != null)
     {
         mensaje.MensajeId = 0;
         if (!mensaje.Asunto.Contains(" Re.: "))
         {
             mensaje.Asunto = " Re.: " + mensaje.Asunto;
         }
         mensaje.Cuerpo = "<p></p><p></p>[Enviador por " + mensaje.NombreAutentico + "]<p></p><blockquote>" +  mensaje.Cuerpo + "</blockquote>";
         SelectList personajesPara = new SelectList(await _servicioPersonajes.GetEnumeradoPersonajes(), "Id", "Descripcion");
         foreach (SelectListItem personajePara in personajesPara)
         {
             if (mensaje.Destinatarios.Any(d => d.TipoDestinatario == TipoDestinatario.Para && d.DestinatarioId == Convert.ToInt32(personajePara.Value)))
             {
                 personajePara.Selected = true;
             }                    
         }
         SelectList personajesCopiaOculta = new SelectList(await _servicioPersonajes.GetEnumeradoPersonajes(), "Id", "Descripcion");
         foreach (SelectListItem personajeCopiaOculta in personajesCopiaOculta)
         {
             if (mensaje.Destinatarios.Any(d => d.TipoDestinatario == TipoDestinatario.CopiaOculta && d.DestinatarioId == Convert.ToInt32(personajeCopiaOculta.Value)))
             {
                 personajeCopiaOculta.Selected = true;
             }
         }
         ViewBag.PersonajesPara = personajesPara;
         ViewBag.PersonajesCopiaOculta = personajesCopiaOculta;
         return View("NuevoMensaje", mensaje);
     }
     else
     {
         return RedirectToAction("AccessDenied", "Account");
     }
 }
Пример #34
0
        public async Task<IActionResult> Edit(int? id, byte[] rowVersion)
        {
            if (id == null)
            {
                return NotFound();
            }

            var departmentToUpdate = await _context.Departments.Include(i => i.Administrator).SingleOrDefaultAsync(m => m.DepartmentID == id);

            if (departmentToUpdate == null)
            {
                Department deletedDepartment = new Department();
                await TryUpdateModelAsync(deletedDepartment);
                ModelState.AddModelError(string.Empty,
                    "Unable to save changes. The department was deleted by another user.");
                ViewData["InstructorID"] = new SelectList(_context.Instructors, "ID", "FullName", departmentToUpdate.InstructorID);
                return View(deletedDepartment);
            }

            _context.Entry(departmentToUpdate).Property("RowVersion").OriginalValue = rowVersion;

            if (await TryUpdateModelAsync<Department>(
                departmentToUpdate,
                "",
                s => s.Name, s => s.StartDate, s => s.Budget, s => s.InstructorID))
            {
                try
                {
                    await _context.SaveChangesAsync();
                    return RedirectToAction("Index");
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    var exceptionEntry = ex.Entries.Single();
                    // Using a NoTracking query means we get the entity but it is not tracked by the context
                    // and will not be merged with existing entities in the context.
                    var databaseEntity = await _context.Departments
                        .AsNoTracking()
                        .SingleAsync(d => d.DepartmentID == ((Department)exceptionEntry.Entity).DepartmentID);
                    var databaseEntry = _context.Entry(databaseEntity);

                    var databaseName = (string)databaseEntry.Property("Name").CurrentValue;
                    var proposedName = (string)exceptionEntry.Property("Name").CurrentValue;
                    if (databaseName != proposedName)
                    {
                        ModelState.AddModelError("Name", $"Current value: {databaseName}");
                    }
                    var databaseBudget = (Decimal)databaseEntry.Property("Budget").CurrentValue;
                    var proposedBudget = (Decimal)exceptionEntry.Property("Budget").CurrentValue;
                    if (databaseBudget != proposedBudget)
                    {
                        ModelState.AddModelError("Budget", $"Current value: {databaseBudget:c}");
                    }
                    var databaseStartDate = (DateTime)databaseEntry.Property("StartDate").CurrentValue;
                    var proposedStartDate = (DateTime)exceptionEntry.Property("StartDate").CurrentValue;
                    if (databaseStartDate != proposedStartDate)
                    {
                        ModelState.AddModelError("StartDate", $"Current value: {databaseStartDate:d}");
                    }
                    var databaseInstructorID = (int)databaseEntry.Property("InstructorID").CurrentValue;
                    var proposedInstructorID = (int)exceptionEntry.Property("InstructorID").CurrentValue;
                    if (databaseInstructorID != proposedInstructorID)
                    {
                        Instructor databaseInstructor = await _context.Instructors.SingleAsync(i => i.ID == databaseInstructorID);
                        ModelState.AddModelError("InstructorID", $"Current value: {databaseInstructor.FullName}");
                    }

                    ModelState.AddModelError(string.Empty, "The record you attempted to edit "
                            + "was modified by another user after you got the original value. The "
                            + "edit operation was canceled and the current values in the database "
                            + "have been displayed. If you still want to edit this record, click "
                            + "the Save button again. Otherwise click the Back to List hyperlink.");
                    departmentToUpdate.RowVersion = (byte[])databaseEntry.Property("RowVersion").CurrentValue;
                    ModelState.Remove("RowVersion");
                }
            }
            ViewData["InstructorID"] = new SelectList(_context.Instructors, "ID", "FullName", departmentToUpdate.InstructorID);
            return View(departmentToUpdate);
        }
 // GET: Cards/Create
 public IActionResult Create()
 {
     ViewData["ApplycationUserId"] = new SelectList(_context.Users, "Id", "UserName");
     ViewData["CateId"] = new SelectList(_context.Categories, "Id", "Name");
     return View();
 }
Пример #36
0
        // GET: Departments/Edit/5
        public async Task<IActionResult> Edit(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            #region snippet_EagerLoading
            var department = await _context.Departments
                .Include(i => i.Administrator)
                .AsNoTracking()
                .SingleOrDefaultAsync(m => m.DepartmentID == id);
            #endregion
            if (department == null)
            {
                return NotFound();
            }
            ViewData["InstructorID"] = new SelectList(_context.Instructors.AsNoTracking(), "ID", "FullName", department.InstructorID);
            return View(department);
        }
Пример #37
0
        public async Task<IActionResult> GetStatesJson(
           string countryCode)
        {
            var country = await dataManager.FetchCountry(countryCode);
            List<IGeoZone> states;
            if (country != null)
            {
                states = await dataManager.GetGeoZonesByCountry(country.Id);
            }
            else
            {
                states = new List<IGeoZone>(); //empty list
            }

            var selecteList = new SelectList(states, "Code", "Name");

            return Json(selecteList);

        }
Пример #38
0
        public async Task ProcessAsyncInTemplate_WithItems_GeneratesExpectedOutput_DoesNotChangeSelectList(
            object model,
            Type containerType,
            Func<object> modelAccessor,
            NameAndId nameAndId,
            string expectedOptions)
        {
            // Arrange
            var originalAttributes = new TagHelperAttributeList
            {
                { "class", "form-control" },
            };
            var originalPostContent = "original content";

            var expectedAttributes = new TagHelperAttributeList(originalAttributes)
            {
                { "id", nameAndId.Id },
                { "name", nameAndId.Name },
                { "valid", "from validation attributes" },
            };
            var expectedPreContent = "original pre-content";
            var expectedContent = "original content";
            var expectedPostContent = originalPostContent + expectedOptions;
            var expectedTagName = "select";

            var metadataProvider = new TestModelMetadataProvider();

            var containerMetadata = metadataProvider.GetMetadataForType(containerType);
            var containerExplorer = metadataProvider.GetModelExplorerForType(containerType, model);

            var propertyMetadata = metadataProvider.GetMetadataForProperty(containerType, "Text");
            var modelExplorer = containerExplorer.GetExplorerForExpression(propertyMetadata, modelAccessor());

            var modelExpression = new ModelExpression(name: string.Empty, modelExplorer: modelExplorer);

            var tagHelperContext = new TagHelperContext(
                allAttributes: new TagHelperAttributeList(
                    Enumerable.Empty<TagHelperAttribute>()),
                items: new Dictionary<object, object>(),
                uniqueId: "test");
            var output = new TagHelperOutput(
                expectedTagName,
                originalAttributes,
                getChildContentAsync: (useCachedResult, encoder) =>
                {
                    var tagHelperContent = new DefaultTagHelperContent();
                    tagHelperContent.AppendHtml("Something");
                    return Task.FromResult<TagHelperContent>(tagHelperContent);
                })
            {
                TagMode = TagMode.SelfClosing,
            };
            output.PreContent.AppendHtml(expectedPreContent);
            output.Content.AppendHtml(expectedContent);
            output.PostContent.AppendHtml(originalPostContent);

            var htmlGenerator = new TestableHtmlGenerator(metadataProvider)
            {
                ValidationAttributes =
                {
                    {  "valid", "from validation attributes" },
                }
            };
            var viewContext = TestableHtmlGenerator.GetViewContext(model, htmlGenerator, metadataProvider);
            viewContext.ViewData.TemplateInfo.HtmlFieldPrefix = nameAndId.Name;

            var items = new SelectList(new[] { "", "outer text", "inner text", "other text" });
            var savedDisabled = items.Select(item => item.Disabled).ToList();
            var savedGroup = items.Select(item => item.Group).ToList();
            var savedSelected = items.Select(item => item.Selected).ToList();
            var savedText = items.Select(item => item.Text).ToList();
            var savedValue = items.Select(item => item.Value).ToList();
            var tagHelper = new SelectTagHelper(htmlGenerator)
            {
                For = modelExpression,
                Items = items,
                ViewContext = viewContext,
            };

            // Act
            tagHelper.Init(tagHelperContext);
            await tagHelper.ProcessAsync(tagHelperContext, output);

            // Assert
            Assert.Equal(TagMode.SelfClosing, output.TagMode);
            Assert.Equal(expectedAttributes, output.Attributes);
            Assert.Equal(expectedPreContent, output.PreContent.GetContent());
            Assert.Equal(expectedContent, output.Content.GetContent());
            Assert.Equal(expectedPostContent, HtmlContentUtilities.HtmlContentToString(output.PostContent));
            Assert.Equal(expectedTagName, output.TagName);

            Assert.Single(
                tagHelperContext.Items,
                entry => (Type)entry.Key == typeof(SelectTagHelper));

            Assert.Equal(savedDisabled, items.Select(item => item.Disabled));
            Assert.Equal(savedGroup, items.Select(item => item.Group));
            Assert.Equal(savedSelected, items.Select(item => item.Selected));
            Assert.Equal(savedText, items.Select(item => item.Text));
            Assert.Equal(savedValue, items.Select(item => item.Value));
        }
Пример #39
0
 public async Task<IActionResult> NuevoMensaje(Mensaje mensaje, List<string> Para, List<string> CopiaOculta)
 {
     if (ModelState.IsValid)
     {
         if (Para.Count() > 0 || CopiaOculta.Count() > 0)
         {                    
             ApplicationUser usuario = await _userManager.GetUserAsync(User);                    
             mensaje.RemitenteId = _servicioJugadores.GetPersonajeId(usuario.Id);
             if (!mensaje.EsAnonimo || (mensaje.EsAnonimo && _servicioPersonajes.PuedeHacerEnvioAnonimo(mensaje.RemitenteId)))
             {
                 if (await _servicioMensajeria.EnviarMensaje(mensaje, Para, CopiaOculta))
                 {
                     ViewBag.MensajeExito = "Mensaje enviado";
                     _servicioMensajeria.EnviarEmails(Para, CopiaOculta); //todo enviar de forma asincrona
                     return View();
                 }
             }
             else
             {
                 ViewBag.MensajeError = $"Uppss... esto es delicado. Parece que estás intentando mandar el mensaje como anónimo pero tu personaje no tiene las habilidades para ello";
             }
         }
         else
         {
             ViewBag.MensajeError = $"Iiiioooo... sipote... selecciona a alguien pa' mandarle el mensaje, ¿no?";
         }
     }
     else
     {
         ViewBag.MensajeError = $"Uppss... parece que los datos no son válidos";
     }
     SelectList personajes = new SelectList(await _servicioPersonajes.GetEnumeradoPersonajes(), "Id", "Descripcion");
     ViewBag.Personajes = personajes;
     return View(mensaje);
 }
Пример #40
0
        public async Task ProcessAsync_WithItems_AndNoModelExpression_GeneratesExpectedOutput()
        {
            // Arrange
            var originalAttributes = new TagHelperAttributeList
            {
                { "class", "form-control" },
            };
            var originalPostContent = "original content";

            var expectedAttributes = new TagHelperAttributeList(originalAttributes);
            var selectItems = new SelectList(Enumerable.Range(0, 5));
            var expectedOptions = "<option>HtmlEncode[[0]]</option>" + Environment.NewLine
                + "<option>HtmlEncode[[1]]</option>" + Environment.NewLine
                + "<option>HtmlEncode[[2]]</option>" + Environment.NewLine
                + "<option>HtmlEncode[[3]]</option>" + Environment.NewLine
                + "<option>HtmlEncode[[4]]</option>" + Environment.NewLine;

            var expectedPreContent = "original pre-content";
            var expectedContent = "original content";
            var expectedPostContent = originalPostContent + expectedOptions;
            var expectedTagName = "select";

            var tagHelperContext = new TagHelperContext(
                allAttributes: new TagHelperAttributeList(
                    Enumerable.Empty<TagHelperAttribute>()),
                items: new Dictionary<object, object>(),
                uniqueId: "test");
            var output = new TagHelperOutput(
                expectedTagName,
                originalAttributes,
                getChildContentAsync: (useCachedResult, encoder) =>
                {
                    var tagHelperContent = new DefaultTagHelperContent();
                    tagHelperContent.AppendHtml("Something");
                    return Task.FromResult<TagHelperContent>(tagHelperContent);
                })
            {
                TagMode = TagMode.SelfClosing,
            };
            output.PreContent.AppendHtml(expectedPreContent);
            output.Content.AppendHtml(expectedContent);
            output.PostContent.AppendHtml(originalPostContent);

            var metadataProvider = new TestModelMetadataProvider();
            var htmlGenerator = new TestableHtmlGenerator(metadataProvider);
            var viewContext = TestableHtmlGenerator.GetViewContext(
                model: null,
                htmlGenerator: htmlGenerator,
                metadataProvider: metadataProvider);

            var tagHelper = new SelectTagHelper(htmlGenerator)
            {
                Items = selectItems,
                ViewContext = viewContext,
            };

            // Act
            tagHelper.Init(tagHelperContext);
            await tagHelper.ProcessAsync(tagHelperContext, output);

            // Assert
            Assert.Equal(TagMode.SelfClosing, output.TagMode);
            Assert.Equal(expectedAttributes, output.Attributes);
            Assert.Equal(expectedPreContent, output.PreContent.GetContent());
            Assert.Equal(expectedContent, output.Content.GetContent());
            Assert.Equal(expectedPostContent, HtmlContentUtilities.HtmlContentToString(output.PostContent));
            Assert.Equal(expectedTagName, output.TagName);

            var kvp = Assert.Single(tagHelperContext.Items);
            Assert.Equal(typeof(SelectTagHelper), kvp.Key);
            Assert.Null(kvp.Value);
        }
Пример #41
0
 public async Task<IActionResult> NuevoMensaje()
 {
     SelectList personajes = new SelectList(await _servicioPersonajes.GetEnumeradoPersonajes(), "Id", "Descripcion");
     personajes.Append(new SelectListItem() { Value = "", Text = "" });
     ViewBag.Personajes = personajes;
     ApplicationUser usuario = await _userManager.GetUserAsync(User);
     int personajeId = _servicioJugadores.GetPersonajeId(usuario.Id);
     ViewBag.PuedeHacerEnvioAnonimo = _servicioPersonajes.PuedeHacerEnvioAnonimo(personajeId);
     return View();
 }