public async Task <Response> PostActivosFijosBaja([FromBody] ActivosFijosBaja activosFijosBaja)
        {
            try
            {
                ModelState.Remove("IdActivo");
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

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

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

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwRm),
                    ExceptionTrace       = ex,
                    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(ActivosFijosBaja ActivosFijosBaja)
        {
            Response response = new Response();
            try
            {
                response = await apiServicio.InsertarAsync(ActivosFijosBaja,
                                                             new Uri(WebApp.BaseAddressRM),
                                                             "api/ActivosFijosBaja/InsertarActivosFijosBaja");
                if (response.IsSuccess)
                {

                    var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName = Convert.ToString(Aplicacion.WebAppRM),
                        ExceptionTrace = null,
                        Message = "Se ha creado un ActivosFijosBaja",
                        UserName = "******",
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                        LogLevelShortName = Convert.ToString(LogLevelParameter.ADV),
                        EntityID = string.Format("{0} {1}", "ActivosFijosBaja:", ActivosFijosBaja.IdBaja),
                    });

                    return RedirectToAction("Index");
                }

                ViewData["Error"] = response.Message;
                return View(ActivosFijosBaja);

            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName = Convert.ToString(Aplicacion.WebAppRM),
                    Message = "Creando Activos Fijos de Baja",
                    ExceptionTrace = ex,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName = Convert.ToString(LogLevelParameter.ERR),
                    UserName = "******"
                });

                return BadRequest();
            }
        }
        public async Task<IActionResult> Edit(string id, ActivosFijosBaja ActivosFijosBaja)
        {
            Response response = new Response();
            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    response = await apiServicio.EditarAsync(id, ActivosFijosBaja, new Uri(WebApp.BaseAddressRM),
                                                                 "api/ActivosFijosBaja");

                    if (response.IsSuccess)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName = Convert.ToString(Aplicacion.WebAppRM),
                            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");
                    }

                }
                return BadRequest();
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName = Convert.ToString(Aplicacion.WebAppRM),
                    Message = "Editando un Activo Fijo de Baja",
                    ExceptionTrace = ex,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit),
                    LogLevelShortName = Convert.ToString(LogLevelParameter.ERR),
                    UserName = "******"
                });

                return BadRequest();
            }
        }
        public Response Existe(ActivosFijosBaja activosFijosBaja)
        {
            var bdd = activosFijosBaja.IdBaja;
            var loglevelrespuesta = db.ActivosFijosBaja.Where(p => p.IdBaja == bdd).FirstOrDefault();

            if (loglevelrespuesta != null)
            {
                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.ExisteRegistro,
                    Resultado = null,
                });
            }

            return(new Response
            {
                IsSuccess = false,
                Resultado = loglevelrespuesta,
            });
        }
        public async Task <Response> PutActivosFijosBaja([FromRoute] int id, [FromBody] ActivosFijosBaja activosFijosBaja)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido,
                    });
                }

                var activosFijosBajaActualizar = await db.ActivosFijosBaja.Where(x => x.IdBaja == id).FirstOrDefaultAsync();

                if (activosFijosBajaActualizar != null)
                {
                    try
                    {
                        activosFijosBajaActualizar.FechaBaja = activosFijosBaja.FechaBaja;
                        db.ActivosFijosBaja.Update(activosFijosBajaActualizar);
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwRm),
                            ExceptionTrace       = ex,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }



                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }