Exemplo n.º 1
0
        public ActionResult deleteClaim(Guid id, string searchText)
        {
            List <Claim> list = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                var claim = dc.Claims.Where(c => c.ClaimId == id).SingleOrDefault();



                claim.isDeleted = true;
                dc.SaveChanges();

                list = dc.Claims
                       .Include("AirPorts")
                       .Include("User")
                       .Include("Documents")
                       .Where(c =>
                              (searchText == "" ||
                               c.FlightNumber.ToLower().Contains(searchText) ||
                               c.AirCompany.Contains(searchText) ||
                               c.User.FirstName.Contains(searchText) ||
                               c.User.LastName.Contains(searchText) ||
                               c.AirPorts.Any(a => a.FlightNumber.Contains(searchText) || a.country.Contains(searchText))) &&
                              c.isDeleted == false &&
                              c.Type != ProblemType.Pending)
                       .Select(c => c)
                       .OrderByDescending(c => c.DateCreated)
                       .ToList();
            }
            return(PartialView("_partialClaim", list));
        }
Exemplo n.º 2
0
        public static VMUser SyncUserToDatabase(VMUser user)
        {
            user.PictureUrl = user.PictureUrl ?? "";
            user.FirstName  = user.FirstName ?? "";
            user.LastName   = user.LastName ?? "";
            user.Email      = user.Email ?? "";
            user.Role       = user.Role ?? "";

            using (AirHelpDBContext context = new AirHelpDBContext())
            {
                var userDB = context.Users.Where(u => u.UserId == user.UserId).SingleOrDefault();
                if (userDB != null)
                {
                    user.Role = userDB.Role;
                    return(user);
                }
                user.Role = "";
                var newUserBD = new User()
                {
                    UserId     = user.UserId,
                    FirstName  = user.FirstName,
                    LastName   = user.LastName,
                    Email      = user.Email,
                    PictureUrl = user.PictureUrl,
                    CreateDate = DateTime.Now,
                    Role       = user.Role
                };

                context.Users.Add(newUserBD);
                context.SaveChanges();
                return(user);
            }
        }
Exemplo n.º 3
0
        public ActionResult ClaimListSearcg(string searchText)
        {
            var          isAdmin = User.IsInRole("admin");
            List <Claim> list    = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                list = dc.Claims
                       .Include("AirPorts")
                       .Include("User")
                       .Include("Documents")
                       .Where(c =>
                              (searchText == "" ||
                               c.FlightNumber.ToLower().Contains(searchText) ||
                               c.AirCompany.Contains(searchText) ||
                               c.User.FirstName.Contains(searchText) ||
                               c.User.LastName.Contains(searchText) ||
                               c.AirPorts.Any(a => a.FlightNumber.Contains(searchText) || a.country.Contains(searchText))) &&
                              c.isDeleted == false &&
                              c.Type != ProblemType.Pending)
                       .Select(c => c)
                       .OrderByDescending(c => c.DateCreated)
                       .ToList();
            }
            return(PartialView("_partialClaim", list));
        }
Exemplo n.º 4
0
        public ActionResult LoginPost(string claimId)
        {
            var ReturnUrl = Request.QueryString["ReturnUrl"];
            var Email     = Request.Form["Email"];
            var Password  = Request.Form["Password"];

            if (ReturnUrl == null)
            {
                ReturnUrl = "/";
            }

            string hashPassword = GetHash(Password);

            User user = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                user = dc.Users.Where(u => u.Email == Email && u.password == hashPassword).SingleOrDefault();

                if (user == null)
                {
                    ViewBag.error = "Грешно потребителско име или парола";
                    return(View("Login"));
                }

                if (claimId != null)
                {
                    var ClaimId = Guid.Parse(claimId);
                    var claim   = dc.Claims.Where(c => c.ClaimId == ClaimId).SingleOrDefault();
                    claim.UserId = user.UserId;
                    dc.SaveChanges();
                }
            }


            var VMuser = new VMUser()
            {
                UserId     = user.UserId,
                FirstName  = user.FirstName,
                LastName   = user.LastName,
                Email      = user.Email,
                PictureUrl = user.PictureUrl,
                Role       = user.Role
            };

            Session["user"] = user;

            FormsAuthenticationTicket authTicket =
                new FormsAuthenticationTicket(1, user.UserId, DateTime.Now, DateTime.Now.AddMinutes(200), true, user.Role, "/");
            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
                                               FormsAuthentication.Encrypt(authTicket));

            Response.Cookies.Add(cookie);

            if (claimId != null)
            {
                return(Redirect($"/потвърждение-на-иск/{claimId}"));
            }
            return(Redirect(ReturnUrl));
        }
Exemplo n.º 5
0
        public ActionResult GdprData(string userid)
        {
            var userEmail = "";

            if (User.IsInRole("admin") && !string.IsNullOrEmpty(userid))
            {
                userEmail = Server.UrlDecode(userid).Replace("2334", ".").Replace("2374", "-");
            }
            else
            {
                userEmail = User.Identity.Name;
            }

            ViewBag.error = false;
            User user = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                user = dc.Users
                       .Include("claims")
                       .Include("claims.documents")
                       .Where(u => u.Email == userEmail)
                       .SingleOrDefault();

                var doc = user.Claims.Select(c => c.Documents);
                return(View("GDPR", user));
            }

            return(View("GDPR", null));
        }
Exemplo n.º 6
0
        public ActionResult ClaimUpdate(Guid id)
        {
            Claim claim = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                claim = dc.Claims.Where(c => c.ClaimId == id).SingleOrDefault();

                var password  = Request.Form["password"];
                var newUserBD = new User()
                {
                    UserId     = claim.User.Email,
                    FirstName  = claim.User.FirstName,
                    LastName   = claim.User.LastName,
                    Email      = claim.User.Email,
                    password   = GetHash(password),
                    PictureUrl = "",
                    CreateDate = DateTime.Now,
                    Role       = "user"
                };

                dc.Users.Add(newUserBD);
                claim.UserId = newUserBD.UserId;
                dc.SaveChanges();
            }

            return(Redirect($"/обезщетение-списък/{claim.ClaimId}"));
        }
Exemplo n.º 7
0
        public ActionResult ForgottenPasswordPP(string code)
        {
            var Password = Request.Form["Password"];

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                var user = dc.Users.Where(u => code != null && u.changePasswordCode == code).SingleOrDefault();

                if (user == null)
                {
                    ViewBag.text = "Невалидан линк";
                    return(View("Success"));
                }

                if (user != null && DateTime.Now > user.changePasswordCodeValudation)
                {
                    ViewBag.text = "Линка е с изтекла валидност";
                    return(View("Success"));
                }

                Password                = GetHash(Password);
                user.password           = Password;
                user.changePasswordCode = null;
                dc.SaveChanges();

                ViewBag.text = "Паролата е зададена успешно";
                return(View("Success"));
            }

            return(View("ForgottenPasswordP"));
        }
Exemplo n.º 8
0
        public ActionResult ChangePasswordPost()
        {
            var    oldPassword  = Request.Form["oldPassword"];
            var    Password     = Request.Form["Password"];
            string hashPassword = GetHash(oldPassword);

            User user = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                user = dc.Users.Where(u => u.Email == User.Identity.Name).SingleOrDefault();


                if (user.password != hashPassword)
                {
                    ViewBag.error = true;
                    return(View("ChangePassword"));
                }
                else
                {
                    user.password = GetHash(Password);
                    dc.SaveChanges();
                    ViewBag.text = "Паролата Ви е сменена успешно";
                    return(View("Success"));
                }
            }
            return(View("Success"));
        }
Exemplo n.º 9
0
        public ActionResult ContractPdf(Guid id)
        {
            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                var userID  = User.Identity.Name;
                var isAdmin = User.IsInRole("admin");
                var claim   = dc.Claims.Include("User").Where(c => c.ClaimId == id && (isAdmin || c.UserId == userID)).SingleOrDefault();
                if (claim == null)
                {
                    ViewBag.text = "защитена информация";
                    return(View("Views/Login/Success.cshtml"));
                }
            }
            string port = Request.Url.Port == 80 ? string.Empty : $":{Request.Url.Port.ToString()}";

            String url = $"{Request.Url.Scheme}://{Request.Url.Host}{port}/contractPdf-09-4565-3453-2345435-2355/{id}";

            SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf();

            converter.Options.MarginTop    = 30;
            converter.Options.MarginBottom = 10;
            converter.Options.MarginLeft   = 20;
            converter.Options.MarginRight  = 20;
            converter.Options.PdfPageSize  = SelectPdf.PdfPageSize.A4;

            SelectPdf.PdfDocument doc = converter.ConvertUrl(url);

            Response.ContentType = "application/pdf";
            doc.Save(Response.OutputStream);
            doc.Close();
            Response.End();
            return(null);
        }
Exemplo n.º 10
0
        public string data()
        {
            return("");

            string result = "";

            string[] lines = System.IO.File.ReadAllLines("D:\\AirHelp\\Data\\airports1.csv");

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                int i = 1;
                foreach (string r in lines)
                {
                    var             arr = r.Split(',');
                    DAL.AirPortData air = dc.AirPortsData.Create();
                    if (r.Contains("medium_airport") /*|| r.Contains("large_airport")*/)
                    {
                        try
                        {
                            air.name        = arr[3].Trim('"').Trim('\\').Trim('"');
                            air.city        = arr[10].Trim('"').Trim('\\').Trim('"');
                            air.country     = arr[8].Trim('"').Trim('\\').Trim('"');
                            air.countryCode = arr[8].Trim('"').Trim('\\').Trim('"');
                            air.x           = double.Parse(arr[5]);
                            air.y           = double.Parse(arr[4]);
                            double e = 0;
                            double.TryParse(arr[6], out e);
                            air.elevation = e;
                            air.iata      = arr[13].Trim('"').Trim('\\').Trim('"');
                            air.timezone  = 0;
                            air.url       = arr[15].Trim('"').Trim('\\').Trim('"');
                            if (air.name.Length > 90 || air.iata.Length > 4)
                            {
                                continue;
                            }
                            dc.AirPortsData.Add(air);
                        }
                        catch (Exception ex)
                        {
                            continue;
                        }


                        try
                        {
                            dc.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            continue;
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 11
0
        public static object GetAirport(string text)
        {
            var result = "";

            if (ConfigurationManager.AppSettings["useLocalData"].ToString() == "true")
            {
                using (AirHelpDBContext dc = new AirHelpDBContext())
                {
                    var airport = dc.AirPortsData.Where(a => a.name.StartsWith(text) || a.city.StartsWith(text) || a.country.StartsWith(text) || a.iata.StartsWith(text)).Select(a => new Airportss {
                        apid      = a.Id.ToString(),
                        iata      = a.iata,
                        city      = a.city,
                        country   = a.country,
                        name      = a.name,
                        ap_name   = a.name,
                        x         = a.x.ToString(),
                        y         = a.y.ToString(),
                        elevation = a.elevation.ToString()
                    });
                    var resultData = new ResultAirportData()
                    {
                        status = 0
                    };

                    resultData.airports = airport.ToArray();
                    resultData.status   = airport.Count() > 0 ? 1 : 0;


                    return(resultData);
                }
            }
            else
            {
                var url    = "https://openflights.org/php/apsearch.php";
                var values = new Dictionary <string, string>
                {
                    { "name", text },
                    { "country", "ALL" },
                    { "action", "SEARCH" },
                    { "offset", "0" }
                };

                var content = new FormUrlEncodedContent(values);

                var response = client.PostAsync(url, content).Result;

                if (response.IsSuccessStatusCode)
                {
                    var responseContent = response.Content;

                    result = responseContent.ReadAsStringAsync().Result;
                }
            }
            return(result);
        }
Exemplo n.º 12
0
        public ActionResult RegisterUserToClaim()
        {
            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                var claimId   = Guid.Parse(Request.Form["claimId"]);
                var FirstName = Request.Form["FirstName"];
                var LastName  = Request.Form["LastName"];
                var City      = Request.Form["City"];
                var Country   = Request.Form["Country"];
                var Email     = Request.Form["Email"];
                var Adress    = Request.Form["Adress"];
                var Tel       = Request.Form["Tel"];
                var Password  = Request.Form["Password"];


                var claim = dc.Claims.Where(c => c.ClaimId == claimId).SingleOrDefault();

                var newUserBD = new User()
                {
                    UserId     = Email,
                    FirstName  = FirstName,
                    LastName   = LastName,
                    City       = City,
                    Adress     = Adress,
                    Country    = Country,
                    CreateDate = DateTime.Now,
                    Tel        = Tel,
                    Email      = Email,
                    password   = GetHash(Password),
                    PictureUrl = "",
                    Role       = "user",
                    changePasswordCodeValudation = new DateTime(2000, 1, 1)
                };

                dc.Users.Add(newUserBD);
                claim.UserId = newUserBD.UserId;
                dc.SaveChanges();

                Session["user"] = newUserBD;

                FormsAuthentication.SignOut();

                FormsAuthenticationTicket authTicket =
                    new FormsAuthenticationTicket(1, newUserBD.UserId, DateTime.Now, DateTime.Now.AddMinutes(200), true, newUserBD.Role, "/");
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
                                                   FormsAuthentication.Encrypt(authTicket));
                Response.Cookies.Add(cookie);


                return(View("ConfirmClaim", claim));
            }
        }
Exemplo n.º 13
0
        public ActionResult ChangeUserData()
        {
            ViewBag.error = false;
            User user = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                user = dc.Users.Where(u => u.Email == User.Identity.Name).SingleOrDefault();
                return(View("ChangeUser", user));
            }

            return(View("ChangeUser", null));
        }
Exemplo n.º 14
0
 public ActionResult ConfirmClaim(string claimId)
 {
     using (AirHelpDBContext dc = new AirHelpDBContext())
     {
         var ClaimId = Guid.Parse(claimId);
         var claim   = dc.Claims.Include("User").Where(c => c.ClaimId == ClaimId).SingleOrDefault();
         if (claim.State > ClaimStatus.Pending)
         {
             var url = $"/иск/{claim.ClaimId}";
             Response.Redirect(url);
         }
         return(View("ConfirmClaim", claim));
     }
 }
Exemplo n.º 15
0
        public ActionResult UserList(string category)
        {
            var         isAdmin = User.IsInRole("admin");
            List <User> list    = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                list = dc.Users
                       .Include("Claims")
                       .OrderByDescending(c => c.CreateDate)
                       .ToList();
            }
            return(View("UserList", list));
        }
Exemplo n.º 16
0
        public ActionResult ClaimListYordan()
        {
            var          isAdmin = User.IsInRole("admin");
            List <Claim> list    = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                list = dc.Claims
                       .Include("AirPorts")
                       .ToList();
            }

            return(View("ClaimListYordan", list));
        }
Exemplo n.º 17
0
        public ActionResult ContractHtml(Guid id)
        {
            Claim claim = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                claim = dc.Claims
                        .Include("User")
                        .Include("AirPorts")
                        .Where(c => c.ClaimId == id).SingleOrDefault();
            }

            var model = new VMClaim(claim);

            return(PartialView("ContractPdf", model));
        }
Exemplo n.º 18
0
        public ActionResult ClaimListRemove(string removeId)
        {
            var          isAdmin = User.IsInRole("admin");
            List <Claim> list    = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                var claimId = Guid.Parse(removeId);
                var claim   = dc.Claims.Where(c => c.ClaimId == claimId).SingleOrDefault();
                dc.Claims.Remove(claim);
                dc.SaveChanges();
                list = dc.Claims
                       .Include("AirPorts")
                       .ToList();
            }
            return(View("ClaimListYordan", list));
        }
Exemplo n.º 19
0
        public ActionResult ClaimList(string category)
        {
            var          isAdmin = User.IsInRole("admin");
            List <Claim> list    = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                list = dc.Claims
                       .Include("AirPorts")
                       .Include("User")
                       .Include("Documents")
                       .Where(c => c.isDeleted == false && c.Type != ProblemType.Pending && (c.UserId == User.Identity.Name || isAdmin)).Select(c => c)
                       .OrderByDescending(c => c.DateCreated)
                       .ToList();
            }
            return(View("ClaimList", list));
        }
Exemplo n.º 20
0
        public ActionResult ClaimDetail(Guid id)
        {
            Claim          claim    = null;
            List <AirPort> airPorts = null;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                claim = dc.Claims.Where(c => c.ClaimId == id).SingleOrDefault();

                airPorts = claim.AirPorts.OrderBy(a => a.number).ToList();
            }
            var model = new VMClaim(claim);


            model.totalDistance = 0;

            for (int i = 0; i < airPorts.Count - 1; i++)
            {
                var sCoord = new GeoCoordinate(airPorts[i].y, airPorts[i].x);
                var eCoord = new GeoCoordinate(airPorts[i + 1].y, airPorts[i + 1].x);

                var distance = sCoord.GetDistanceTo(eCoord);

                var AirportDistance = new AirportDistance
                {
                    From     = $"{airPorts[i].name} ({airPorts[i].iata})",
                    To       = $"{airPorts[i + 1].name} ({airPorts[i + 1].iata})",
                    distance = distance / 1000
                };
                model.totalDistance = model.totalDistance + distance / 1000;
                model.AirporstDistance.Add(AirportDistance);
            }

            model.rightOfCompensation = true;
            model.CompensationAmount  = 250;
            if (model.totalDistance >= 3500)
            {
                model.CompensationAmount = 600;
            }
            else if (model.totalDistance >= 1500)
            {
                model.CompensationAmount = 450;
            }
            return(View("ViewClaim", model));
        }
Exemplo n.º 21
0
        public ActionResult ProtectedDocuments(string doc, string ext)
        {
            var userID = User.Identity.Name;
            var docU   = doc + "/" + ext;
            var docF   = doc + "." + ext;

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                var isAdmin  = User.IsInRole("admin");
                var filePath = "";
                var fileName = "";
                var document = dc.Documents.Where(d => d.DocumentName == docF && (d.Claim.UserId == userID || isAdmin)).SingleOrDefault();
                if (document != null)
                {
                    filePath = $"~/UserDocuments/{docF}";
                    fileName = docF;


                    var length = new System.IO.FileInfo(Server.MapPath(filePath)).Length;
                    Response.BufferOutput = false;
                    Response.AddHeader("Content-Length", length.ToString());
                    return(File(Server.MapPath(filePath), System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
                }
                else
                {
                    var url = $"/документи/{docU}";
                    var pdf = dc.Claims.Where(c => (c.UserId == userID || isAdmin) && (c.AttorneyUrl == url || c.contractUrl == url)).SingleOrDefault();
                    if (pdf != null)
                    {
                        filePath = $"~/UserDocuments/{docF}";
                        fileName = docF;

                        var length = new System.IO.FileInfo(Server.MapPath(filePath)).Length;
                        Response.BufferOutput = false;
                        Response.AddHeader("Content-Length", length.ToString());
                        return(File(Server.MapPath(filePath), System.Net.Mime.MediaTypeNames.Application.Pdf, fileName));
                    }
                }
            }

            ViewBag.text    = "защитена информация";
            ViewBag.subtext = "файла е защитен от неауторизиран достъп";
            return(View("Success"));
        }
Exemplo n.º 22
0
        public ActionResult Login(string claimId)
        {
            if (!string.IsNullOrEmpty(claimId) && User.Identity.IsAuthenticated)
            {
                using (AirHelpDBContext dc = new AirHelpDBContext())
                {
                    var giid  = Guid.Parse(claimId);
                    var claim = dc.Claims.Where(c => c.ClaimId == giid).SingleOrDefault();

                    if (claim != null)
                    {
                        claim.UserId = User.Identity.Name;
                        dc.SaveChanges();
                    }
                }
                return(Redirect($"/потвърждение-на-иск/{claimId}"));
            }
            return(View("Login"));
        }
Exemplo n.º 23
0
        public ActionResult UpdateClaimPost(IEnumerable <HttpPostedFileBase> UserFiles, string id)
        {
            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                var claimId = Request.Form["claimId"] ?? id;

                var ClaimId = Guid.Parse(claimId);
                var claim   = dc.Claims
                              .Include("User")
                              .Include("Documents")
                              .Include("AdditionalUsers")
                              .Include("AirPorts")
                              .Where(c => c.ClaimId == ClaimId).SingleOrDefault();

                if (UserFiles != null)
                {
                    foreach (var file in UserFiles)
                    {
                        if (file != null && file.ContentLength > 0)
                        {
                            var name = Guid.NewGuid().ToString().Replace("-", "") + "." + file.FileName.Split('.')[1];
                            file.SaveAs(Server.MapPath("~/UserDocuments/" + name));
                            claim.Documents.Add(new Document
                            {
                                Id           = Guid.NewGuid(),
                                DocumentName = name,
                                Url          = "/документи/" + name.Split('.')[0] + "/" + name.Split('.')[1]
                            });
                        }
                    }
                    claim.isDurtyAdmin = !User.IsInRole("admin");
                }
                if (claim.State == ClaimStatus.WaitForAttorny && claim.Documents.Count > 0)
                {
                    claim.State = ClaimStatus.InProgress;
                }

                dc.SaveChanges();
                return(View("ViewClaim", claim));
            }
        }
Exemplo n.º 24
0
        public static VMUser GetUserById(string userID)
        {
            VMUser user = null;

            using (AirHelpDBContext context = new AirHelpDBContext())
            {
                var userDB = context.Users.Where(u => u.UserId == userID).SingleOrDefault();
                if (userDB != null)
                {
                    user = new VMUser()
                    {
                        UserId     = userDB.UserId,
                        FirstName  = userDB.FirstName,
                        LastName   = userDB.LastName,
                        Email      = userDB.Email,
                        PictureUrl = userDB.PictureUrl,
                        Role       = userDB.Role
                    };
                }
            }
            return(user);
        }
Exemplo n.º 25
0
        public ActionResult ForgottenPasswordP(string code)
        {
            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                var user = dc.Users.Where(u => u.changePasswordCode == code).SingleOrDefault();

                if (user == null)
                {
                    ViewBag.text = "Невалидан линк";
                    return(View("Success"));
                }

                if (user != null && DateTime.Now > user.changePasswordCodeValudation)
                {
                    ViewBag.text = "Линка е с изтекла валидност";
                    return(View("Success"));
                }

                return(View("ForgottenPasswordP"));
            }

            return(View("ForgottenPasswordP"));
        }
Exemplo n.º 26
0
        public ActionResult ChangeUserdataPost()
        {
            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                var userId    = Request.Form["userId"];
                var FirstName = Request.Form["FirstName"];
                var LastName  = Request.Form["LastName"];
                var City      = Request.Form["City"];
                var Country   = Request.Form["Country"];
                var Adress    = Request.Form["Adress"];
                var Tel       = Request.Form["Tel"];
                var Password  = Request.Form["Password"];


                var user = dc.Users.Where(c => c.UserId == userId).SingleOrDefault();
                user.FirstName = FirstName;
                user.LastName  = LastName;
                user.Country   = Country;
                user.City      = City;
                user.Adress    = Adress;
                user.Tel       = Tel;
                user.FirstName = FirstName;

                dc.SaveChanges();

                Session["user"] = user;

                FormsAuthenticationTicket authTicket =
                    new FormsAuthenticationTicket(1, user.UserId, DateTime.Now, DateTime.Now.AddMinutes(200), true, user.Role, "/");
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
                                                   FormsAuthentication.Encrypt(authTicket));

                return(View("ChangeUser", user));
            }

            return(View("ChangeUser", null));
        }
Exemplo n.º 27
0
        public ActionResult CheckDirctFlightPost(string FlightNumber, string Date)
        {
            // testing
            Claim c = null;
            Guid  g = new Guid("ecbc3e69-71c0-4fab-971d-3acc3bd98480");

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                c = dc.Claims.Where(cl => cl.ClaimId == g).SingleOrDefault();


                ViewBag.IsEu         = c.AirPorts.Any(a => CommonHeppler.IsEuCountry(a.countryCode));
                ViewBag.delayMessage = (c.issueDistance < 1500000 ? "Полета ви закъсня ли с повече от 2 часа?" :
                                        (c.issueDistance < 3500000 || ViewBag.IsEu ? "Полета ви закъсня ли с повече от 3 часа?" : "Полета ви закъсня ли с повече от 3 часа ?"));
            }
            return(View("ColectData", c));

            var model = new VMDirectFlight()
            {
                date        = Date,
                number      = FlightNumber,
                numberError = ""
            };
            var arr  = Date.Split('.');
            var day  = int.Parse(arr[0]);
            var mont = int.Parse(arr[1]);
            var year = int.Parse(arr[2]);

            FlightStatus fligth = CommonHeppler.GetFlight(FlightNumber, Date);

            if (fligth.flightStatuses.Length == 0)
            {
                model.commonError = "Невалидна комбинция от номер и дата на полета";
                return(View("DirectFlight", model));
            }

            var AirLine = fligth.appendix.airlines.ToList().Find(a => a.iata == fligth.flightStatuses[0].primaryCarrierFsCode);

            Claim claim = new Claim
            {
                ClaimId           = Guid.NewGuid(),
                FlightDate        = Date,
                State             = ClaimStatus.Accepted,
                UserId            = User.Identity.IsAuthenticated ? User.Identity.Name : null,
                DateCreated       = DateTime.Now,
                Type              = ProblemType.Pending,
                FlightNumber      = FlightNumber,
                AirCompany        = AirLine.name,
                AirCompanyCountry = ""
            };

            int number = 0;

            fligth.appendix.airports.ToList().ForEach(a =>
            {
                double distance = 0;
                if (number > 0)
                {
                    var sCoord = new GeoCoordinate(fligth.appendix.airports[number - 1].longitude, fligth.appendix.airports[number - 1].latitude);
                    var eCoord = new GeoCoordinate(fligth.appendix.airports[number].longitude, fligth.appendix.airports[number].latitude);

                    distance = sCoord.GetDistanceTo(eCoord);
                }
                AirPort airport = new AirPort
                {
                    Id             = Guid.NewGuid(),
                    ap_name        = a.name,
                    city           = a.city,
                    cityCode       = a.cityCode,
                    country        = a.countryName,
                    countryCode    = a.countryCode,
                    elevation      = a.elevationFeet,
                    iata           = a.iata,
                    number         = number,
                    name           = a.name,
                    timezone       = 0,
                    icao           = a.icao,
                    type           = "",
                    x              = a.latitude,
                    y              = a.longitude,
                    distanceToNext = distance
                };
                number++;
                claim.AirPorts.Add(airport);
            });

            claim.allDistance = claim.AirPorts.Sum(a => a.distanceToNext);

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                dc.Claims.Add(claim);
                dc.SaveChanges();
            }

            return(View("ColectData", claim));
        }
Exemplo n.º 28
0
        public ActionResult RegisterClaimSave(string category)
        {
            ViewBag.category = category;

            string BordCardUrl         = "";
            string BookConfirmationUrl = "";

            if (Request.Files["BordCard"].ContentLength > 0)
            {
                var file = Request.Files["BordCard"];
                var name = Guid.NewGuid() + "." + file.FileName.Split('.')[1];
                BordCardUrl = $"/UserDocuments/{name}";
                file.SaveAs(Server.MapPath("~/UserDocuments/" + name));
            }
            if (Request.Files["BookConfirmation"].ContentLength > 0)
            {
                var file = Request.Files["BookConfirmation"];
                var name = Guid.NewGuid() + "." + file.FileName.Split('.')[1];
                BookConfirmationUrl = $"/UserDocuments/{name}";
                file.SaveAs(Server.MapPath("~/UserDocuments/" + name));
            }

            Guid   newGuid     = Guid.NewGuid();
            string AttorneyUrl = $"/UserDocuments/{newGuid}.pdf";

            var jsonString = Request.Form["json"];

            var        json = new JavaScriptSerializer();
            Rootobject data = json.Deserialize <Rootobject>(jsonString);


            Claim claim = new Claim
            {
                ClaimId = Guid.NewGuid(),
                State   = ClaimStatus.Pending,

                UserId      = null,
                DateCreated = DateTime.Now,


                Type         = ProblemType.Cancel,
                FlightNumber = Request.Form["FlightNumber"],


                AirCompany        = data.airline.al_name,
                AirCompanyCountry = data.airline.country,
                AdditionalInfo    = Request.Form["AdditionalInfo"],
                Confirm           = Request.Form["Confirm"],

                SignitureImage = Request.Form["SignitureImage"],
                AttorneyUrl    = AttorneyUrl
            };

            int number = 1;

            data.airports.ToList().ForEach(a =>
            {
                AirPort airport = new AirPort
                {
                    Id        = Guid.NewGuid(),
                    ap_name   = a.ap_name,
                    city      = a.city,
                    country   = a.country,
                    elevation = int.Parse(a.elevation),
                    iata      = a.iata,
                    number    = number,
                    name      = a.name,
                    timezone  = double.Parse(a.timezone),
                    icao      = a.icao,
                    type      = a.type,
                    x         = double.Parse(a.x),
                    y         = double.Parse(a.y)
                };
                number++;

                claim.AirPorts.Add(airport);
            });

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                dc.Claims.Add(claim);
                dc.SaveChanges();
            }

            string port = Request.Url.Port == 80 ? string.Empty : $":{Request.Url.Port.ToString()}";

            String url = $"{Request.Url.Scheme}://{Request.Url.Host}{port}/attorattorneyPdf-09-234-5644-34e5345-2343246neyPdf/{claim.ClaimId}";

            SelectPdf.HtmlToPdf   converter = new SelectPdf.HtmlToPdf();
            SelectPdf.PdfDocument doc       = converter.ConvertUrl(url);
            doc.Save(Server.MapPath($"~/UserDocuments/{newGuid}.pdf"));
            doc.Close();

            LogWithUser("temp", "temp");

            return(Redirect($"/обезщетение-списък/{claim.ClaimId}"));
        }
Exemplo n.º 29
0
        public ActionResult ForgottenPasswordPost()
        {
            var Email = Request.Form["Email"];

            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                var user = dc.Users.Where(u => u.Email == Email).SingleOrDefault();

                if (user == null)
                {
                    ViewBag.error = " Няма потребител с такъв email ";
                    return(View("ForgottenPassword"));
                }
                else
                {
                    DateTime limit       = DateTime.Now.AddMinutes(30);
                    Guid     guid1       = Guid.NewGuid();
                    Guid     guid2       = Guid.NewGuid();
                    var      securityKey = GetHash(guid1.ToString()) + GetHash(guid2.ToString());
                    securityKey = securityKey
                                  .Replace("=", "")
                                  .Replace("/", "")
                                  .Replace("\\", "")
                                  .Replace("+", "");
                    var url = $"helpclaim.eu/забравена-парола/{securityKey}";
                    user.changePasswordCode           = securityKey;
                    user.changePasswordCodeValudation = limit;
                    dc.SaveChanges();

                    string bosy = $"<h1>Възстановяване на забравена парола </h1>" +
                                  $"<p>Възстановяване на забравена парола за потребител на helpclaim.eu. потребител имейл: {user.Email}</p>" +
                                  $"<p> Моля последваите лика за избор на нова парола: <a href='{url}' target='_blank'> генериране на парола </a></p>" +
                                  $"<p><b>{ConfigurationManager.AppSettings["company"]} 2018</b></p>";



                    MailMessage message = new MailMessage();
                    message.To.Add(new MailAddress(user.Email));
                    message.Subject    = "Забравена парола";
                    message.Body       = bosy;
                    message.IsBodyHtml = true;

                    try
                    {
                        using (var smtp = new SmtpClient())
                        {
                            smtp.Port        = 25;
                            smtp.EnableSsl   = false;
                            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "K4hvd2357@");
                            smtp.Host        = "mail.helpclaim.eu";
                            smtp.Send(message);
                        }
                    }
                    catch (Exception ex)
                    {
                        ViewBag.text = "Грешка при изпращането на имейл за възстановяване на парола";
                        return(View("Success"));
                    }

                    ViewBag.text = "Изпратен емейл";
                    ViewBag.text = "Изпратен Ви е имейл с линк за избор на нова парола. Валидността на линка е 30 мин.";
                    return(View("Success"));
                }
            }

            return(View("ForgottenPassword"));
        }
Exemplo n.º 30
0
        public ActionResult ConfirmClaimPost(IEnumerable <HttpPostedFileBase> UserFiles)
        {
            using (AirHelpDBContext dc = new AirHelpDBContext())
            {
                var BookCode       = Request.Form["BookCode"];
                var TikedNumber    = Request.Form["TikedNumber"];
                var AdditionalInfo = Request.Form["AdditionalInfo"];
                var claimId        = Request.Form["claimId"];
                var SignitureImage = Request.Form["SignitureImage"];
                var Name           = Request.Form["Name"];
                var Family         = Request.Form["Family"];

                bool signOnEmail = Request.Form["SignViaEmail"] == "yes" ? true : false;

                var ClaimId = Guid.Parse(claimId);
                var claim   = dc.Claims
                              .Include("User")
                              .Include("Documents")
                              .Include("AdditionalUsers")
                              .Include("AirPorts")
                              .Where(c => c.ClaimId == ClaimId).SingleOrDefault();

                if (claim.State > ClaimStatus.Pending)
                {
                    var url = $"/иск/{claim.ClaimId}";
                    Response.Redirect(url);
                }

                if (!string.IsNullOrEmpty(Name))
                {
                    var arrN = Name.Split(',');
                    var arrF = Family.Split(',');
                    for (var i = 0; i < arrN.Length; i++)
                    {
                        AdditionalUser user = new AdditionalUser
                        {
                            AdditionalUserId = Guid.NewGuid(),
                            FirstName        = arrN[i],
                            LastName         = arrF[i]
                        };
                        claim.AdditionalUsers.Add(user);
                    }
                }
                claim.SignitureImage = SignitureImage;
                claim.AdditionalInfo = AdditionalInfo;
                claim.TikedNumber    = TikedNumber;
                claim.BookingCode    = BookCode;

                if (UserFiles != null)
                {
                    foreach (var file in UserFiles)
                    {
                        if (file != null && file.ContentLength > 0)
                        {
                            var name = Guid.NewGuid().ToString().Replace("-", "") + "." + file.FileName.Split('.')[1];
                            file.SaveAs(Server.MapPath("~/UserDocuments/" + name));
                            claim.Documents.Add(new Document
                            {
                                Id           = Guid.NewGuid(),
                                DocumentName = name,
                                Url          = "/документи/" + name.Split('.')[0] + "/" + name.Split('.')[1]
                            });
                        }
                    }
                }
                claim.State = signOnEmail ? ClaimStatus.WaitForAttorny : (claim.Documents.Count > 0 ? ClaimStatus.InProgress : ClaimStatus.WaitForDocument);

                Guid newGuid      = Guid.NewGuid();
                var  attorneyName = string.Format("attorney{0}", claim.referalNumber.ToString("0000"));
                var  contractName = string.Format("contract{0}", claim.referalNumber.ToString("0000"));
                claim.AttorneyUrl = $"/документи/{attorneyName}/pdf";
                claim.contractUrl = $"/документи/{contractName}/pdf";

                dc.SaveChanges();


                string port = Request.Url.Port == 80 ? string.Empty : $":{Request.Url.Port.ToString()}";

                String aUrl = $"{Request.Url.Scheme}://{Request.Url.Host}{port}/attorneyPdf-09-234-5644-34e5345-2343246/{claim.ClaimId}";
                String cUrl = $"{Request.Url.Scheme}://{Request.Url.Host}{port}/contractPdf-09-4565-3453-2345435-2355/{claim.ClaimId}";

                SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf();
                converter.Options.MarginTop    = 30;
                converter.Options.MarginBottom = 10;
                converter.Options.MarginLeft   = 20;
                converter.Options.MarginRight  = 20;
                converter.Options.PdfPageSize  = SelectPdf.PdfPageSize.A4;

                SelectPdf.PdfDocument doc = converter.ConvertUrl(aUrl);
                doc.Save(Server.MapPath($"~/UserDocuments/{attorneyName}.pdf"));
                doc.Close();

                doc = converter.ConvertUrl(cUrl);
                doc.Save(Server.MapPath($"~/UserDocuments/{contractName}.pdf"));
                doc.Close();

                Session["claim"] = claim;


                string bosy = $"<h1>Заявка #{claim.referalNumber.ToString("0000")}</h1><p>От: {claim.User.FirstName} {claim.User.LastName}</p><p><а href='helpclaim.eu/иск/{claim.ClaimId}'>заявка</а></p>";


                MailMessage message = new MailMessage();
                message.To.Add(new MailAddress("*****@*****.**"));
                message.To.Add(new MailAddress("*****@*****.**"));
                message.To.Add(new MailAddress("*****@*****.**"));
                message.To.Add(new MailAddress("*****@*****.**"));
                message.Subject    = "message";
                message.Body       = bosy;
                message.IsBodyHtml = true;

                try
                {
                    using (var smtp = new SmtpClient())
                    {
                        smtp.Port        = 25;
                        smtp.EnableSsl   = false;
                        smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "P@ssw0rd6712");
                        smtp.Host        = "mail.helpclaim.eu";
                        smtp.Send(message);
                    }
                }
                catch (Exception ex)
                {
                    return(View("ViewClaim", claim));
                }

                return(View("ViewClaim", claim));
            }
        }