예제 #1
0
        public async Task <EntityDto> CreateOrUpdateLocation(LocationEditDto input)
        {
            var isEdit = input.Id > 0;

            Location location;

            if (isEdit)
            {
                location = await _locationManager.FindLocationAsync(input.Id);

                if (location == null)
                {
                    throw new UserFriendlyException(L("InvalidLocation"));
                }
            }
            else
            {
                location = new Location(input.Name);
            }

            //location.VoucherPlatforms = new List<BranchWithVoucherPlatform>();
            location.UpdateName(input.Name);
            location.UpdateAddress(input.Address, input.Postcode);
            location.UpdateSettings(input.TimeTableJson);

            State state = state = await _stateManager.FindAsync(input.State.Id);

            City city = state.Cities.Where(x => x.CityName == input.City.CityName).FirstOrDefault();

            // if state city null
            location.UpdateState(state);
            location.UpdateCity(city);


            if (!isEdit)
            {
                await _locationManager.CreateLocationAsync(location);
            }

            await CurrentUnitOfWork.SaveChangesAsync();

            return(new EntityDto(location.Id));
        }
예제 #2
0
        public async Task <EntityDto <Guid> > CreateLocation(CreateLocationInput input)
        {
            var location = await _locationManager.CreateLocationAsync(Location.Create(input.Name, input.Longitude, input.Latitude));

            return(new EntityDto <Guid>(location.Id));
        }
예제 #3
0
        public async Task <IHttpActionResult> CreateLocation(LocationDto locationDto)
        {
            var locationId = await locationManager.CreateLocationAsync(locationDto);

            return(Ok(locationId));
        }