public async Task AddRecord() { try { Lessons = Lessons.Substring(0, Lessons.Length - 2); var record = new CreateRecord { Teacher = Teacher, Room = Room, Note = Note, ClassNumber = SelectedNumber, ClassLetter = SelectedLetter, Lessons = Lessons, Date = Date }; await _recordTempService.PostRecord(record); ResetFields(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public async Task UpdateRecordAsync() { var client = new HetznerDnsClient(this._apiKey); var zoneResponse = await client.GetZonesAsync(); Assert.IsNotNull(zoneResponse); var zoneId = zoneResponse.Zones.FirstOrDefault()?.Id; var createRecord = new CreateRecord { ZoneId = zoneId, Name = "_acme-challenge.unittest", Type = DnsRecordType.TXT, Value = "testest", Ttl = 0 }; var createdRecord = await client.CreateRecordAsync(createRecord); Assert.IsNotNull(createdRecord); var updateRecord = new UpdateRecord { ZoneId = createRecord.ZoneId, Type = DnsRecordType.TXT, Name = createRecord.Name, Value = "update-record", Ttl = 10, }; var updatedRecord = await client.UpdateRecordAsync(createdRecord.Id, updateRecord); Assert.IsNotNull(updatedRecord); }
public OVertex Run() { // var operation = CreateSQLOperation(); var operation = new CreateRecord(_document, _connection.Database); return(_connection.ExecuteOperation(operation).To <OVertex>()); }
public async Task <TResult> CreateRecordAsync <TResult>(object createRecordParams, CancellationToken cancelToken) { if (createRecordParams == null) { throw new ArgumentNullException("createRecordParams"); } var requestBody = new RequestBody(createRecordParams); var method = new CreateRecord(m_client, requestBody, typeof(TResult)); Response response = await method.ExecuteAsync(cancelToken); return((TResult)response.GetResult()); }
public async Task PostRecord(CreateRecord record) { using (HttpResponseMessage response = await _apiHelper.ApiClient.PostAsJsonAsync("api/v1/admin/records", record)) { if (response.IsSuccessStatusCode) { // log successful post } else { //throw new Exception(response.ReasonPhrase); } } }
public OEdge Run() { if (_document == null) { // simple link, no properties? } else { } // var operation = CreateSQLOperation(); var operation = new CreateRecord(_document, _connection.Database); return(_connection.ExecuteOperation(operation).To <OEdge>()); }
public async Task <Record> CreateRecordAsync(CreateRecord record, CancellationToken cancellationToken = default) { var json = JsonConvert.SerializeObject(record, this._jsonSerializerSettings); var responseMessage = await this._httpClient.PostAsync($"v1/records", new StringContent(json), cancellationToken); if (!responseMessage.IsSuccessStatusCode) { var errorMessage = await responseMessage.Content.ReadAsStringAsync(); throw new HttpException($"{responseMessage.IsSuccessStatusCode} {errorMessage}"); } json = await responseMessage.Content.ReadAsStringAsync(); var changeResponse = JsonConvert.DeserializeObject <ChangeRecordResponse>(json, this._jsonSerializerSettings); return(changeResponse.Record); }
private void ResetRecord_Click(object sender, RoutedEventArgs e) { //Removes previous record and writes the new one Dates.DateList.Remove(Dates.DateList.Last()); CreateRecord.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); }
public bool CreateRecordEx(CreateRecord command) => Resolve(command);
public async Task <IActionResult> Post([FromBody] CreateRecord command) { await _client.PublishAsync(command); return(Accepted()); }
public async Task <IActionResult> Post([FromBody] CreateRecord command) { return(Accepted()); }
public async Task <IActionResult> Post([FromBody] CreateRecord command) { await _busClient.PublishAsync(command); return(StatusCode(202)); }
public bool IsAvailable(string session, int patientId) { var json = "{ \"patient_id\":\"" + patientId + "\",\"speciality_code\":\"" + specialityCode + "\",\"auth\":{ \"session_id\":\"" + session + "\"} }"; var response = Post("https://emp.mos.ru/v1.1/doctor/getDoctors?token=887033d0649e62a84f80433e823526a1", json); var responseJson = JsonConvert.DeserializeObject <EMaisAnswer>(response); Console.WriteLine($"[{DateTime.Now}] {responseJson.errorCode}: {responseJson.errorMessage}"); if (responseJson.errorCode == 0) { var sb = new StringBuilder(); foreach (var clinic in responseJson.result.clinics) { sb.AppendLine($"Клиника: {clinic.address}"); foreach (var doctorsInfo in clinic.doctors_info) { sb.AppendLine($"- {doctorsInfo.availability_date}: {doctorsInfo.last_name} {doctorsInfo.first_name} {doctorsInfo.second_name}"); } } Console.WriteLine(sb.ToString()); _telegram.SendMessage(sb.ToString()); var enableAppointmentAutoCreation = true; var nearestDate = responseJson.result.clinics.SelectMany(f => f.doctors_info) .OrderBy(f => Math.Abs((DateTime.Parse(f.availability_date) - _bestRecordDate).TotalMinutes)).FirstOrDefault(); // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (enableAppointmentAutoCreation && nearestDate != null) { var createAppointment = new CreateRecord() { availableResourceId = nearestDate.availableResourceId, complexResourceId = nearestDate.complexResourceId, auth = new Auth { session_id = session }, code = nearestDate.code, date = DateTime.Parse(nearestDate.availability_date).Date.ToString("dd.MM.yyyy"), doctorInfo = new ObjectModel.DoctorInfo { availability_date = DateTime.Parse(nearestDate.availability_date), code = nearestDate.code, availableResourceId = nearestDate.availableResourceId, complexResourceId = nearestDate.complexResourceId, clinic = nearestDate.clinic, first_name = nearestDate.first_name, last_name = nearestDate.last_name, room = nearestDate.room, second_name = nearestDate.second_name }, patient_id = patientId.ToString(), specialityCode = specialityCode, specialityName = "", startTime = DateTime.Parse(nearestDate.availability_date).ToString("dd.MM.yyyy HH:mm"), endTime = DateTime.Parse(nearestDate.availability_date).AddMinutes(10).ToString("dd.MM.yyyy HH:mm"), ticket = _currentRecord?.ticket }; string responseCreateAppointmentJson; if (_currentRecord != null) { var currentDiff = Math.Abs((DateTime.Parse(_currentRecord.dateBegin) - _bestRecordDate).TotalMinutes); var newDiff = Math.Abs((DateTime.Parse(nearestDate.availability_date) - _bestRecordDate).TotalMinutes); if (newDiff < currentDiff) { if (_currentRecord.clinic == nearestDate.clinic) { responseCreateAppointmentJson = Post( "https://emp.mos.ru/v1.1/doctor/shiftAppointment?token=887033d0649e62a84f80433e823526a1", JsonConvert.SerializeObject(createAppointment)); UpdateAppointments(patientId, session); var responseJs = JsonConvert.DeserializeObject <BaseResponse>(responseCreateAppointmentJson); _telegram.SendMessage($"Перезаписываю Вас на {nearestDate.availability_date} ({newDiff}<{currentDiff}): \r\n - {responseJs.errorCode}:{responseJs.errorMessage}."); } else { _telegram.SendMessage($"Клиника в записи отличается от изначально выбранной ({_currentRecord.clinic}!={nearestDate.clinic}). Ничего не делаю."); } } else { _telegram.SendMessage($"Вы уже имеете запись на {_currentRecord?.dateBegin}, предлагаемая {nearestDate.availability_date} менее удобна. ({newDiff}>{currentDiff}), пропускаю."); } } else { responseCreateAppointmentJson = Post( "https://emp.mos.ru/v1.1/doctor/createAppointment?token=887033d0649e62a84f80433e823526a1", JsonConvert.SerializeObject(createAppointment)); UpdateAppointments(patientId, session); } } } return(true); }
public PostRecordsController(CreateRecord createRecord) { this.create = createRecord; }