public async Task Update(int id, ClientUpdateDTO model) { var entry = await _context.Clients.SingleAsync(x => x.ClientId == id); entry.Name = model.Name; await _context.SaveChangesAsync(); }
public async Task <IActionResult> Update(int id, [FromBody] ClientUpdateDTO clientDTO) { var location = GetCotrollerActionNames(); try { if (id < 1 || clientDTO == null || id != clientDTO.Id) { return(BadRequest()); } var isExist = await _clientRepository.IsExist(id); if (!isExist) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var client = _mapper.Map <Client>(clientDTO); await _clientRepository.Update(client); return(NoContent()); } catch (Exception e) { return(InternalServerError($"{location}: {e.Message} - {e.InnerException}")); } }
public async Task <ClientDTO> PatchAsync(ClientUpdateDTO dto) { this.Logger.LogDebug($"{nameof(ClientUpdateService)} called for {dto.ClientId}"); return(this.Mapper.Map <ClientDTO>( await this.ClientUpdateService.UpdateAsync(Mapper.Map <ClientUpdateModel>(dto)))); }
public async Task <IActionResult> Update(int id, [FromBody] ClientUpdateDTO clientDTO) { try { if (id < 1 || clientDTO == null || id != clientDTO.IDClient) { return(BadRequest()); } var isExists = await _clientRepository.isExists(id); if (!isExists) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var client = _mapper.Map <Client>(clientDTO); var isSuccess = await _clientRepository.Update(client); if (!isSuccess) { return(InternalError($"Update failed.")); } return(NoContent()); } catch (Exception e) { return(InternalError($"{e.Message} - {e.InnerException}")); } }
/// <summary> /// Конструктор с данными обновления. /// </summary> /// <param name="update">Данные обновления</param> /// <param name="downloadUrl">Ссылка на скачивание</param> public UpdateAppVm(ClientUpdateDTO update) { isEnableBtn = true; Update = update; StatusText = "*Обновление можно запустить позже из меню \"Справка\" главного окна."; StatusUpdate = false; updaterPath = Environment.CurrentDirectory + @"\Updater\Updater.exe"; }
public async Task <ClientDTO> PatchAsync(ClientUpdateDTO client) { this.Logger.LogTrace($"{nameof(this.PutAsync)} called"); var result = await this.ClientUpdateService.UpdateAsync(this.Mapper.Map <ClientUpdateModel>(client)); return(this.Mapper.Map <ClientDTO>(result)); }
public async Task <IActionResult> UpdateClient(ClientUpdateDTO dto) { var client = new UserDetails { Id = dto.ID, Countrycode = dto.Nationality, Languageid = int.Parse(dto.Language), Dob = dto.Dob, Housenumber = dto.HouseNumber, Streetname1 = dto.StreetName1, Streetname2 = dto.StreetName2, Streetname3 = dto.StreetName3 }; var result = await _clientService.UpdateClient(client); return(Ok(result)); }
public async Task <ClientDTO> UpdateAsync(ClientUpdateDTO client, String id) { try { String json = JsonConvert.SerializeObject(client, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); StringContent data = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = await this.client.PutAsync(apiUrl + "/client-management/clients/" + id, data); string result = await ResponseUtility.Verification(response); return(JsonConvert.DeserializeObject <ClientDTO>(result)); } catch (ServicesException ex) { throw ex; } catch (Exception e) { throw new ServicesException("Client api not found", 408); } }
public async Task <IActionResult> UploadUpdate(UploadUpdateVm updateVm) { try { // Загрузить обновление. ClientUpdate.AddUpdate(updateVm.UpdateFile, updateVm.Description, updateVm.Version); // Поулчить последнее загруженное обновление. ClientUpdateDTO update = ClientUpdate.GetLastUpdate(); // Отправить всем клиентам вызов проверки обновления. await WorkHub.Clients.All.SendAsync("CheckUpdate"); return(RedirectToAction("UploadUpdate")); } catch (DbUpdateException dbEx) { // При ошибке записать в лог и вывести страницу ошибок. string error = dbEx.InnerException is null ? dbEx.Message : dbEx.InnerException.Message; Logger.LogError($"Ошибка загрузки обновления - {error}"); return(View("Error", new ErrorVm() { ErrorMessage = error })); } }
public async Task <ActionResult> Update(int id, ClientUpdateDTO model) { await _clientService.Update(id, model); return(NoContent()); }
public IActionResult Put(String id, [FromBody] ClientUpdateDTO client) { return(Ok(_clientService.UpdateAsync(client, id).Result)); }