コード例 #1
0
        public async Task <IActionResult> Create(CompaniaSeguro companiaSeguro, List <IFormFile> file)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var response = await apiServicio.InsertarAsync(companiaSeguro, new Uri(WebApp.BaseAddressRM), "api/CompaniaSeguro/InsertarCompaniaSeguro");

                    if (response.IsSuccess)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), ExceptionTrace = null, Message = "Se ha creado una Compañía de Seguro", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "Compañía de Seguro:", companiaSeguro.IdCompaniaSeguro) });

                        return(await GestionarInformacionAdicional(response, file));
                    }
                    ViewData["Error"] = response.Message;
                }
                else
                {
                    ViewData["Error"] = Mensaje.ModeloInvalido;
                }
                return(View(companiaSeguro));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Creando Compañía de Seguro", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" });

                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCrear}"));
            }
        }
コード例 #2
0
        public async Task <IActionResult> Edit(string id, CompaniaSeguro companiaSeguro, List <IFormFile> file)
        {
            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    if (ModelState.IsValid)
                    {
                        var response = await apiServicio.EditarAsync(id, companiaSeguro, new Uri(WebApp.BaseAddressRM), "api/CompaniaSeguro");

                        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(await GestionarInformacionAdicional(response, file));
                        }
                        ViewData["Error"] = response.Message;
                    }
                    else
                    {
                        ViewData["Error"] = Mensaje.ModeloInvalido;
                    }
                    return(View(nameof(Edit), companiaSeguro));
                }
                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.RegistroNoExiste}"));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Editando una Compañía de Seguro", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" });

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