public async Task <ApiResult <bool> > UpdatePublic(int id, CustomerPublicUpdateRequest request) { try { var cusExist = await _context.Customers.FindAsync(request.Id); if (cusExist != null || cusExist.isDelete) { cusExist.email = request.email; cusExist.name = request.name; cusExist.phone = request.phone; cusExist.birthday = request.birthday; cusExist.sex = request.sex; cusExist.update_at = DateTime.Now; await _context.SaveChangesAsync(); return(new ApiSuccessResult <bool>()); } else { return(new ApiErrorResult <bool>("Không tìm thấy tài khoản này")); } } catch { return(new ApiErrorResult <bool>("Cập nhật thất bại")); } }
public async Task <IActionResult> UpdatePublic([FromBody] CustomerPublicUpdateRequest request) { var result = await _customerService.UpdatePublic(request.Id, request); if (!result.IsSuccess) { return(BadRequest(result)); } return(Ok(result)); }
public async Task <ApiResult <bool> > UpdateCustomerPublic(CustomerPublicUpdateRequest request) { var client = _httpClientFactory.CreateClient(); client.BaseAddress = new Uri(_configuration["BaseAddress"]); var json = JsonConvert.SerializeObject(request); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var respone = await client.PutAsync($"/api/Customer/Public/{request.Id}", httpContent); var result = await respone.Content.ReadAsStringAsync(); if (respone.IsSuccessStatusCode) { return(JsonConvert.DeserializeObject <ApiSuccessResult <bool> >(result)); } else { return(JsonConvert.DeserializeObject <ApiErrorResult <bool> >(result)); } }