Exemplo n.º 1
0
        public async Task <LocationContact> AddContactAddressAsync(long ownerId, long restaurantId, int floor, string steetNumber, string route, string locality, string country, int zipCode, float latitude, float longitude, [Optional] string administrativeAreaLevel1, [Optional] string administrativeAreaLevel2, [Optional] string googleLink)
        {
            EmployersRestaurants connection = await CheckEmployerRestaurantAsync(ownerId, restaurantId);

            CheckTheLoggedInPerson();
            LocationPoints point = new LocationPoints
            {
                Latitude  = latitude,
                Longitude = longitude
            };
            await PointRepo.AddAsync(point, ModifierId);

            LocationContact contact = new LocationContact()
            {
                LocationPointId = point.Id, RestaurantId = connection.TheRestaurant.Id
            };

            contact.FillOrUpdateFields(floor, steetNumber, route, locality, country, zipCode, administrativeAreaLevel1, administrativeAreaLevel2, googleLink);
            try
            {
                await LocationRepo.AddAsync(contact, ModifierId);
            }
            catch (Exception ex)
            {
                if (contact.Id <= 0)
                {
                    contact = null;
                    await PointRepo.RemoveAsync(point);
                }

                throw ex;
            }

            return(contact);
        }
Exemplo n.º 2
0
        private async Task <LocationPoints> CheckLocationPointExistenceAsync(long locationPointid)
        {
            LocationPoints point = await PointRepo.FindById(locationPointid);

            if (point == null)
            {
                throw new Exception(String.Format("There is no location point record with id {0}", locationPointid));
            }
            return(point);
        }
Exemplo n.º 3
0
        public static void InsertPoint(Message message, MainDbContext context, TelegramBotClient client)
        {
            var newPoint = new LocationPoints()
            {
                IdAdmin = message.From.Id
            };

            context.AllPoints.Add(newPoint);
            context.SaveChanges();

            client.SendTextMessageAsync(message.From.Id, "Enter name of the point:");
        }
Exemplo n.º 4
0
        public async Task <bool> RemoveContactAddressAsync(long ownerId, long restaurantId, long contactId)
        {
            EmployersRestaurants connection = await CheckEmployerRestaurantAsync(ownerId, restaurantId);

            LocationContact loc = await CheckLocationExistenceAsync(contactId);

            LocationPoints point = await CheckLocationPointExistenceAsync(loc.LocationPointId);

            CheckTheLoggedInPerson();
            await PointRepo.RemoveAsync(point);

            await LocationRepo.RemoveAsync(loc);

            return(true);
        }
Exemplo n.º 5
0
        public async Task <LocationContact> UpdateContactAddressAsync(long ownerId, long restaurantId, long contactId, int floor, string steetNumber, string route, string locality, string country, int zipCode, float latitude, float longitude, [Optional] string administrativeAreaLevel1, [Optional] string administrativeAreaLevel2, [Optional] string googleLink)
        {
            EmployersRestaurants connection = await CheckEmployerRestaurantAsync(ownerId, restaurantId);

            LocationContact contact = await CheckLocationExistenceAsync(contactId);

            LocationPoints point = await CheckLocationPointExistenceAsync(contact.LocationPointId);

            point.Latitude  = latitude;
            point.Longitude = longitude;

            CheckTheLoggedInPerson();
            await PointRepo.UpdateAsync(point, ModifierId);

            contact.FillOrUpdateFields(floor, steetNumber, route, locality, country, zipCode, administrativeAreaLevel1, administrativeAreaLevel2, googleLink);
            await LocationRepo.UpdateAsync(contact, ModifierId);

            return(contact);
        }
Exemplo n.º 6
0
 private void ConnectLocationPoints(NeighboringHex neighboringHex, LocationPoints thisLocation, LocationPoints neighboringLocation)
 {
     if (this.Points[thisLocation] == null)
     {
         if (this.neighboringHexes[(int)neighboringHex].Points[neighboringLocation] == null)
         {
             this.neighboringHexes[(int)neighboringHex].Points[neighboringLocation] = new LocationPoint(this.neighboringHexes[(int)neighboringHex]);
         }
         this.Points[thisLocation] = this.neighboringHexes[(int)neighboringHex].Points[neighboringLocation];
         if (!this.neighboringHexes[(int)neighboringHex].Points[neighboringLocation].AttachedHex.Contains(this))
             this.neighboringHexes[(int)neighboringHex].Points[neighboringLocation].AddToAttachedHexList(this);
     }
     else
     {
         if (this.neighboringHexes[(int)neighboringHex].Points[neighboringLocation] == null)
         {
             this.neighboringHexes[(int)neighboringHex].Points[neighboringLocation] = this.Points[thisLocation];
             if (!this.Points[thisLocation].AttachedHex.Contains(this.neighboringHexes[(int)neighboringHex]))
                 this.Points[thisLocation].AddToAttachedHexList(this.neighboringHexes[(int)neighboringHex]);
         }
         else
         {
             this.Points[(int)thisLocation] = this.neighboringHexes[(int)neighboringHex].Points[(int)neighboringLocation];
             if (!this.neighboringHexes[(int)neighboringHex].Points[(int)neighboringLocation].AttachedHex.Contains(this))
                 this.neighboringHexes[(int)neighboringHex].Points[(int)neighboringLocation].AddToAttachedHexList(this);
         }
     }
 }