public async Task <IHttpActionResult> PutRechazarSupervisor([FromBody] AprobacionModel model)
        {
            IdentityUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            var supervisorModel = supervisorService.GetSingle(c => c.SV_ID_SUPERVISOR == model.id);

            if (supervisorModel != null)
            {
                supervisorModel.SV_USUARIO_MOD = user.Id;
                supervisorModel.SV_FECHA_MOD   = DateTime.Now.Date;

                supervisorModel.SV_FECHA_APROBACION  = DateTime.Now.Date;
                supervisorModel.SV_USUARIO_APROBADOR = user.Id;

                if (supervisorModel.SV_ESTATUS == Convert.ToInt16(RegistryStateModel.RegistryState.Pendiente))
                {
                    supervisorModel.SV_ESTATUS = Convert.ToInt16(RegistryStateModel.RegistryState.Eliminado);
                }
                else
                {
                    supervisorModel.SV_ESTATUS = Convert.ToInt16(RegistryStateModel.RegistryState.Aprobado);
                }

                //supervisorModel.SV_ESTATUS = Convert.ToInt16(RegistryStateModel.RegistryState.Aprobado);
                supervisorService.Update(supervisorModel);
                var supervisorTempModel = supervisorTempService.GetSingle(c => c.SV_ID_SUPERVISOR == model.id);
                supervisorTempModel = MappingTempFromSupervisor(supervisorTempModel, supervisorModel);

                supervisorTempService.Update(supervisorTempModel);
                return(Ok("El supervisor ha sido rechazado."));
            }
            return(BadRequest("No se encontraron datos para actualizar."));
        }
        public async Task <IHttpActionResult> PutAprobarParametro([FromBody] AprobacionModel model)
        {
            IdentityUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            var tempModel = supervisorTempService.GetSingle(c => c.SV_ID_SUPERVISOR == model.id);

            int estadoAprobado = Convert.ToInt32(RegistryStateModel.RegistryState.Aprobado);
            var listSupervisor = supervisorService.GetAll(c => c.CE_ID_EMPRESA == tempModel.CE_ID_EMPRESA &&
                                                          c.SV_ID_AREA == tempModel.SV_ID_AREA &&
                                                          c.SV_ESTATUS == estadoAprobado &&
                                                          c.SV_COD_SUPERVISOR == tempModel.SV_COD_SUPERVISOR, null, includes: c => c.SAX_EMPRESA);

            if (listSupervisor != null & listSupervisor.Count > 0)
            {
                return(BadRequest("Supervisor duplicado, por favor rechazar."));
            }

            if (tempModel != null)
            {
                tempModel.SV_FECHA_APROBACION  = DateTime.Now.Date;
                tempModel.SV_ESTATUS           = Convert.ToInt16(RegistryStateModel.RegistryState.Aprobado);
                tempModel.SV_USUARIO_APROBADOR = user.Id;
                supervisorTempService.Update(tempModel);
                SupervisorModel supervisor = new SupervisorModel();
                supervisor = MappingSupervisorFromTemp(supervisor, tempModel);

                supervisorService.Update(supervisor);
                return(Ok("El supervisor ha sido aprobado."));
            }
            return(BadRequest("No se encontraron datos para actualizar."));
        }
        public async Task <IHttpActionResult> PutRechazarParametro([FromBody] AprobacionModel model)
        {
            IdentityUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            var paramModel = paramService.GetSingle(c => c.PA_ID_PARAMETRO == model.id);

            if (paramModel != null)
            {
                paramModel.PA_USUARIO_MOD = user.Id;
                paramModel.PA_FECHA_MOD   = DateTime.Now.Date;
                paramModel.PA_ESTATUS     = Convert.ToInt16(RegistryStateModel.RegistryState.Aprobado);
                paramService.Update(paramModel);
                var paramTemp = paramTempService.GetSingle(c => c.PA_ID_PARAMETRO == model.id);
                paramTemp = MappingTempFromParam(paramTemp, paramModel);

                paramTempService.Update(paramTemp);
                return(Ok("El parĂ¡metro ha sido rechazado."));
            }
            return(BadRequest("No se encontraron datos para actualizar."));
        }
        public async Task <IHttpActionResult> PutAprobarParametro([FromBody] AprobacionModel model)
        {
            IdentityUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            var tempModel = paramTempService.GetSingle(c => c.PA_ID_PARAMETRO == model.id);

            if (tempModel != null)
            {
                tempModel.PA_FECHA_APROBACION  = DateTime.Now.Date;
                tempModel.PA_ESTATUS           = Convert.ToInt16(RegistryStateModel.RegistryState.Aprobado);
                tempModel.PA_USUARIO_APROBADOR = user.Id;
                paramTempService.Update(tempModel);
                ParametroModel param = new ParametroModel();
                param = MappingParamFromTemp(param, tempModel);

                paramService.Update(param);
                return(Ok("El parĂ¡metro ha sido aprobado."));
            }
            return(BadRequest("No se encontraron datos para actualizar."));
        }