コード例 #1
0
ファイル: BoPhanServices.cs プロジェクト: dinhducbac/QLSQ
        public async Task <APIResult <bool> > Edit(int IDBP, BoPhanUpdateRequest request)
        {
            var bp = await _context.BoPhans.FirstOrDefaultAsync(x => x.IDBP == IDBP);

            bp.TenBP = request.TenBP;
            await _context.SaveChangesAsync();

            return(new APISuccessedResult <bool>(true));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int IDBP, BoPhanUpdateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _boPhanServices.Edit(IDBP, request);

            if (result.ResultObj == true)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(BoPhanUpdateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(View(ModelState));
            }
            var result = await _boPhanApiClient.Edit(request.IDBP, request);

            if (result.IsSuccessed)
            {
                TempData["result"] = "Sửa bộ phận chức vụ thành công!";
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Error", "Home"));
        }
コード例 #4
0
ファイル: BoPhanAPIClient.cs プロジェクト: dinhducbac/QLSQ
        public async Task <APIResult <bool> > Edit(int IDBP, BoPhanUpdateRequest 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 reponse     = await client.PutAsync($"/api/BoPhans/{IDBP}/edit", httpContent);

            if (reponse.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <APISuccessedResult <bool> >(await reponse.Content.ReadAsStringAsync()));
            }
            return(JsonConvert.DeserializeObject <APIErrorResult <bool> >(await reponse.Content.ReadAsStringAsync()));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int IDBP)
        {
            if (!ModelState.IsValid)
            {
                return(View(ModelState));
            }
            var result = await _boPhanApiClient.Details(IDBP);

            var bpUpdateRequest = new BoPhanUpdateRequest()
            {
                IDBP  = result.ResultObj.IDBP,
                TenBP = result.ResultObj.TenBP
            };

            return(View(bpUpdateRequest));
        }