public ResultTransactionModel UpdateLocation(UpdateLocationModel model) { return(new ResultTransactionModel() { numAffactedRows = 1, Description = "" }); }
public async Task <IResult> UpdateAsync(long locationId, UpdateLocationModel updateLocationModel) { var validation = new LocationModelValidator().Valid(updateLocationModel); if (!validation.Success) { return(new ErrorDataResult <long>(validation.Message)); } var locationEntity = await LocationRepository.SelectAsync(locationId); var nullObjectValidation = new NullObjectValidation <LocationEntity>().Valid(locationEntity); if (!nullObjectValidation.Success) { return(new ErrorResult(nullObjectValidation.Message)); } var locationDomain = LocationDomainFactory.Create(locationEntity); locationDomain.Update(updateLocationModel); locationEntity = locationDomain.Map <LocationEntity>(); locationEntity.LocationId = locationId; await LocationRepository.UpdateAsync(locationEntity, locationEntity.LocationId); await DatabaseUnitOfWork.SaveChangesAsync(); return(new SuccessResult()); }
public async Task <IActionResult> UpdateLocation([FromBody] UpdateLocationModel model) { // Stop tracking await _trackingService.UpdateLocation(model); return(Ok()); }
public static LocationDomain Create(UpdateLocationModel updateLocationModel) { return(new LocationDomain( updateLocationModel.Title, updateLocationModel.FacultyId )); }
public IActionResult Put(int id, [FromBody] UpdateLocationModel updateModel) { var updateCommand = new UpdateLocationCommand() { LocationId = id }; this.mapper.Map <UpdateLocationModel, UpdateLocationCommand>(updateModel, updateCommand); Location location = this.locationService.UpdateLocation(updateCommand); var model = this.mapper.Map <Location, LocationModel>(location); return(this.Ok(model)); }
public ResultTransactionModel UpdateLocation(UpdateLocationModel model) { var result = new ResultTransactionModel() { numAffactedRows = 0, Description = "" }; using (TransactionScope scope = new TransactionScope()) { try { conn.Open(); model.locations.ForEach(l => { var command = conn.CreateCommand(); command.CommandText = "[UpdateVehicleLocation]"; command.CommandType = CommandType.StoredProcedure; DbParameter vehicleId = command.CreateParameter(); vehicleId.ParameterName = "@vehicleId"; vehicleId.Value = model.vehicle.vehicleId; DbParameter location = command.CreateParameter(); location.ParameterName = "@location"; location.Value = $"POINT({l.latitud} {l.longitud})"; DbParameter datetime = command.CreateParameter(); datetime.ParameterName = "@datetime"; datetime.Value = l.datetime; command.Parameters.Add(vehicleId); command.Parameters.Add(location); command.Parameters.Add(datetime); result.numAffactedRows += command.ExecuteNonQuery(); }); } finally { conn.Close(); } scope.Complete(); return(result); } }
public void UpdateLocation(UpdateLocationModel updateLocationModel) { try { var location = _locationRepository.Get(updateLocationModel.Id); location.Name = updateLocationModel.Name; _locationRepository.Update(location); _locationRepository.Save(); _logger.LogInformation($"Location with id {location.Id} has been updated"); } catch (Exception e) { _logger.LogError(e, "Error when updating location"); throw; } }
public async Task UpdateLocation(UpdateLocationModel model) { // Get current user id var userId = HttpContextHelper.GetCurrentUserId(); // Get tracking session from Redis cache var session = await _cacheService.Get <TrackingSession>(Schema.SESSION_SCHEMA, $"{userId.ToString()}_{model.Code}"); if (session == null) { throw new CustomException(ErrorCodes.EC_Session_002, model.Code); } // Update location var updateLocationCommandHandler = _serviceProvider.GetRequiredService <UpdateLocationCommandHandler>(); await updateLocationCommandHandler.Handle(new UpdateLocationCommand() { SessionId = session.SessionId, Longitude = model.Longitude, Latitude = model.Latitude }); }
public void UpdateLocationTest() { decimal latitud = 87.1000982m; decimal longitud = 88.1000982m; var updateLocationModel = new UpdateLocationModel { vehicle = new Vehicle { vehicleId = "AAA-AAA" }, locations = new List <Location>() { new Location { datetime = DateTime.Now, latitud = $"{latitud}", longitud = $"{longitud}" }, new Location { datetime = DateTime.Now, latitud = $"{latitud}", longitud = $"{longitud}" } } }; VahicleController vehicleController = new VahicleController(repository); vehicleController.Request = new HttpRequestMessage(); vehicleController.Request.SetConfiguration(new HttpConfiguration()); var result = vehicleController.UpdateLocation(updateLocationModel); }
public HttpResponseMessage UpdateLocation(UpdateLocationModel request) { var result = this.NotifyAsync(TaxiCabUtil.VEHICLELOCATION, new { Message = request }); return(Request.CreateResponse(HttpStatusCode.OK, repository.UpdateLocation(request))); }
public void Update(UpdateLocationModel updateLocationModel) { Title = updateLocationModel.Title; FacultyId = updateLocationModel.FacultyId; UpdatedDate = DateTime.Now; }
public async Task <IActionResult> UpdateAsync(long locationId, UpdateLocationModel updateLocationModel) { var result = await LocationService.UpdateAsync(locationId, updateLocationModel); return(new ActionIResult(result)); }