Пример #1
0
        public ActionResult AutocompleteEmpleado()
        {
            List <EmployeeViewModel> lstEmp   = new List <EmployeeViewModel>();
            EmployeeViewModel        empModel = null;

            try
            {
                var serviceNomina = GetService.nominaService;
                var lstEmployees  = serviceNomina.GetEmpleados();

                foreach (var emp in lstEmployees)
                {
                    empModel = new EmployeeViewModel();
                    empModel.CopyPropertiesFrom(emp);
                    lstEmp.Add(empModel);
                }

                var empData = lstEmp
                              .OrderBy(o => o.Nombre)
                              .Select(miniEmp => new { nombre = miniEmp.Id.ToString() + " - " + miniEmp.Nombre + " [" + miniEmp.getDescripcionRol() + "]" });

                return(Json(empData, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { isWarning = false, isSuccess = false, msj = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #2
0
        // GET: Employee/Edit/5
        public ActionResult Edit(int id)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    EmployeeViewModel empModel = new EmployeeViewModel();
                    var serviceNomina          = GetService.nominaService;
                    var emple = serviceNomina.GetEmpleado(new Service.Employee()
                    {
                        Id = id
                    });
                    empModel.CopyPropertiesFrom(emple);

                    return(View(empModel));
                }
                catch (Exception ex)
                {
                    return(Json(new { isError = true, isWarning = false, isSuccess = false, msj = ex.Message }));
                }
            }
            else
            {
                return(Json(new { isError = false, isWarning = true, isSuccess = false, msj = Errors.getModelError(ModelState) }));
            }
        }
Пример #3
0
        // GET: Employee
        public ActionResult Index()
        {
            List <EmployeeViewModel> lstEmp   = new List <EmployeeViewModel>();
            EmployeeViewModel        empModel = null;

            try
            {
                var serviceNomina = GetService.nominaService;
                var lstEmployees  = serviceNomina.GetEmpleados();

                foreach (var emp in lstEmployees)
                {
                    empModel = new EmployeeViewModel();
                    empModel.CopyPropertiesFrom(emp);
                    lstEmp.Add(empModel);
                }
            }
            catch (Exception ex)
            {
                return(Json(new { isWarning = false, isSuccess = false, msj = ex.Message }, JsonRequestBehavior.AllowGet));
            }

            return(View(lstEmp));
        }