public ActionResult EditPreAdvisor(PreAviso model) { getCookies(); if (ModelState.IsValid) { try { try { string path = ""; for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; var extension = Path.GetExtension(file.FileName).Replace(".", ""); var fileName = model.invoice; path = Path.Combine(RootUrl + "/preavisoFiles", fileName); try { System.IO.File.Delete(path); } catch { } /// Guardando el archivo if (ConfigurationManager.AppSettings["ExtensionsAllowed"].ToString().ToLower().Contains(extension.ToLower())) { try { file.SaveAs(path); } catch (Exception ex) { throw ex; } } else { ViewBag.ErrorMessage = "Ha Ocurrido un Error: Formato de archivo invalido, deben ser: " + ConfigurationManager.AppSettings["ExtensionsAllowed"].ToString().ToLower(); } } } catch (Exception ex) { ViewBag.ErrorMessage = "Ha Ocurrido un Error: " + ex.Message.ToString(); } PreAvisoManager um = new PreAvisoManager(); model.Weights = 0; model.usersId = userIdLogged; um.Update(model); ViewBag.SavedOk = "1"; return(RedirectToAction("Manage")); } catch (Exception ex) { ViewBag.ErrorMessage = "Ha Ocurrido un Error: Intente en unos momentos."; } } return(View(model)); }
public ActionResult AddPreavisos(PreAviso model) { getCookies(); if (ModelState.IsValid) { try { try { string path = ""; for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; var extension = Path.GetExtension(file.FileName).Replace(".", ""); var fileName = Guid.NewGuid().ToString() + "." + extension; model.invoice = fileName; path = Path.Combine(RootUrl + "/preavisoFiles", fileName); /// Guardando el archivo if (ConfigurationManager.AppSettings["ExtensionsAllowed"].ToString().ToLower().Contains(extension.ToLower())) { try { file.SaveAs(path); } catch (Exception ex) { throw ex; } } else { ViewBag.ErrorMessage = "Ha Ocurrido un Error: Formato de archivo invalido, deben ser: " + ConfigurationManager.AppSettings["ExtensionsAllowed"].ToString().ToLower(); } } } catch (Exception ex) { ViewBag.ErrorMessage = "Ha Ocurrido un Error: " + ex.Message.ToString(); } PreAvisoManager um = new PreAvisoManager(); model.Weights = 0; model.usersId = userIdLogged; um.Insert(model); ViewBag.SavedOk = "1"; string body = System.IO.File.ReadAllText(RootUrl + "/" + ConfigurationManager.AppSettings["PreAdvisor"].ToString()); body = string.Format(body, userEmail, model.tracking_code); SendEmail("Nueva PreAlerta Registrada", ConfigurationManager.AppSettings["AdminEmail"].ToString(), body, true); return(RedirectToAction("Manage")); } catch (Exception ex) { ViewBag.ErrorMessage = "Ha Ocurrido un Error: Intente en unos momentos."; } } return(View(model)); }
public ActionResult Deleteclaims(PreAviso model) { getCookies(); if (ModelState.IsValid) { try { PreAvisoManager um = new PreAvisoManager(); um.Delete(model); ViewBag.DeleteOk = "1"; return(RedirectToAction("Manage")); } catch { ViewBag.ErrorMessage = "Ha Ocurrido un Error: Intente en unos momentos."; } } return(RedirectToAction("Manage")); }
public ActionResult DeletePreAdvisor(PreAviso model) { getCookies(); if (ModelState.IsValid) { try { PreAvisoManager um = new PreAvisoManager(); model.Weights = 0; model.usersId = userIdLogged; um.Delete(model); ViewBag.DeleteOk = "1"; return(RedirectToAction("Manage")); } catch (Exception ex) { ViewBag.ErrorMessage = "Ha Ocurrido un Error: Intente en unos momentos."; } } return(View(model)); }