public async Task <ApiResult> CreateLocationAsync(LocationDto locationDto) { var location = new Location(); Mapper.Map(locationDto, location); var insertedId = await locationRepository.CreateLocationAsync(location, locationDto.MappingScheme); var apiResult = new ApiResult(MessageType.Success); apiResult.AdditionalDetails.Add("insertedId", insertedId); return(apiResult); }
public async Task <Location> CreateLocationAsync(LocationViewModel model) { try { var location = mapper.Map <Location>(model); var created = await repository.CreateLocationAsync(location); return(await SaveAndReturn(created)); } catch (Exception e) { throw e; } }
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))); }