Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int IDQLCV)
        {
            if (!ModelState.IsValid)
            {
                return(View(ModelState));
            }
            var result = await _qLChucVuApiClient.Details(IDQLCV);

            var qlcvUpdateRequest = new QLChucVuUpdateRequest()
            {
                IDQLCV           = result.ResultObj.IDQLCV,
                IDSQ             = result.ResultObj.IDSQ,
                HoTen            = result.ResultObj.HoTen,
                IDBP             = result.ResultObj.IDBP,
                IDCV             = result.ResultObj.IDCV,
                NgayNhan         = result.ResultObj.NgayNhan,
                HeSoPhuCap       = result.ResultObj.HeSoPhuCap,
                boPhanViewModels = new List <ViewModel.Catalogs.BoPhan.BoPhanViewModel>(),
                chucVuViewModels = new List <ViewModel.Catalogs.ChucVu.ChucVuViewModel>()
            };
            var getListBoPhan = await _boPhanApiClient.GetAllWithNotPaging();

            qlcvUpdateRequest.boPhanViewModels = getListBoPhan.ResultObj;
            var getLiChucVu = await _chucVuApiClient.GetChucVuWithIDBP(qlcvUpdateRequest.IDBP);

            qlcvUpdateRequest.chucVuViewModels = getLiChucVu.ResultObj;
            return(View(qlcvUpdateRequest));
        }
Exemplo n.º 2
0
        public async Task <APIResult <bool> > Edit(int IDQLCV, QLChucVuUpdateRequest request)
        {
            var qlcv = await _context.QLChucVus.FirstOrDefaultAsync(x => x.IDQLCV == IDQLCV);

            qlcv.IDCV     = request.IDCV;
            qlcv.NgayNhan = request.NgayNhan;
            await _context.SaveChangesAsync();

            return(new APISuccessedResult <bool>(true));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(QLChucVuUpdateRequest request)
        {
            var result = await _qLChucVuApiClient.Edit(request.IDQLCV, request);

            if (result.IsSuccessed)
            {
                TempData["result"] = "Sửa quản lý chức vụ thành công!";
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Error", "Home"));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int IDQLCV, [FromBody] QLChucVuUpdateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _qLChucVuServices.Edit(IDQLCV, request);

            if (result.ResultObj == true)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Exemplo n.º 5
0
        public async Task <APIResult <bool> > Edit(int IDQLCV, QLChucVuUpdateRequest 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/QLChucVus/{IDQLCV}/edit", httpContent);

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

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