예제 #1
0
        public async Task <Response> PostConfirmacionLectura([FromBody] ConfirmacionLectura ConfirmacionLectura)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = ""
                    });
                }

                var respuesta = Existe(ConfirmacionLectura);
                if (!respuesta.IsSuccess)
                {
                    db.ConfirmacionLectura.Add(ConfirmacionLectura);
                    await db.SaveChangesAsync();

                    return(new Response
                    {
                        IsSuccess = true,
                        Message = Mensaje.Satisfactorio
                    });
                }

                return(new Response
                {
                    IsSuccess = false,
                    Message = "Existe una confirmación de lectura de igual información"
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex.Message,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Error,
                });
            }
        }
        public async Task <IActionResult> Create(ConfirmacionLectura confirmacionLectura)
        {
            Response response = new Response();

            try
            {
                response = await apiServicio.InsertarAsync(confirmacionLectura,
                                                           new Uri(WebApp.BaseAddress),
                                                           "api/ConfirmacionesLecturas/InsertarConfirmacionLectura");

                if (response.IsSuccess)
                {
                    var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                        ExceptionTrace       = null,
                        Message              = "Se ha creado un confirmación de lectura",
                        UserName             = "******",
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                        EntityID             = string.Format("{0} {1}", "Confirmación Lectura:", confirmacionLectura.IdConfirmacionLectura),
                    });

                    return(RedirectToAction("Index"));
                }

                ViewData["Error"] = response.Message;
                return(View(confirmacionLectura));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Creando Confirmación Lectura",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
예제 #3
0
        private Response Existe(ConfirmacionLectura ConfirmacionLectura)
        {
            var bdd = ConfirmacionLectura.IdEmpleado;
            var ConfirmacionLecturarespuesta = db.ConfirmacionLectura.Where(p => p.IdEmpleado == bdd).FirstOrDefault();

            if (ConfirmacionLecturarespuesta != null)
            {
                return(new Response
                {
                    IsSuccess = true,
                    Message = "Existe una confirmación de lecutra de igual información",
                    Resultado = null,
                });
            }

            return(new Response
            {
                IsSuccess = false,
                Resultado = ConfirmacionLecturarespuesta,
            });
        }