コード例 #1
0
        public async Task <IActionResult> Edit(string id, Subramo subramo)
        {
            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    var response = await apiServicio.EditarAsync(id, subramo, new Uri(WebApp.BaseAddressRM), "api/Subramo");

                    if (response.IsSuccess)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), EntityID = string.Format("{0} : {1}", "Subramo", id), LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), Message = "Se ha actualizado un registro Subramo", UserName = "******" });

                        return(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}"));
                    }
                    ViewData["Error"] = response.Message;
                    ViewData["Ramo"]  = new SelectList(await apiServicio.Listar <Ramo>(new Uri(WebApp.BaseAddressRM), "api/Ramo/ListarRamo"), "IdRamo", "Nombre");
                    return(View(subramo));
                }
                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.RegistroNoExiste}"));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Editando un Subramo", 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 <IActionResult> Create(Subramo subramo)
        {
            try
            {
                var response = await apiServicio.InsertarAsync(subramo, new Uri(WebApp.BaseAddressRM), "api/Subramo/InsertarSubramo");

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

                    return(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}"));
                }
                ViewData["Error"] = response.Message;
                ViewData["Ramo"]  = new SelectList(await apiServicio.Listar <Ramo>(new Uri(WebApp.BaseAddressRM), "api/Ramo/ListarRamo"), "IdRamo", "Nombre");
                return(View(subramo));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Creando Subramo", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" });

                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCrear}"));
            }
        }