Beispiel #1
0
        public async Task <APIResult <bool> > Edit(int IDLuongCB, LuongCoBanUpdateRequest request)
        {
            var lcb = await _context.LuongCoBans.FirstOrDefaultAsync(x => x.IDLuongCB == IDLuongCB);

            lcb.LuongCB = request.LuongCB;
            await _context.SaveChangesAsync();

            return(new APISuccessedResult <bool>(true));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(LuongCoBanUpdateRequest request)
        {
            var result = await _luongCoBanApiClient.Edit(request.IDLuongCB, request);

            if (result.IsSuccessed)
            {
                TempData["result"] = "Sửa lương cơ bản thành công!";
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Error", "Home"));
        }
        public async Task <IActionResult> Edit(int IDLuongCB, LuongCoBanUpdateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _luongCoBanServices.Edit(IDLuongCB, request);

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

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

            if (response.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <APISuccessedResult <bool> >(body));
            }
            return(JsonConvert.DeserializeObject <APIErrorResult <bool> >(body));
        }
Beispiel #5
0
        public async Task <IActionResult> Edit(int IDLuongCB)
        {
            if (!ModelState.IsValid)
            {
                return(View(ModelState));
            }
            var result = await _luongCoBanApiClient.Details(IDLuongCB);

            if (result.IsSuccessed)
            {
                var lcbUpdateRequest = new LuongCoBanUpdateRequest()
                {
                    IDLuongCB = result.ResultObj.IDLuongCB,
                    LuongCB   = result.ResultObj.LuongCB
                };
                return(View(lcbUpdateRequest));
            }
            return(View(result));
        }