Exemplo n.º 1
0
        public async Task <IActionResult> Edit(QLGiaDinhSQUpdateRequest request)
        {
            var result = await _qLGiaDinhApiClient.Edit(request.IDQLGDSQ, request);

            if (result.IsSuccessed)
            {
                TempData["result"] = "Sửa quản lý gia đình sĩ quan thành công!";
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Error", "Home"));
        }
Exemplo n.º 2
0
        public async Task <APIResult <bool> > Edit(int IDQLGDSQ, QLGiaDinhSQUpdateRequest request)
        {
            var qlgdsq = await _context.QLGiaDinhSQs.FirstOrDefaultAsync(x => x.IDQLGDSQ == IDQLGDSQ);

            qlgdsq.QuanHe   = request.QuanHe;
            qlgdsq.HoTen    = request.HoTen;
            qlgdsq.NgaySinh = request.NgaySinh;
            qlgdsq.GhiChu   = request.GhiChu;
            await _context.SaveChangesAsync();

            return(new APISuccessedResult <bool>(true));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int IDQLGDSQ, QLGiaDinhSQUpdateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _qLGiaDinhSQServices.Edit(IDQLGDSQ, request);

            if (result.ResultObj == true)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Exemplo n.º 4
0
        public async Task <APIResult <bool> > Edit(int IDQLGDSQ, QLGiaDinhSQUpdateRequest 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 response    = await client.PutAsync($"/api/QLGiaDinhSQs/{IDQLGDSQ}/edit", httpContent);

            var body = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <APISuccessedResult <bool> >(body));
            }
            return(JsonConvert.DeserializeObject <APIErrorResult <bool> >(body));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(int IDQLGDSQ)
        {
            if (!ModelState.IsValid)
            {
                return(View(ModelState));
            }
            var result = await _qLGiaDinhApiClient.Details(IDQLGDSQ);

            if (result.ResultObj != null)
            {
                var qlgdsqUpdateRequest = new QLGiaDinhSQUpdateRequest()
                {
                    IDQLGDSQ = result.ResultObj.IDQLGDSQ,
                    IDSQ     = result.ResultObj.IDSQ,
                    HoTenSQ  = result.ResultObj.HoTenSQ,
                    QuanHe   = result.ResultObj.QuanHe,
                    HoTen    = result.ResultObj.HoTen,
                    NgaySinh = result.ResultObj.NgaySinh,
                    GhiChu   = result.ResultObj.GhiChu
                };
                return(View(qlgdsqUpdateRequest));
            }
            return(View(result));
        }