public MissingLicensePlate MarkFoundPlate(int plateId, DateTime requestDateTime, LicensePlateFoundStatus status) { using (var ctx = _dbContextFactory.BuildHucaresContext()) { var recordToUpdate = ctx.MissingLicensePlates.FirstOrDefault(c => c.Id == plateId) ?? throw new ArgumentException(string.Format(Resources.Error_BadIdProvided, plateId)); recordToUpdate.Status = status; recordToUpdate.SearchEndDateTime = requestDateTime; ctx.SaveChanges(); return(recordToUpdate); } }
public async Task <MissingLicensePlate> MarkFoundPlate(int plateId, DateTime requestDateTime, LicensePlateFoundStatus status) { var uri = $"api/mlp/found/{plateId}"; var fullUri = new Uri(HostUri, uri); var plateNumberData = new { endDateTime = requestDateTime, status = status }; var jsonContent = JsonConvert.SerializeObject(plateNumberData, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var request = new HttpRequestMessage(HttpMethod.Post, fullUri) { Content = new StringContent(jsonContent, Encoding.UTF8, "application/json") }; return(await httpHelper.MakeRequest <MissingLicensePlate>(request)); }