Beispiel #1
0
        // GET: Trabajador/Details/5
        public async Task <IActionResult> Details(string id)
        {
            try
            {
                if (id == null)
                {
                    return(NotFound());
                }
                Trabajador?trabajador;
                trabajador = await trabajadorRepository.GetByRut(id);

                if (trabajador == null)
                {
                    return(NotFound());
                }
                ViewBag.CantidadAlarmas = (await productoRepository.GetCantidadAlarmas()).Cantidad;
                if (trabajador.Foto != null)
                {
                    ViewData["img"] = string.Format(config["AWSS3:UrlUser"], trabajador.IdNegocio, trabajador.Rut);
                }
                return(View(trabajador));
            }
            catch (Exception e)
            {
                return(StatusCode((int)System.Net.HttpStatusCode.Unauthorized, e.Message));
                //return Unauthorized(e.Message);
            }
        }
Beispiel #2
0
        public async Task <IActionResult> RegisterAsync(TrabajadorRegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.TipoNegocio > 3 || model.TipoNegocio < 1)
            {
                ModelState.AddModelError(nameof(model.Correo), "El tipo de negocio es invalido.");
                return(View(model));
            }
            if ((await repositorioTrabajadores.GetByEmail(model.Correo)) != null)
            {
                ModelState.AddModelError(nameof(model.Correo), "El correo ingresado ya existe.");
                return(View(model));
            }
            else if ((await repositorioTrabajadores.GetByRut(model.Rut, true)) != null)
            {
                ModelState.AddModelError(nameof(model.Rut), "El rut ingresado ya existe.");
                return(View(model));
            }
            else if (string.IsNullOrWhiteSpace(model.Contrasena))
            {
                ModelState.AddModelError(nameof(model.Contrasena), "La contraseña no puede estar vacia.");
                return(View(model));
            }
            else if (string.IsNullOrWhiteSpace(model.Correo))
            {
                ModelState.AddModelError(nameof(model.Correo), "El correo no puede estar vacio.");
                return(View(model));
            }

            await repositorioTrabajadores.Registrar(model);

            return(LocalRedirect("~/Account/Login"));
        }