public async Task <IActionResult> Edit(string id, MotivoTransferencia motivoTransferencia)
        {
            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    var response = await apiServicio.EditarAsync(id, motivoTransferencia, new Uri(WebApp.BaseAddressRM), "api/MotivoTransferencia");

                    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(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}"));
                    }
                    ViewData["Error"] = response.Message;
                    return(View(motivoTransferencia));
                }
                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.RegistroNoExiste}"));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Editando un MotivoTransferencia", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" });

                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorEditar}"));
            }
        }
예제 #2
0
        public async Task <Response> PostMotivoTransferencia([FromBody] MotivoTransferencia _motivoTransferencia)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

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

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

                return(new Response
                {
                    IsSuccess = false,
                    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,
                });
            }
        }
예제 #3
0
        public async Task <IActionResult> Edit(string id, MotivoTransferencia motivoTransferencia)
        {
            Response response = new Response();

            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    response = await apiServicio.EditarAsync(id, motivoTransferencia, new Uri(WebApp.BaseAddressRM),
                                                             "api/MotivoTransferencia");

                    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"));
                    }
                    ViewData["Error"] = response.Message;
                    return(View(motivoTransferencia));
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppRM),
                    Message              = "Editando un MotivoTransferencia",
                    ExceptionTrace       = ex,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
예제 #4
0
        public async Task <IActionResult> Create(MotivoTransferencia motivoTransferencia)
        {
            Response response = new Response();

            try
            {
                response = await apiServicio.InsertarAsync(motivoTransferencia,
                                                           new Uri(WebApp.BaseAddressRM),
                                                           "api/MotivoTransferencia/InsertarMotivoTransferencia");

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

                    return(RedirectToAction("Index"));
                }

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

                return(BadRequest());
            }
        }
예제 #5
0
        public Response Existe(MotivoTransferencia _motivoTransferencia)
        {
            var bdd = _motivoTransferencia.Motivo_Transferencia.ToUpper().TrimEnd().TrimStart();
            var loglevelrespuesta = db.MotivoTransferencia.Where(p => p.Motivo_Transferencia.ToUpper().TrimStart().TrimEnd() == 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 <IActionResult> Create(MotivoTransferencia motivoTransferencia)
        {
            try
            {
                var response = await apiServicio.InsertarAsync(motivoTransferencia, new Uri(WebApp.BaseAddressRM), "api/MotivoTransferencia/InsertarMotivoTransferencia");

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

                    return(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}"));
                }
                ViewData["Error"] = response.Message;
                return(View(motivoTransferencia));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Creando MotivoTransferencia", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" });

                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCrear}"));
            }
        }
예제 #7
0
        public async Task <Response> PutMotivoTransferencia([FromRoute] int id, [FromBody] MotivoTransferencia _motivoTransferencia)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var _motivoTransferenciaActualizar = await db.MotivoTransferencia.Where(x => x.IdMotivoTransferencia == id).FirstOrDefaultAsync();

                if (_motivoTransferenciaActualizar != null)
                {
                    try
                    {
                        _motivoTransferenciaActualizar.Motivo_Transferencia = _motivoTransferencia.Motivo_Transferencia;

                        db.MotivoTransferencia.Update(_motivoTransferenciaActualizar);
                        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
                });
            }
        }