public async Task <Response> PostMotivoRecepcion([FromBody] MotivoRecepcion _motivoRecepcion) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var respuesta = Existe(_motivoRecepcion); if (!respuesta.IsSuccess) { db.MotivoRecepcion.Add(_motivoRecepcion); 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, }); } }
public async Task <IActionResult> Edit(string id, MotivoRecepcion motivoRecepcion) { Response response = new Response(); try { if (!string.IsNullOrEmpty(id)) { response = await apiServicio.EditarAsync(id, motivoRecepcion, new Uri(WebApp.BaseAddressRM), "api/MotivoRecepcion"); 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(motivoRecepcion)); } return(BadRequest()); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Editando un MotivoRecepcion", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public async Task <IActionResult> Create(MotivoRecepcion motivoRecepcion) { Response response = new Response(); try { response = await apiServicio.InsertarAsync(motivoRecepcion, new Uri(WebApp.BaseAddressRM), "api/MotivoRecepcion/InsertarMotivoRecepcion"); if (response.IsSuccess) { var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), ExceptionTrace = null, Message = "Se ha creado un MotivoRecepcion", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "MotivoRecepcion:", motivoRecepcion.IdMotivoRecepcion), }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(motivoRecepcion)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Creando MotivoRecepcion", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public Response Existe(MotivoRecepcion _motivoRecepcion) { var bdd = _motivoRecepcion.Descripcion.ToUpper().TrimEnd().TrimStart(); var loglevelrespuesta = db.MotivoRecepcion.Where(p => p.Descripcion.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 <Response> PutMotivoRecepcion([FromRoute] int id, [FromBody] MotivoRecepcion _motivoRecepcion) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var _motivoRecepcionActualizar = await db.MotivoRecepcion.Where(x => x.IdMotivoRecepcion == id).FirstOrDefaultAsync(); if (_motivoRecepcionActualizar != null) { try { _motivoRecepcionActualizar.Descripcion = _motivoRecepcion.Descripcion; _motivoRecepcionActualizar.RecepcionActivoFijo = _motivoRecepcion.RecepcionActivoFijo; db.MotivoRecepcion.Update(_motivoRecepcionActualizar); 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 }); } }