예제 #1
0
        private bool AreSame(Establishment current, Establishment staging)
        {
            if (current.EstablishmentName != staging.EstablishmentName)
            {
                return(false);
            }

            if (current.Ukprn != staging.Ukprn)
            {
                return(false);
            }

            if (current.Uprn != staging.Uprn)
            {
                return(false);
            }

            if (current.CompaniesHouseNumber != staging.CompaniesHouseNumber)
            {
                return(false);
            }

            if (current.CharitiesCommissionNumber != staging.CharitiesCommissionNumber)
            {
                return(false);
            }

            if (current.Trusts?.Code != staging.Trusts?.Code)
            {
                return(false);
            }

            if (current.LA?.Code != staging.LA?.Code)
            {
                return(false);
            }

            if (current.EstablishmentNumber != staging.EstablishmentNumber)
            {
                return(false);
            }

            if (current.PreviousEstablishmentNumber != staging.PreviousEstablishmentNumber)
            {
                return(false);
            }

            if (current.Postcode != staging.Postcode)
            {
                return(false);
            }

            if (current.Federations?.Code != staging.Federations?.Code)
            {
                return(false);
            }

            if (current.Trusts?.Code != staging.Trusts?.Code)
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
 public static bool EstablishmentIsInstitutionWhenIsClaimingStudent(bool isClaimingStudent, Establishment establishment)
 {
     // return false when user is claiming student but establishment is not an academic institution
     return(establishment != null && (establishment.IsInstitution || isClaimingStudent == false));
 }
예제 #3
0
        public ForgotPasswordValidator(IQueryEntities entities, IStorePasswords passwords)
        {
            CascadeMode = CascadeMode.StopOnFirstFailure;

            Establishment establishment     = null;
            var           loadEstablishment = new Expression <Func <Establishment, object> >[]
            {
                e => e.SamlSignOn,
            };

            Person person     = null;
            var    loadPerson = new Expression <Func <Person, object> >[]
            {
                p => p.Emails,
                p => p.User
            };

            RuleFor(p => p.EmailAddress)

            // cannot be empty
            .NotEmpty()
            .WithMessage(FailedBecauseEmailAddressWasEmpty)

            // must be valid against email address regular expression
            .EmailAddress()
            .WithMessage(FailedBecauseEmailAddressWasNotValidEmailAddress)

            // must match an establishment
            .Must(p => ValidateEstablishment.EmailMatchesEntity(p, entities, loadEstablishment, out establishment))
            .WithMessage(FailedBecauseUserNameMatchedNoLocalMember,
                         p => p.EmailAddress)

            // establishment must be a member
            .Must(p => establishment.IsMember)
            .WithMessage(FailedBecauseUserNameMatchedNoLocalMember,
                         p => p.EmailAddress)

            // establishment cannot have saml integration
            .Must(p => !establishment.HasSamlSignOn())
            .WithMessage(FailedBecauseEduPersonTargetedIdWasNotEmpty,
                         p => p.EmailAddress.GetEmailDomain())

            // must match a person
            .Must(p => ValidateEmailAddress.ValueMatchesPerson(p, entities, loadPerson, out person))
            .WithMessage(FailedBecauseUserNameMatchedNoLocalMember,
                         p => p.EmailAddress)

            // the matched person must have a user
            .Must(p => ValidatePerson.UserIsNotNull(person))
            .WithMessage(FailedBecauseUserNameMatchedNoLocalMember,
                         p => p.EmailAddress)

            // the user must not have a SAML account
            .Must(p => ValidateUser.EduPersonTargetedIdIsEmpty(person.User))
            .WithMessage(FailedBecauseEduPersonTargetedIdWasNotEmpty,
                         p => p.EmailAddress.GetEmailDomain())

            // the email address' person's user's name must match a local member account
            .Must(p => ValidateUser.NameMatchesLocalMember(person.User.Name, passwords))
            .WithMessage(FailedBecauseUserNameMatchedNoLocalMember,
                         p => p.EmailAddress)

            // the email address must be confirmed
            .Must(p => ValidateEmailAddress.IsConfirmed(person.GetEmail(p)))
            .WithMessage(ValidateEmailAddress.FailedBecauseIsNotConfirmed,
                         p => p.EmailAddress)
            ;
        }
        private async Task UnpackMigrateFiles(
            string[] directoryPath,
            Establishment establishment,
            List <string> usedFileNames,
            bool appendOnlyIfDoesntExist,
            CancellationToken cancellationToken)
        {
            string topLevelDirectory = directoryPath.Last();

            // First, delve down recursively.
            this.loggerWrapper.Debug(
                $"Pulling inner directories within \"{topLevelDirectory}\"...");

            IEnumerable <string> innerDirectories =
                await this.documentStorageAdapter.ListDirectoriesAsync(
                    directoryPath,
                    cancellationToken)
                .ConfigureAwait(false);

            this.loggerWrapper.Info(
                $"{innerDirectories.Count()} inner directory(s) returned.");

            this.loggerWrapper.Debug("Looping through inner directories...");

            string[] innerDirectoryPath = null;
            foreach (string innerDirectory in innerDirectories)
            {
                innerDirectoryPath = directoryPath
                                     .Concat(new string[] { innerDirectory })
                                     .ToArray();

                this.loggerWrapper.Debug(
                    $"Processing inner directory \"{innerDirectory}\"...");

                await this.UnpackMigrateFiles(
                    innerDirectoryPath,
                    establishment,
                    usedFileNames,
                    appendOnlyIfDoesntExist,
                    cancellationToken)
                .ConfigureAwait(false);

                this.loggerWrapper.Info(
                    $"Inner directory \"{innerDirectory}\" processed.");
            }

            this.loggerWrapper.Debug(
                $"Now scanning for files in \"{topLevelDirectory}\"...");

            IEnumerable <DocumentFile> documentFiles =
                await this.documentStorageAdapter.ListFilesAsync(
                    directoryPath,
                    cancellationToken)
                .ConfigureAwait(false);

            this.loggerWrapper.Info(
                $"{documentFiles.Count()} file(s) returned.");

            foreach (DocumentFile documentFile in documentFiles)
            {
                this.loggerWrapper.Debug(
                    $"Processing file {documentFile}...");

                await this.ProcessFile(
                    establishment,
                    usedFileNames,
                    documentFile,
                    appendOnlyIfDoesntExist,
                    cancellationToken)
                .ConfigureAwait(false);

                this.loggerWrapper.Info($"Processed file {documentFile}.");
            }
        }
        private async Task ProcessFile(
            Establishment establishment,
            List <string> usedFileNames,
            DocumentFile documentFile,
            bool appendToDirectoryIfNotExists,
            CancellationToken cancellationToken)
        {
            this.loggerWrapper.Debug(
                $"Determining the {nameof(ZipFileType)} for " +
                $"{documentFile}...");

            string name = documentFile.Name;

            ZipFileType?zipFileType = GetZipFileType(name);

            if (zipFileType.HasValue)
            {
                this.loggerWrapper.Info(
                    $"{nameof(zipFileType)} = {zipFileType.Value}");

                switch (zipFileType.Value)
                {
                case ZipFileType.SitePlan:
                    await this.ProcessSitePlanZip(
                        establishment,
                        documentFile,
                        usedFileNames,
                        cancellationToken)
                    .ConfigureAwait(false);

                    break;

                case ZipFileType.Evidence:
                    await this.ProcessEvidence(
                        establishment,
                        documentFile,
                        usedFileNames,
                        cancellationToken)
                    .ConfigureAwait(false);

                    break;

                case ZipFileType.ArchivedReport:
                    await this.ProcessArchivedReport(
                        establishment,
                        documentFile,
                        usedFileNames,
                        appendToDirectoryIfNotExists,
                        cancellationToken)
                    .ConfigureAwait(false);

                    break;

                case ZipFileType.Report:
                    await this.ProcessReport(
                        establishment,
                        documentFile,
                        usedFileNames,
                        appendToDirectoryIfNotExists,
                        cancellationToken)
                    .ConfigureAwait(false);

                    break;

                default:
                    this.loggerWrapper.Error(
                        "Able to determine the zip file type, but the " +
                        "processing functionality has not been " +
                        "implemented yet.");
                    break;
                }
            }
            else
            {
                this.loggerWrapper.Warning(
                    $"Could not determine {nameof(ZipFileType)} for " +
                    $"\"{name}\". It will be ignored.");
            }
        }
예제 #6
0
        public void InitializeData()
        {
            _dbContext.Database.EnsureDeleted();
            if (_dbContext.Database.EnsureCreated())
            {
                // BEGIN CATEGORIES
                Category restrauntCategory = new Category()
                {
                    Name = "Restaurant"
                };
                Category winkelCategory = new Category()
                {
                    Name = "Winkel"
                };
                Category cafeCategory = new Category()
                {
                    Name = "Café"
                };
                Category schoolCategory = new Category()
                {
                    Name = "School"
                };

                var categories = new List <Category>
                {
                    restrauntCategory, winkelCategory, cafeCategory, schoolCategory
                };
                // END CATEGORIES

                // BEGIN ROLE
                Role customerRole = new Role()
                {
                    Name = "Customer"
                };
                Role merchantRole = new Role()
                {
                    Name = "Merchant"
                };

                var roles = new List <Role>
                {
                    customerRole, merchantRole
                };
                //END ROLE

                // BEGIN USERS
                Customer customerLennert = new Customer()
                {
                    FirstName = "Lennert", LastName = "Bontinck", Email = "*****@*****.**"
                };
                customerLennert.Login = new Login()
                {
                    Role = customerRole, Username = "******"
                };

                Customer customerBram = new Customer()
                {
                    FirstName = "Bram", LastName = "De Coninck", Email = "*****@*****.**"
                };
                customerBram.Login = new Login()
                {
                    Role = customerRole, Username = "******"
                };

                Customer customerJodi = new Customer()
                {
                    FirstName = "Jodi", LastName = "De Loof", Email = "*****@*****.**"
                };
                customerJodi.Login = new Login()
                {
                    Role = customerRole, Username = "******"
                };

                Merchant merchantRestaurantSpaghetti = new Merchant()
                {
                    FirstName = "Spaghetti", LastName = "Verantwoordelijke", Email = "*****@*****.**"
                };
                merchantRestaurantSpaghetti.Login = new Login()
                {
                    Role = merchantRole, Username = "******"
                };

                Merchant merchantWinkelFnac = new Merchant()
                {
                    FirstName = "Fnac", LastName = "Verantwoordelijke", Email = "*****@*****.**"
                };
                merchantWinkelFnac.Login = new Login()
                {
                    Role = merchantRole, Username = "******"
                };

                Merchant merchantCafeSafir = new Merchant()
                {
                    FirstName = "Safir", LastName = "Verantwoordelijke", Email = "*****@*****.**"
                };
                merchantCafeSafir.Login = new Login()
                {
                    Role = merchantRole, Username = "******"
                };

                Merchant merchantSchoolHoGent = new Merchant()
                {
                    FirstName = "HoGent", LastName = "Verantwoordelijke", Email = "*****@*****.**"
                };
                merchantSchoolHoGent.Login = new Login()
                {
                    Role = merchantRole, Username = "******"
                };

                var customers = new List <Customer>
                {
                    customerLennert, customerBram, customerJodi
                };
                var merchants = new List <Merchant>
                {
                    merchantRestaurantSpaghetti, merchantWinkelFnac, merchantCafeSafir, merchantSchoolHoGent
                };
                // END USERS

                // START SET PASSWORDS
                byte[] salt = new byte[128 / 8];
                using (var randomGetal = RandomNumberGenerator.Create())
                {
                    randomGetal.GetBytes(salt);
                }

                string hash = Convert.ToBase64String(KeyDerivation.Pbkdf2(
                                                         password: "******",
                                                         salt: salt,
                                                         prf: KeyDerivationPrf.HMACSHA1,
                                                         iterationCount: 10000,
                                                         numBytesRequested: 256 / 8));

                foreach (User user in customers)
                {
                    user.Login.Salt = salt;
                    user.Login.Hash = hash;
                }

                foreach (User user in merchants)
                {
                    user.Login.Salt = salt;
                    user.Login.Hash = hash;
                }
                // END SET PASSWORDS

                // START SOCIAL MEDIA
                SocialMedia facebookSocialMedia = new SocialMedia()
                {
                    LogoPath = "img/socialMediaLogos/facebook/facebook.png", Name = "Facebook"
                };
                SocialMedia instagramSocialMedia = new SocialMedia()
                {
                    LogoPath = "img/socialMediaLogos/instagram/instagram.png", Name = "Instagram"
                };
                SocialMedia twitterSocialMedia = new SocialMedia()
                {
                    LogoPath = "img/socialMediaLogos/twitter/twitter.png", Name = "Twitter"
                };

                var socialsMedias = new List <SocialMedia>
                {
                    facebookSocialMedia, instagramSocialMedia, twitterSocialMedia
                };
                // END SOCIAL MEDIA

                // START COMPANIES
                Company mrspaghettiCompany = new Company()
                {
                    Name = "Mr Spaghetti"
                };
                Company fnacCompany = new Company()
                {
                    Name = "Fnac"
                };
                Company safirCompany = new Company()
                {
                    Name = "Safir"
                };
                Company hogentCompany = new Company()
                {
                    Name = "HoGent"
                };
                // END COMPANIES

                // START ESTABLISHMENT
                // Day of week 0 = maandag, openinghours null = gesloten
                Establishment mrspaghettiAalstEstablishment = new Establishment()
                {
                    Name = "Restaurant Mr Spaghetti", Description = "Kom langs bij Mister Spaghetti en laat je verbazen door de pasta bij uitstek!", PostalCode = "9300", City = "Aalst", Street = "Hopmarkt", HouseNumber = "33", Latitude = 50.937142, Longitude = 4.036673
                };

                mrspaghettiAalstEstablishment.EstablishmentCategories.Add(new EstablishmentCategory()
                {
                    Category = restrauntCategory
                });
                mrspaghettiAalstEstablishment.EstablishmentCategories.Add(new EstablishmentCategory()
                {
                    Category = cafeCategory
                });

                mrspaghettiAalstEstablishment.EstablishmentSocialMedias.Add(new EstablishmentSocialMedia()
                {
                    SocialMedia = facebookSocialMedia, Url = "https://www.facebook.com/WeLoveMisterSpaghettiAalst/"
                });

                mrspaghettiAalstEstablishment.Images.Add(new Image()
                {
                    Path = "img/establishments/1/1.jpg"
                });
                mrspaghettiAalstEstablishment.Images.Add(new Image()
                {
                    Path = "img/establishments/1/2.jpg"
                });

                mrspaghettiAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 0
                });
                mrspaghettiAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 1
                });
                mrspaghettiAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 2, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 11, Startminute = 30, EndHour = 14, EndMinute = 00
                        }, new OpenHour()
                        {
                            StartHour = 18, Startminute = 00, EndHour = 22, EndMinute = 00
                        }
                    }
                });
                mrspaghettiAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 3, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 11, Startminute = 30, EndHour = 14, EndMinute = 00
                        }, new OpenHour()
                        {
                            StartHour = 18, Startminute = 00, EndHour = 22, EndMinute = 00
                        }
                    }
                });
                mrspaghettiAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 4, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 11, Startminute = 30, EndHour = 14, EndMinute = 00
                        }, new OpenHour()
                        {
                            StartHour = 18, Startminute = 00, EndHour = 22, EndMinute = 00
                        }
                    }
                });
                mrspaghettiAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 5, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 11, Startminute = 30, EndHour = 14, EndMinute = 00
                        }, new OpenHour()
                        {
                            StartHour = 18, Startminute = 00, EndHour = 22, EndMinute = 00
                        }
                    }
                });
                mrspaghettiAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 6, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 11, Startminute = 30, EndHour = 14, EndMinute = 00
                        }, new OpenHour()
                        {
                            StartHour = 18, Startminute = 00, EndHour = 22, EndMinute = 00
                        }
                    }
                });

                mrspaghettiAalstEstablishment.ExceptionalDays.Add(new ExceptionalDay()
                {
                    Day = DateTime.Today, Message = "Gesloten wegens familiale redenen."
                });
                mrspaghettiAalstEstablishment.ExceptionalDays.Add(new ExceptionalDay()
                {
                    Day = DateTime.Today.AddDays(4), Message = "All you can eat event!"
                });
                mrspaghettiAalstEstablishment.ExceptionalDays.Add(new ExceptionalDay()
                {
                    Day = DateTime.Today.AddDays(10), Message = "Ladies night event!"
                });

                mrspaghettiAalstEstablishment.Events.Add(new Event()
                {
                    StartDate = DateTime.Today.AddDays(4).AddHours(11).AddMinutes(30), EndDate = DateTime.Today.AddDays(4).AddHours(22),
                    Name      = "All you can eat",
                    Message   = "Bij het all you can eat event betaal je een inkom van 20 euro en krijg je een ganse avond spaghetti voorgeschoteld! De normale openingsuren gelden.",
                    Images    = new List <Image>()
                    {
                        new Image()
                        {
                            Path = "img/events/1/1.jpg"
                        }, new Image()
                        {
                            Path = "img/events/1/2.jpg"
                        }
                    }
                });
                mrspaghettiAalstEstablishment.Events.Add(new Event()
                {
                    StartDate = DateTime.Today.AddDays(10).AddHours(18), EndDate = DateTime.Today.AddDays(10).AddHours(23),
                    Name      = "Ladies night",
                    Message   = "Voor deze ladies night kunnen alle meiden vanaf 6u savonds terrecht bij Mr Spaghetti te Aalst voor een hapje en een drankje terwijl er een Sturm Der Liebe marathon afspeeld op het groot scherm!",
                    Images    = new List <Image>()
                    {
                        new Image()
                        {
                            Path = "img/events/2/1.jpg"
                        }, new Image()
                        {
                            Path = "img/events/2/2.jpg"
                        }
                    }
                });

                mrspaghettiAalstEstablishment.Promotions.Add(new Promotion()
                {
                    StartDate = DateTime.Today, EndDate = DateTime.Today.AddDays(10).AddHours(5),
                    Name      = "€ 5 korting op spaghetti",
                    Message   = "€ 5 korting op een spaghetti naar keuze bij het vermelden van de couponcode 'Spaghet5'.",
                    Images    = new List <Image>()
                    {
                        new Image()
                        {
                            Path = "img/promotions/1/1.jpg"
                        }, new Image()
                        {
                            Path = "img/promotions/1/2.jpg"
                        }
                    },
                    Attachments = new List <File>()
                    {
                        new File()
                        {
                            Name = "QR-code", Path = "files/promotions/1/1.pdf"
                        }
                    }
                });

                mrspaghettiCompany.Establishments.Add(mrspaghettiAalstEstablishment);
                //-------
                Establishment fnacAalstEstablishment = new Establishment()
                {
                    Name = "Fnac Aalst", Description = "Ontdek onze nieuwe Fnac winkel, en vind al je onmisbare artikelen: Boeken, CD's, Computers, Telefoons en nog veel meer.", PostalCode = "9300", City = "Aalst", Street = "Kattestraat", HouseNumber = "17", Latitude = 50.939538, Longitude = 4.037435
                };

                fnacAalstEstablishment.EstablishmentCategories.Add(new EstablishmentCategory()
                {
                    Category = winkelCategory
                });

                fnacAalstEstablishment.EstablishmentSocialMedias.Add(new EstablishmentSocialMedia()
                {
                    SocialMedia = facebookSocialMedia, Url = "https://www.facebook.com/FnacAalst/"
                });
                fnacAalstEstablishment.EstablishmentSocialMedias.Add(new EstablishmentSocialMedia()
                {
                    SocialMedia = twitterSocialMedia, Url = "https://twitter.com/fnacbelgie"
                });

                fnacAalstEstablishment.Images.Add(new Image()
                {
                    Path = "img/establishments/2/1.jpg"
                });
                fnacAalstEstablishment.Images.Add(new Image()
                {
                    Path = "img/establishments/2/2.jpg"
                });
                fnacAalstEstablishment.Images.Add(new Image()
                {
                    Path = "img/establishments/2/3.jpg"
                });

                fnacAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 0, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 18, EndMinute = 00
                        }
                    }
                });
                fnacAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 1, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 18, EndMinute = 00
                        }
                    }
                });
                fnacAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 2, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 18, EndMinute = 00
                        }
                    }
                });
                fnacAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 3, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 18, EndMinute = 00
                        }
                    }
                });
                fnacAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 4, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 18, EndMinute = 00
                        }
                    }
                });
                fnacAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 5, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 18, EndMinute = 00
                        }
                    }
                });
                fnacAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 6
                });

                fnacAalstEstablishment.ExceptionalDays.Add(new ExceptionalDay()
                {
                    Day = DateTime.Today.AddDays(2), Message = "Gesloten wegens werken"
                });

                fnacAalstEstablishment.Promotions.Add(new Promotion()
                {
                    StartDate = DateTime.Today.AddDays(12), EndDate = DateTime.Today.AddDays(16),
                    Name      = "Week van de smartphone.",
                    Message   = "Tot wel 50% korting op ons assortiment smartphones. Kom eens binnen en ontdek welk toestel onze experts u aanbevelen.",
                    Images    = new List <Image>()
                    {
                        new Image()
                        {
                            Path = "img/promotions/2/1.jpg"
                        }, new Image()
                        {
                            Path = "img/promotions/2/2.jpg"
                        }
                    }
                });

                fnacCompany.Establishments.Add(fnacAalstEstablishment);
                //-------
                Establishment safirAalstEstablishment = new Establishment()
                {
                    Name = "Café Safir", Description = "Het café van Aalst voor jong en oud! Verschillende snack en lunch mogelijkheden aanwezig.", PostalCode = "9300", City = "Aalst", Street = "Grote Markt", HouseNumber = "22", Latitude = 50.938424, Longitude = 4.038867
                };

                safirAalstEstablishment.EstablishmentCategories.Add(new EstablishmentCategory()
                {
                    Category = cafeCategory
                });
                safirAalstEstablishment.EstablishmentCategories.Add(new EstablishmentCategory()
                {
                    Category = restrauntCategory
                });

                safirAalstEstablishment.EstablishmentSocialMedias.Add(new EstablishmentSocialMedia()
                {
                    SocialMedia = facebookSocialMedia, Url = "https://www.facebook.com/pages/category/Cafe/Safir-188724374609159/"
                });
                safirAalstEstablishment.Images.Add(new Image()
                {
                    Path = "img/establishments/3/1.jpg"
                });
                safirAalstEstablishment.Images.Add(new Image()
                {
                    Path = "img/establishments/3/2.jpg"
                });
                safirAalstEstablishment.Images.Add(new Image()
                {
                    Path = "img/establishments/3/3.jpg"
                });

                safirAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 0, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 0, EndMinute = 00
                        }
                    }
                });
                safirAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 1, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 0, EndMinute = 00
                        }
                    }
                });
                safirAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 2, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 0, EndMinute = 00
                        }
                    }
                });
                safirAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 3, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 0, EndMinute = 00
                        }
                    }
                });
                safirAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 4, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 0, EndMinute = 00
                        }
                    }
                });
                safirAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 5, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 9, Startminute = 30, EndHour = 0, EndMinute = 00
                        }
                    }
                });
                safirAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 6
                });

                safirAalstEstablishment.Promotions.Add(new Promotion()
                {
                    StartDate = DateTime.Today.AddDays(2), EndDate = DateTime.Today.AddDays(2).AddHours(5),
                    Name      = "Happy hours!",
                    Message   = "2 pintjes voor de prijs van 1!",
                    Images    = new List <Image>()
                    {
                        new Image()
                        {
                            Path = "img/promotions/3/1.jpg"
                        }, new Image()
                        {
                            Path = "img/promotions/3/2.jpg"
                        }
                    }
                });

                safirCompany.Establishments.Add(safirAalstEstablishment);
                //-------
                Establishment hogentAalstEstablishment = new Establishment()
                {
                    Name = "HoGent Campus Aalst", Description = "De hogeschool Gent Campus Aalst inspireert en stimuleert mensen om, op eigen wijze, het verschil te maken in en voor de samenleving.", PostalCode = "9300", City = "Aalst", Street = "Arbeidstraat", HouseNumber = "14", Latitude = 51.141550, Longitude = 4.559644
                };

                hogentAalstEstablishment.EstablishmentCategories.Add(new EstablishmentCategory()
                {
                    Category = schoolCategory
                });

                hogentAalstEstablishment.EstablishmentSocialMedias.Add(new EstablishmentSocialMedia()
                {
                    SocialMedia = facebookSocialMedia, Url = "https://www.facebook.com/HoGentCampusAalst/"
                });
                hogentAalstEstablishment.EstablishmentSocialMedias.Add(new EstablishmentSocialMedia()
                {
                    SocialMedia = twitterSocialMedia, Url = "https://twitter.com/hogeschool_gent"
                });
                hogentAalstEstablishment.EstablishmentSocialMedias.Add(new EstablishmentSocialMedia()
                {
                    SocialMedia = instagramSocialMedia, Url = "https://www.instagram.com/explore/locations/420243736/hogent-stadscampus-aalst"
                });

                hogentAalstEstablishment.Images.Add(new Image()
                {
                    Path = "img/establishments/4/1.jpg"
                });
                hogentAalstEstablishment.Images.Add(new Image()
                {
                    Path = "img/establishments/4/2.jpg"
                });

                hogentAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 0, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 8, Startminute = 30, EndHour = 12, EndMinute = 00
                        }, new OpenHour()
                        {
                            StartHour = 13, Startminute = 00, EndHour = 16, EndMinute = 30
                        }
                    }
                });
                hogentAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 1, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 8, Startminute = 30, EndHour = 12, EndMinute = 00
                        }, new OpenHour()
                        {
                            StartHour = 13, Startminute = 00, EndHour = 16, EndMinute = 30
                        }
                    }
                });
                hogentAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 2, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 8, Startminute = 30, EndHour = 12, EndMinute = 00
                        }
                    }
                });
                hogentAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 3, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 8, Startminute = 30, EndHour = 12, EndMinute = 00
                        }, new OpenHour()
                        {
                            StartHour = 13, Startminute = 00, EndHour = 16, EndMinute = 30
                        }
                    }
                });
                hogentAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 4, OpenHours = new List <OpenHour>()
                    {
                        new OpenHour()
                        {
                            StartHour = 8, Startminute = 30, EndHour = 12, EndMinute = 00
                        }
                    }
                });
                hogentAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 5
                });
                hogentAalstEstablishment.OpenDays.Add(new OpenDay()
                {
                    DayOfTheWeek = 6
                });

                hogentAalstEstablishment.Events.Add(new Event()
                {
                    StartDate = new DateTime(2019, 3, 5).AddHours(14), EndDate = new DateTime(2019, 3, 8).AddHours(18),
                    Name      = "Open lessen dagen!",
                    Message   =
                        "Een goede manier om een toekomstige opleiding te kiezen, is gewoon komen proeven. Proeven van de leerstof, van de manier van lesgeven, van de sfeer op de campus. Gewoon een échte les meemaken tussen onze huidige studenten. Het aanbod aan Live! lessen is zeer divers. Pik eventueel ook een les mee uit een richting die je minder bekend in de oren klinkt.",
                    Images = new List <Image>()
                    {
                        new Image()
                        {
                            Path = "img/events/3/1.jpg"
                        }, new Image()
                        {
                            Path = "img/events/3/2.jpg"
                        }
                    },
                    Attachments = new List <File>()
                    {
                        new File()
                        {
                            Name = "Brochure Toegepaste Informatica", Path = "files/promotions/3/1.pdf"
                        }, new File()
                        {
                            Name = "Brochure bedrijfsmanagement", Path = "files/promotions/3/2.pdf"
                        }
                    }
                });

                hogentCompany.Establishments.Add(hogentAalstEstablishment);
                // END ESTABLISHMENT

                // START ASSIGNING COMPANY TO MERCHANT
                merchantRestaurantSpaghetti.Companies.Add(mrspaghettiCompany);
                merchantWinkelFnac.Companies.Add(fnacCompany);
                merchantCafeSafir.Companies.Add(safirCompany);
                merchantSchoolHoGent.Companies.Add(hogentCompany);
                // END ASSIGN COMPANY TO MERCHANT

                // START SUBSCRIPTIONS
                customerLennert.EstablishmentSubscriptions.Add(new EstablishmentSubscription()
                {
                    DateAdded = DateTime.Today.AddDays(-10), Establishment = fnacAalstEstablishment
                });
                customerLennert.EstablishmentSubscriptions.Add(new EstablishmentSubscription()
                {
                    DateAdded = DateTime.Today.AddDays(-4), Establishment = hogentAalstEstablishment
                });
                customerBram.EstablishmentSubscriptions.Add(new EstablishmentSubscription()
                {
                    DateAdded = DateTime.Today.AddDays(-8), Establishment = fnacAalstEstablishment
                });
                customerBram.EstablishmentSubscriptions.Add(new EstablishmentSubscription()
                {
                    DateAdded = DateTime.Today.AddDays(-3), Establishment = mrspaghettiAalstEstablishment
                });
                customerJodi.EstablishmentSubscriptions.Add(new EstablishmentSubscription()
                {
                    DateAdded = DateTime.Today.AddDays(-6), Establishment = safirAalstEstablishment
                });
                customerJodi.EstablishmentSubscriptions.Add(new EstablishmentSubscription()
                {
                    DateAdded = DateTime.Today.AddDays(-1), Establishment = mrspaghettiAalstEstablishment
                });
                // END SUBSCRIPTIONS

                // BEGIN SAVE CHANGES
                _dbContext.Categories.AddRange(categories);
                _dbContext.Roles.AddRange(roles);
                _dbContext.Merchants.AddRange(merchants);
                _dbContext.Customers.AddRange(customers);
                _dbContext.SaveChanges();
                _dbContext.SocialMedias.AddRange(socialsMedias);
                // END SAVE CHANGES
            }
        }
예제 #7
0
        public async Task <Establishment> GetEstablishmentAsync(long urn, CancellationToken cancellationToken)
        {
            var message = _getEstablishmentMessageBuilder.Build(new GetEstablishmentRequest
            {
                Urn = urn,
            });

            var request = new RestRequest(Method.POST);

            request.AddParameter("text/xml", message, ParameterType.RequestBody);
            request.AddHeader("SOAPAction", "http://ws.edubase.texunatech.com/GetEstablishment");

            var response = await _restClient.ExecuteTaskAsync(request, cancellationToken);

            try
            {
                var result = EnsureSuccessResponseAndExtractResult(response).Result;

                var root = result.GetElementByLocalName("Establishment");

                // NOTE: Mapping appears in order of the properties for the
                //       Establishment entity.
                //       If adding new mapping, please retain order.
                var establishment = new Establishment
                {
                    AdministrativeWard = root.GetCodeNamePairFromChildElement("AdministrativeWard"),
                    AdmissionsPolicy   = root.GetCodeNamePairFromChildElement("AdmissionsPolicy"),
                    Boarders           = root.GetCodeNamePairFromChildElement("Boarders"),
                    Ccf                    = root.GetCodeNamePairFromChildElement("CCF"),
                    CloseDate              = root.GetDateTimeFromChildElement("CloseDate"),
                    OfstedLastInsp         = root.GetDateTimeFromChildElement("OfstedLastInsp"),
                    Diocese                = root.GetCodeNamePairFromChildElement("Diocese"),
                    DistrictAdministrative = root.GetCodeNamePairFromChildElement("DistrictAdministrative"),
                    Easting                = root.GetLongFromChildElement("Easting"),
                    Ebd                    = root.GetCodeNamePairFromChildElement("EBD"),
                    EdByOther              = root.GetCodeNamePairFromChildElement("EdByOther"),
                    EstablishmentName      = root.GetValueFromChildElement("EstablishmentName"),
                    EstablishmentNumber    = root.GetLongFromChildElement("EstablishmentNumber"),
                    EstablishmentStatus    = root.GetCodeNamePairFromChildElement("EstablishmentStatus"),
                    EstablishmentTypeGroup = root.GetCodeNamePairFromChildElement("EstablishmentTypeGroup"),
                    TypeOfEstablishment    = root.GetCodeNamePairFromChildElement("TypeOfEstablishment"),
                    FurtherEducationType   = root.GetCodeNamePairFromChildElement("FurtherEducationType"),
                    Gender                 = root.GetCodeNamePairFromChildElement("Gender"),
                    Gor                    = root.GetCodeNamePairFromChildElement("GOR"),
                    GsslaCode              = root.GetCodeNamePairFromChildElement("GSSLACode"),
                    Inspectorate           = root.GetCodeNamePairFromChildElement("Inspectorate"),
                    LA = root.GetCodeNamePairFromChildElement("LA"),
                    LastChangedDate             = root.GetDateTimeFromChildElement("LastChangedDate"),
                    Msoa                        = root.GetCodeNamePairFromChildElement("MSOA"),
                    Northing                    = root.GetLongFromChildElement("Northing"),
                    NumberOfPupils              = root.GetLongFromChildElement("NumberOfPupils"),
                    OfficialSixthForm           = root.GetCodeNamePairFromChildElement("OfficialSixthForm"),
                    OfstedRating                = root.GetCodeNamePairFromChildElement("OfstedRating"),
                    OpenDate                    = root.GetDateTimeFromChildElement("OpenDate"),
                    ParliamentaryConstituency   = root.GetCodeNamePairFromChildElement("ParliamentaryConstituency"),
                    PercentageFsm               = root.GetDecimalFromChildElement("PercentageFSM"),
                    PhaseOfEducation            = root.GetCodeNamePairFromChildElement("PhaseOfEducation"),
                    PlacesPru                   = root.GetLongFromChildElement("PlacesPRU"),
                    Postcode                    = root.GetValueFromChildElement("Postcode"),
                    PreviousEstablishmentNumber = root.GetLongFromChildElement("PreviousEstablishmentNumber"),
                    ReasonEstablishmentClosed   = root.GetCodeNamePairFromChildElement("ReasonEstablishmentClosed"),
                    ReasonEstablishmentOpened   = root.GetCodeNamePairFromChildElement("ReasonEstablishmentOpened"),
                    ReligiousEthos              = root.GetCodeNamePairFromChildElement("ReligiousEthos"),
                    ResourcedProvisionCapacity  = root.GetLongFromChildElement("ResourcedProvisionCapacity"),
                    ResourcedProvisionOnRoll    = root.GetLongFromChildElement("ResourcedProvisionOnRoll"),
                    RscRegion                   = root.GetCodeNamePairFromChildElement("RSCRegion"),
                    SchoolCapacity              = root.GetLongFromChildElement("SchoolCapacity"),
                    SchoolWebsite               = root.GetValueFromChildElement("SchoolWebsite"),
                    Section41Approved           = root.GetCodeNamePairFromChildElement("Section41Approved"),
                    SpecialClasses              = root.GetCodeNamePairFromChildElement("SpecialClasses"),
                    StatutoryHighAge            = root.GetLongFromChildElement("StatutoryHighAge"),
                    StatutoryLowAge             = root.GetLongFromChildElement("StatutoryLowAge"),
                    TeenMoth                    = root.GetCodeNamePairFromChildElement("TeenMoth"),
                    TeenMothPlaces              = root.GetLongFromChildElement("TeenMothPlaces"),
                    TelephoneNum                = root.GetValueFromChildElement("TelephoneNum"),
                    Trusts                      = root.GetElementByLocalName("Trusts")?.GetCodeNamePairFromChildElement("Value"),
                    Ukprn                       = root.GetLongFromChildElement("UKPRN"),
                    Uprn                        = root.GetValueFromChildElement("UPRN"),
                    UrbanRural                  = root.GetCodeNamePairFromChildElement("UrbanRural"),
                    Urn  = urn,
                    Lsoa = root.GetCodeNamePairFromChildElement("LSOA"),
                    DateOfLastInspectionVisit = root.GetDateTimeFromChildElement("DateOfLastInspectionVisit"),
                    InspectorateReport        = root.GetValueFromChildElement("InspectorateReport"),
                    ContactEmail = root.GetValueFromChildElement("ContactEmail"),
                    Street       = root.GetValueFromChildElement("Street"),
                    Locality     = root.GetValueFromChildElement("Locality"),
                    Address3     = root.GetValueFromChildElement("Address3"),
                    Town         = root.GetValueFromChildElement("Town"),
                    County       = root.GetValueFromChildElement("County"),
                    Federations  = root.GetCodeNamePairFromChildElement("Federations"),
                };

                return(establishment);
            }
            catch (SoapException ex)
            {
                // GIAS API throws exception if not found for some reason
                // This is the only obvious way to identify this error case
                if (ex.Message == "Unknown URN")
                {
                    return(null);
                }

                throw;
            }
        }
 public static int DeleteEstablishment(Establishment theestablishment)
 {
     return(EstablishmentDataAccess.GetInstance.DeleteEstablishment(theestablishment));
 }
예제 #9
0
        private async Task ProcessSitePlanZip(
            Establishment establishment,
            DocumentFile documentFile,
            List <string> usedFileNames,
            CancellationToken cancellationToken)
        {
            byte[] sitePlanBytes = await this.DownloadAndUnzip(
                documentFile,
                cancellationToken)
                                   .ConfigureAwait(false);

            if (sitePlanBytes.Length < 10000)
            {
                // probably a text file, skip it
                this.loggerWrapper.Info($"{documentFile.Name} with mime type octet-stream is less than 10kb, skipping");
                return;
            }

            string name     = establishment.Name;
            string filename = name + DestinationSitePlanFileExtension;

            // Attempt to get filename from evidence data
            string idSegment    = this.GetIdFromName(documentFile.Name);
            string evidenceName = string.Empty;

            if (idSegment != string.Empty)
            {
                var keyExists = this._cdc1Evidence.TryGetValue(idSegment.ToLower(), out evidenceName);
                if (keyExists)
                {
                    this.loggerWrapper.Info($"Evidence name: {evidenceName}");
                }
                else
                {
                    this.loggerWrapper.Info($"Entry not found for id {idSegment}, skipping file");
                    return;
                }

                evidenceName += this.GetFileExtension(documentFile.Name);
                evidenceName  = this.StripIllegalCharacters(evidenceName);
            }

            Uri uri = await this.SendFileToDestinationStorage(
                establishment,
                DestinationSitePlanSubDirectory,
                evidenceName,
                DestinationSitePlanMimeType,
                sitePlanBytes,
                cancellationToken)
                      .ConfigureAwait(false);

            FileTypeOption fileType = FileTypeOption.SitePlan;

            await this.InsertMetaData(
                establishment,
                fileType,
                uri,
                name,
                evidenceName,
                cancellationToken)
            .ConfigureAwait(false);
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            OrganRecipient or = new OrganRecipient();
            or.Establishment = (Establishment)Session["establishment"];
            or.Bloodgroup    = ddlBloodType.SelectedValue;
            or.DOB           = Convert.ToDateTime(tbxDate.Text);
            or.Height        = Convert.ToInt32(tbxHeight.Text);
            or.Weight        = Convert.ToInt32(tbxWeight.Text);
            or.Addedon       = DateTime.Today;
            or.Organrequired = rbtnlstOrganType.SelectedValue;
            or.Comments      = tbxComments.Text;
            or.Urgency       = Convert.ToInt32(ddlUrgency.SelectedValue);
            or.Refnumber     = tbxReference.Text;
            or.Status        = "waiting";
            OrganRecipientDB.insertOrganRecipient(or);


            Establishment currentEstab = (Establishment)Session["establishment"];
            string        address      = currentEstab.Address;

            List <LiveDonor> allLiveDonors = LiveDonorDB.getallLiveDonor();
            OrganRecipient   tReciepient;
            //donor id from database
            List <OrganRecipient> allReciepients = OrganRecipientDB.getAllRecipients();
            String x      = allReciepients[0].ID;
            int    tempId = Convert.ToInt32(x.Substring(4, x.Length - 4));
            foreach (OrganRecipient dd in allReciepients)
            {
                if (tempId < Convert.ToInt32(dd.ID.Substring(4, dd.ID.Length - 4)) && dd.Establishment.ID == currentEstab.ID)
                {
                    tempId = Convert.ToInt32(dd.ID.Substring(4, dd.ID.Length - 4));
                }
            }
            tReciepient = OrganRecipientDB.getRecipientByID("orwl" + Convert.ToString(tempId));
            //end of getting last one
            bool f = false;

            foreach (LiveDonor ldnr in allLiveDonors)
            {
                int    y   = 0;
                String bt2 = or.Bloodgroup;
                String bt1 = ldnr.Userid.BloodType;
                if ((bt1 == "A+" || bt1 == "A-") && (bt2 == "A+" || bt2 == "A-" || bt2 == "AB+" || bt2 == "AB-"))
                {
                    y = 1;
                }
                else if ((bt1 == "B+" || bt1 == "B-") && (bt2 == "B+" || bt2 == "B-" || bt2 == "AB+" || bt2 == "AB-"))
                {
                    y = 1;
                }
                else if ((bt1 == "AB+" || bt1 == "AB-") && (bt2 == "AB+" || bt2 == "AB-"))
                {
                    y = 1;
                }
                else if ((bt1 == "O+" || bt1 == "O-") && (bt2 == "A+" || bt2 == "A-" || bt2 == "AB+" || bt2 == "AB-" || bt2 == "B+" || bt2 == "B-" || bt2 == "O+" || bt2 == "O-"))
                {
                    y = 1;
                }

                if (ldnr.OrganType == or.Organrequired && y == 1 && ldnr.status == "not allotted")
                {
                    string matchAddress = ldnr.Userid.Address;
                    float  d            = getDistance(address, matchAddress);
                    int    score        = 0;
                    int    d1           = Convert.ToInt32(d);
                    d = d / 3600;

                    int wTimeScore = 0, distanceScore = 0;
                    if (d < 5)
                    {
                        distanceScore = 5;
                    }
                    else if (d < 15)
                    {
                        distanceScore = 4;
                    }
                    else if (d < 25)
                    {
                        distanceScore = 3;
                    }
                    else if (d < 35)
                    {
                        distanceScore = 2;
                    }
                    else if (d < 45)
                    {
                        distanceScore = 1;
                    }
                    else
                    {
                        distanceScore = 0;
                    }

                    wTimeScore = 1;

                    score = or.Urgency * 3 + distanceScore + wTimeScore;

                    LiveOrganMatching match = new LiveOrganMatching();
                    match.LiveDonor  = ldnr;
                    match.Recipient  = tReciepient;
                    match.MatchScore = score;
                    match.Comments   = "NIL";
                    match.Status     = "pending";
                    match.Distance   = d1;
                    LiveOrganMatchingDB.insertMatch(match);
                    f = true;
                }
            }
            if (f == true)
            {
                bool f1 = false;
                List <LiveOrganMatching> liveMatches   = LiveOrganMatchingDB.getAllMatches();
                List <LiveOrganMatching> liveMatchCurr = new List <LiveOrganMatching>();
                foreach (LiveOrganMatching LOM in liveMatches)
                {
                    if (LOM.Recipient == tReciepient)
                    {
                        liveMatchCurr.Add(LOM);
                        f1 = true;
                    }
                }
                if (f1 == true)
                {
                    bool f3 = false;
                    List <LiveOrganMatching> tempDOMList = new List <LiveOrganMatching>();
                    foreach (LiveOrganMatching LOM1 in liveMatchCurr)
                    {                       //also check for highest score
                        foreach (LiveOrganMatching LOM2 in liveMatches)
                        {
                            if (LOM1.LiveDonor == LOM2.LiveDonor && LOM2.Status == "current match")
                            {
                                f3 = true;
                            }
                        }
                        if (f3 == false)
                        {
                            tempDOMList.Add(LOM1);
                        }
                    }
                    LiveOrganMatching tempDOM = tempDOMList[0];

                    foreach (LiveOrganMatching t in tempDOMList)
                    {
                        if (t.MatchScore > tempDOM.MatchScore)
                        {
                            tempDOM = t;
                        }
                    }
                    tempDOM.Status = "current match";
                    LiveOrganMatchingDB.updateMatch(tempDOM);
                }
            }
            lblOutput.Text             = "Recipient successfully added!";
            tbxDate.Text               = "";
            tbxHeight.Text             = "";
            tbxWeight.Text             = "";
            tbxComments.Text           = "";
            tbxReference.Text          = "";
            ddlBloodType.SelectedIndex = 0;
            ddlUrgency.SelectedIndex   = 0;
            string MyAccountUrl = "RecipientWaitingList.aspx";
            Page.Header.Controls.Add(new LiteralControl(string.Format(@" <META http-equiv='REFRESH' content=2;url={0}> ", MyAccountUrl)));
        }
        catch { lblOutput.Text = "Please Check The Entered Values"; }
    }
예제 #11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["echat"] != null)
     {
         string        eID = Session["echat"].ToString();
         Establishment r   = EstablishmentDB.getEstablishmentByID(eID);
         lblName.Text = r.Name;
         Establishment s = (Establishment)Session["establishment"];
         tbxChat.Text = "";
         List <IndividualChatRoom> iuu = IndividualChatRoomDB.getAllChatby2ID(s.ID, r.ID);
         tbxChat.Style["text-align"] = "left";
         if (iuu.Count > 0)
         {
             foreach (IndividualChatRoom i in iuu)
             {
                 if (i.Sender == s.ID)
                 {
                     tbxChat.Text += s.Name + " : " + i.Messages + "\r\n";
                 }
                 else
                 {
                     tbxChat.Text += r.Name + " : " + i.Messages + "\r\n";
                 }
             }
         }
         else
         {
             tbxChat.Text = "You can start the chat now";
             tbxChat.Style["text-align"] = "center";
         }
     }
     else if (Session["rwEst"] != null)
     {
         string        eID = Session["rwEst"].ToString();
         Establishment re  = EstablishmentDB.getEstablishmentByID(eID);
         lblName.Text = re.Name;
         Establishment s = (Establishment)Session["establishment"];
         tbxChat.Text = "";
         List <IndividualChatRoom> iuu = IndividualChatRoomDB.getAllChatby2ID(s.ID, re.ID);
         tbxChat.Style["text-align"] = "left";
         if (iuu.Count > 0)
         {
             foreach (IndividualChatRoom i in iuu)
             {
                 if (i.Sender == s.ID)
                 {
                     tbxChat.Text += s.Name + " : " + i.Messages + "\r\n";
                 }
                 else
                 {
                     tbxChat.Text += re.Name + " : " + i.Messages + "\r\n";
                 }
             }
         }
         else
         {
             tbxChat.Text = "You can start the chat now";
             tbxChat.Style["text-align"] = "center";
         }
     }
     else if (Session["ldID"] != null)
     {
         Users r = UsersDB.getUserbyID(Session["ldID"].ToString());
         lblName.Text = r.Name;
         Establishment s = (Establishment)Session["establishment"];
         tbxChat.Text = "";
         List <IndividualChatRoom> iuu = IndividualChatRoomDB.getAllChatby2ID(s.ID, r.UserId);
         tbxChat.Style["text-align"] = "left";
         if (iuu.Count > 0)
         {
             foreach (IndividualChatRoom i in iuu)
             {
                 if (i.Sender == s.ID)
                 {
                     tbxChat.Text += s.Name + " : " + i.Messages + "\r\n";
                 }
                 else
                 {
                     tbxChat.Text += r.Name + " : " + i.Messages + "\r\n";
                 }
             }
         }
         else
         {
             tbxChat.Text = "You can start the chat now";
             tbxChat.Style["text-align"] = "center";
         }
     }
 }
예제 #12
0
        private void Detail(Establishment establishment)
        {
            String establishmentSerialized = JsonConvert.SerializeObject(establishment);

            Shell.Current.GoToAsync($"establishment/detail?establishmentSerialized={Uri.EscapeDataString(establishmentSerialized)}");
        }
예제 #13
0
        public async Task <IActionResult> Post([FromBody] AddEstablishmentViewModel establishmentToAdd)
        {
            if (ModelState.IsValid)
            {
                if (!IsMerchant())
                {
                    return(BadRequest(new { error = "U bent geen handelaar." }));
                }

                //modelstate werkt niet op lijsten :-D
                if (establishmentToAdd.Categories == null || !establishmentToAdd.Categories.Any())
                {
                    return(BadRequest(new { error = "Geen categorieën meegeven." }));
                }

                //modelstate werkt niet op lijsten :-D
                if (establishmentToAdd.Images == null || !establishmentToAdd.Images.Any())
                {
                    return(BadRequest(new { error = "Geen afbeelding(en) meegeven." }));
                }

                if (!ContainsJpgs(establishmentToAdd.Images))
                {
                    return(BadRequest(new { error = "Geen jpg afbeelding(en) meegeven." }));
                }

                if (!_companyRepository.isOwnerOfCompany(int.Parse(User.FindFirst("userId")?.Value), establishmentToAdd.CompanyId ?? 0))
                {
                    return(BadRequest(new { error = "Het bedrijf waaraan u deze vestiging wilt toevoegen behoord niet tot u." }));
                }

                // Ophalen van Latitude en Longitude op basis van het meegegeven adres
                var adress = $"{establishmentToAdd.Street}+{establishmentToAdd.HouseNumber},+{establishmentToAdd.PostalCode}+{establishmentToAdd.City},+België";

                List <double> latAndLong = await GetLatAndLongFromAddressAsync(adress);

                Establishment newEstablishment = new Establishment
                {
                    Name        = establishmentToAdd.Name,
                    Description = establishmentToAdd.Description,

                    Street      = establishmentToAdd.Street,
                    HouseNumber = establishmentToAdd.HouseNumber,
                    PostalCode  = establishmentToAdd.PostalCode,
                    City        = establishmentToAdd.City,
                    Latitude    = latAndLong[0],
                    Longitude   = latAndLong[1],

                    EstablishmentCategories = ConvertCategoryViewModelsToCategory(establishmentToAdd.Categories),

                    OpenDays        = ConvertOpenDaysViewModelsToOpenDays(establishmentToAdd.OpenDays),
                    ExceptionalDays = ConvertExceptionalDaysViewModelsToExceptionalDays(establishmentToAdd.ExceptionalDays),

                    EstablishmentSocialMedias = ConvertEstablishmentSocialMediasViewModelsToEstablishmentSocialMedias(establishmentToAdd.SocialMedias)
                };

                _establishmentRepository.addEstablishment(establishmentToAdd.CompanyId ?? 0, newEstablishment);

                //we hebben id nodig voor img path dus erna
                newEstablishment.Images = ConvertFileViewModelToImages(establishmentToAdd.Images, newEstablishment.EstablishmentId);
                _establishmentRepository.SaveChanges();
                return(Ok(new { bericht = "De vestiging werd succesvol toegevoegd." }));
            }
            //Als we hier zijn is is modelstate niet voldaan dus stuur error 400, slechte aanvraag
            string errorMsg = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));

            return(BadRequest(new { error = errorMsg }));
        }
예제 #14
0
        public IActionResult Put(int id, [FromBody] ModifyEstablishmentViewModel editedEstablishment)
        {
            if (ModelState.IsValid)
            {
                if (!IsMerchant())
                {
                    return(BadRequest(new { error = "De voorziene token voldoet niet aan de eisen." }));
                }

                Establishment establishment = _establishmentRepository.getById(id);

                if (establishment == null)
                {
                    return(BadRequest(new { error = "Vestiging met meegegeven id niet gevonden." }));
                }

                if (!_establishmentRepository.isOwnerOfEstablishment(int.Parse(User.FindFirst("userId")?.Value), id))
                {
                    return(BadRequest(new { error = "Vestiging behoord niet tot uw vestigingen." }));
                }

                //alles ok, mag editen

                if (!string.IsNullOrEmpty(editedEstablishment.Name))
                {
                    establishment.Name = editedEstablishment.Name;
                }

                if (!string.IsNullOrEmpty(editedEstablishment.Description))
                {
                    establishment.Description = editedEstablishment.Description;
                }

                if (!string.IsNullOrEmpty(editedEstablishment.PostalCode))
                {
                    establishment.PostalCode = editedEstablishment.PostalCode;
                }

                if (!string.IsNullOrEmpty(editedEstablishment.City))
                {
                    establishment.City = editedEstablishment.City;
                }

                if (!string.IsNullOrEmpty(editedEstablishment.Street))
                {
                    establishment.Street = editedEstablishment.Street;
                }

                if (!string.IsNullOrEmpty(editedEstablishment.HouseNumber))
                {
                    establishment.HouseNumber = editedEstablishment.HouseNumber;
                }

                if (editedEstablishment.Categories != null && editedEstablishment.Categories.Any())
                {
                    establishment.EstablishmentCategories = ConvertCategoryViewModelsToCategory(editedEstablishment.Categories);
                }

                if (editedEstablishment.SocialMedias != null && editedEstablishment.SocialMedias.Any())
                {
                    establishment.EstablishmentSocialMedias =
                        ConvertEstablishmentSocialMediasViewModelsToEstablishmentSocialMedias(editedEstablishment
                                                                                              .SocialMedias);
                }

                if (editedEstablishment.OpenDays != null && editedEstablishment.OpenDays.Any())
                {
                    establishment.OpenDays = ConvertOpenDaysViewModelsToOpenDays(editedEstablishment.OpenDays);
                }

                if (editedEstablishment.ExceptionalDays != null && editedEstablishment.ExceptionalDays.Any())
                {
                    establishment.ExceptionalDays = ConvertExceptionalDaysViewModelsToExceptionalDays(editedEstablishment.ExceptionalDays);
                }

                if (editedEstablishment.Images != null && editedEstablishment.Images.Any())
                {
                    var images = ConvertFileViewModelToImages(editedEstablishment.Images, id);
                    if (images.Any())
                    {
                        establishment.Images = images;
                    }
                }

                _companyRepository.SaveChanges();
                return(Ok(new { bericht = "De vestiging werd succesvol bijgewerkt." }));
            }
            //Als we hier zijn is is modelstate niet voldaan dus stuur error 400, slechte aanvraag
            string errorMsg = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));

            return(BadRequest(new { error = errorMsg }));
        }