Esempio n. 1
0
 public async Task <ResponseDTO> Update(UpdateLocationRequest location)
 {
     if (ModelState.IsValid)
     {
         return(await _locationApplicationService.UpdateLocationAsync(location));
     }
     return(ModelState.ToResponse());
 }
Esempio n. 2
0
        public async Task <ResponseDTO> UpdateLocationAsync(UpdateLocationRequest location)
        {
            //Map to Command
            var command = _mapper.Map <UpdateLocationRequest, UpdateLocationCommand>(location);

            //Execute Command
            var resp = await _bus.SendAsync(command);

            return(ResponseBuilder.Correct(resp));
        }
Esempio n. 3
0
        public UpdateLocationResponse UpdateLocation(UpdateLocationRequest request)
        {
            Location location = PersistenceContext.Load <Location>(request.LocationDetail.LocationRef, EntityLoadFlags.CheckVersion);

            LocationAssembler assembler = new LocationAssembler();

            assembler.UpdateLocation(request.LocationDetail, location, PersistenceContext);

            return(new UpdateLocationResponse(assembler.CreateLocationSummary(location)));
        }
Esempio n. 4
0
 internal static LocationEntity ToEntity(this UpdateLocationRequest request)
 {
     return(request == null ? null : new LocationEntity
     {
         UID = request.UID,
         Name = request.Name,
         Description = request.Description,
         Floor = request.Floor,
         Address = request.Address,
         UserUID = request.UserUID
     });
 }
Esempio n. 5
0
        public async Task <BaseResponse> UpdateAsync(UpdateLocationRequest request)
        {
            BaseResponse _Response = new BaseResponse();

            if (request.UID == Guid.Empty || !await __LocationRepository.UpdateAsync(request.ToEntity(), request.UserUID))
            {
                _Response.Success      = false;
                _Response.ErrorMessage = $"{GlobalConstants.ERROR_ACTION_PREFIX} update {ENTITY_NAME}.";
            }

            return(_Response);
        }
Esempio n. 6
0
        public override bool SaveItem(bool copyCurrent = false)
        {
            var json = JsonView?.Text.ToString();

            if (!string.IsNullOrEmpty(json))
            {
                try
                {
                    var location = JsonConvert.DeserializeObject <Location>(json);

                    if (copyCurrent)
                    {
                        var createLocationRequest = new CreateLocationRequest(
                            name: location.Name += "-copy",
                            countryCode: location.CountryCode ?? "USA",
                            latitude: location.Latitude,
                            longitude: location.Longitude,
                            regionRadius: location.RegionRadius,
                            temperatureScale: location.TemperatureScale,
                            locale: location.Locale,
                            additionalProperties: location.AdditionalProperties);

                        STClient.CreateLocation(createLocationRequest);
                    }
                    else
                    {
                        UpdateLocationRequest locationRequest = new UpdateLocationRequest(
                            name: location.Name,
                            latitude: location.Latitude,
                            longitude: location.Longitude,
                            regionRadius: location.RegionRadius,
                            temperatureScale: location.TemperatureScale,
                            locale: location.Locale,
                            additionalProperties: location.AdditionalProperties);

                        STClient.UpdateLocation(location.LocationId.ToString(), locationRequest);
                    }

                    RefreshScreen();
                }
                catch (SmartThingsNet.Client.ApiException exp)
                {
                    ShowErrorMessage($"Error: {exp.ErrorCode} {Environment.NewLine} {exp.Message}");
                }
                catch (Exception exp)
                {
                    ShowErrorMessage($"Error updating: {exp}");
                }
            }
            return(true);
        }
        public async Task UpdateLocation_Call()
        {
            //--------------    Arrange     -------------
            CommonArrangements();

            var request = new UpdateLocationRequest();
            var command = new UpdateLocationCommand();

            A.CallTo(() => mapper.Map <UpdateLocationRequest, UpdateLocationCommand>(request)).Returns(command);

            //--------------    Act     -------------
            var resp = locationService.UpdateLocationAsync(request);

            //--------------    Assert     -------------

            A.CallTo(() => bus.SendAsync(command)).MustHaveHappened(Repeated.Exactly.Once);
        }
        public async Task <IHttpActionResult> AddLocation([FromBody] UpdateLocationRequest createRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _locationRepository.CreateLocationAsync(createRequest);

            await _locationRepository.SaveAsync();

            var dictionary = new Dictionary <string, string>();

            dictionary.Add("locationName", createRequest.Name);

            _telemetry.TrackEvent("CreatedLocation", dictionary);

            return(ResponseMessage(Request.CreateResponse(HttpStatusCode.Created)));
        }
 public UpdateLocationResponse UpdateLocation(string locationId, UpdateLocationRequest locationRequest)
 {
     return(_locationsApi.UpdateLocation(_accessToken, locationId, locationRequest));
 }
 public void Post(UpdateLocationRequest request)
 {
     UpdateLocation(request.LocationId, request.ComputerId);
 }
 public Location UpdateLocation(string locationId, UpdateLocationRequest locationRequest)
 {
     return(_locationsApi.UpdateLocation(locationId, locationRequest));
 }