public FormPage(Visita visita) { InitializeComponent(); this._visita = visita; viewmodel = new InformeViewModel(); BindingContext = viewmodel; }
public ActionResult Crear(InformeViewModel model, FormCollection collection) { var pdfUrl = ""; try { HttpPostedFileBase pdf = Request.Files["Pdf"]; if (pdf != null && pdf.ContentLength > 0) { pdfUrl = CargarPdf(pdf); } else { pdfUrl = ""; } _informesManager.Crear(Convert.ToInt32(TempData["venta_id"]), model.Nombre, pdfUrl.Trim(), model.Fecha); TempData.Keep(); TempData["FlashSuccess"] = MensajesResource.INFO_Informes_CreadoCorrectamente; //return RedirectToAction("Index"); return(RedirectToAction("Index", "AdministrarInformes", new { @id = TempData["venta_id"] })); } catch (BusinessException businessEx) { ModelState.AddModelError(string.Empty, businessEx.Message); return(RedirectToAction("Index", "AdministrarInformes", new { @id = TempData["venta_id"] })); } catch (Exception e) { var log = CommonManager.BuildMessageLog( TipoMensaje.Error, ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(), ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(), e.ToString(), Request); CommonManager.WriteAppLog(log, TipoMensaje.Error); ModelState.AddModelError(string.Empty, e.Message); return(RedirectToAction("Index", "AdministrarInformes", new { @id = TempData["venta_id"] })); } }
public ActionResult Editar(int id) { var informes = _informesManager.Find(id); var mantenimiento = _informesManager.GetInforme(id); var venta = _ventasManager.Find(id); ViewBag.obra = _obrasManager.Find(venta.IdObra); ViewBag.Informes = _informesManager.GetInformes(id); if (informes == null) { // TempData["FlashError"] = MensajesResource.ERROR_MensajesInstitucionales_IdIncorrecto; return(RedirectToAction("Index")); } if (informes.Nombre == null) { informes.Nombre = "null"; } if (informes.Url == null) { informes.Url = "null"; } if (informes.Fecha == null) { informes.Fecha = DateTime.Now; } var informeModel = new InformeViewModel() { Nombre = informes.Nombre, Url = informes.Url, Fecha = informes.Fecha.ToString(), }; return(View(informeModel)); }
public ActionResult Editar(int id, InformeViewModel model) { var informe = _informesManager.Find(id); var pdfUrl = ""; var mantenimiento = _informesManager.GetInforme(id); var venta = _ventasManager.Find(id); ViewBag.obra = _obrasManager.Find(venta.IdObra); ViewBag.Informes = _informesManager.GetInformes(id); if (informe.Nombre == null) { informe.Nombre = "null"; } if (informe.Url == null) { informe.Url = "null"; } if (informe.Fecha == null) { informe.Fecha = DateTime.Now; } if (informe == null) { //TempData["FlashError"] = MensajesResource.ERROR_MensajesInstitucionales_IdIncorrecto; return(RedirectToAction("Index")); } try { HttpPostedFileBase pdf = Request.Files["Pdf"]; if (pdf != null && pdf.ContentLength > 0) { pdfUrl = CargarPdf(pdf); } else { pdfUrl = informe.Url; } _informesManager.Actualizar(Convert.ToInt32(TempData["IDVENTA"]), id, model.Nombre, pdfUrl.Trim(), model.Fecha); TempData.Keep(); TempData["FlashSuccess"] = MensajesResource.INFO_Informes_ActualizadoCorrectamente; return(RedirectToAction("Index", "AdministrarInformes", new { @id = TempData["IDVENTA"] })); } catch (BusinessException businessEx) { ModelState.AddModelError(string.Empty, businessEx.Message); return(View(model)); } catch (Exception e) { var log = CommonManager.BuildMessageLog( TipoMensaje.Error, ControllerContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(), ControllerContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(), e.ToString(), Request); CommonManager.WriteAppLog(log, TipoMensaje.Error); return(View(model)); } }