Пример #1
0
        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));
        }
Пример #2
0
 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));
 }
Пример #3
0
 public ActionResult DeletePreAdvisor(string tracking_code, int user_id)
 {
     try
     {
         getCookies();
         PreAvisoManager um    = new PreAvisoManager();
         var             model = um.GetPreAdvisorById(user_id, tracking_code);
         if (model != null)
         {
             return(View(model));
         }
     }
     catch
     {
     }
     return(RedirectToAction("Manage"));
 }
Пример #4
0
        public ActionResult Concludas()
        {
            ViewBag.PackageTitles = "Preavisos Concluidos Entregados";
            getCookies();
            PreAvisoManager pk     = new PreAvisoManager();
            var             result = pk.GetPreAdvisor(userIdLogged, 2);

            if (result == null || result.Count == 0)
            {
                ViewBag.NotPackage = "1";
                return(View(result));
            }
            else
            {
                return(View("Manage", result));
            }
        }
Пример #5
0
        public ActionResult Manage()
        {
            ViewBag.PackageTitles = "Preavisos Creados Pendientes";
            getCookies();
            PreAvisoManager pk     = new PreAvisoManager();
            var             result = pk.GetPreAdvisor(userIdLogged, 1);

            if (result == null || result.Count == 0)
            {
                ViewBag.NotPackage = "1";
                return(View(result));
            }
            else
            {
                return(View(result));
            }
        }
Пример #6
0
 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"));
 }
Пример #7
0
 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));
 }