Ejemplo n.º 1
0
        public async Task <IActionResult> Update(string id, [FromBody] SinhVienUpdateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var affectedResult = await _sinhVienService.Update(id, request);

            if (affectedResult == 0)
            {
                return(BadRequest());
            }
            return(Ok());
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Put(FormDataCollection form)
        {
            var key    = Convert.ToInt32(form.Get("key"));
            var values = form.Get("values");

            var sinhVien = _sinhVienService.GetById(key);

            JsonConvert.PopulateObject(values, sinhVien);


            if (_sinhVienService.Update(sinhVien))
            {
                return(Request.CreateResponse(HttpStatusCode.OK));
            }

            return(Request.CreateResponse("Không thể cập nhật"));
        }