Beispiel #1
0
        public async Task <IActionResult> Edit(int IDQLQH)
        {
            if (!ModelState.IsValid)
            {
                return(View(ModelState));
            }
            var qlqhViewModel = await _qLQuanHamApiClient.Details(IDQLQH);

            var qlqhUpdateRequest = new QLQuanHamUpdateRequest()
            {
                IDQLQH            = qlqhViewModel.ResultObj.IDQLQH,
                IDSQ              = qlqhViewModel.ResultObj.IDSQ,
                HoTen             = qlqhViewModel.ResultObj.HoTen,
                IDQH              = qlqhViewModel.ResultObj.IDQH,
                IDHeSoLuongQH     = qlqhViewModel.ResultObj.IDHeSoLuongQH,
                HeSoLuong         = qlqhViewModel.ResultObj.HeSoLuong,
                quanHamViewModels = new List <ViewModel.Catalogs.QuanHam.QuanHamViewModel>(),
                heSoLuongTheoQuanHamViewModels = new List <ViewModel.Catalogs.HeSoLuongTheoQuanHam.HeSoLuongTheoQuanHamViewModel>()
            };
            var qhvm = await _quanHamApiClient.GetAllWithoutPaging();

            qlqhUpdateRequest.quanHamViewModels = qhvm.ResultObj;
            var hslqhvm = await _heSoLuongTheoQuanHamApiClient.GetHeSoLuongTheoQHByIDQH(qlqhUpdateRequest.IDQH);

            qlqhUpdateRequest.heSoLuongTheoQuanHamViewModels = hslqhvm.ResultObj;
            return(View(qlqhUpdateRequest));
        }
Beispiel #2
0
        public async Task <APIResult <bool> > Edit(int IDQLQH, QLQuanHamUpdateRequest request)
        {
            var qlqh = await _context.QLQuanHams.FirstOrDefaultAsync(x => x.IDQLQH == IDQLQH);

            qlqh.IDQH = request.IDQH;
            qlqh.IDHeSoLuongTheoQH = request.IDHeSoLuongQH;
            await _context.SaveChangesAsync();

            return(new APISuccessedResult <bool>(true));
        }
Beispiel #3
0
        public async Task <IActionResult> Edit(QLQuanHamUpdateRequest request)
        {
            var result = await _qLQuanHamApiClient.Edit(request.IDQLQH, request);

            if (result.IsSuccessed)
            {
                TempData["result"] = "Sửa quân hàm của sĩ quan thành công!";
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Error", "Home"));
        }
        public async Task <IActionResult> Edit(int IDQLQH, [FromBody] QLQuanHamUpdateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _qLQuanHamServices.Edit(IDQLQH, request);

            if (result.ResultObj == true)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Beispiel #5
0
        public async Task <APIResult <bool> > Edit(int IDQLQH, QLQuanHamUpdateRequest 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/QLQuanHams/{IDQLQH}/edit", httpContent);

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

            if (response.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <APISuccessedResult <bool> >(body));
            }
            return(JsonConvert.DeserializeObject <APIErrorResult <bool> >(body));
        }