Exemple #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);
        }
Exemple #2
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);
        }