public async Task <IActionResult> Update(string id, [FromBody] LopHocPhanUpdateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            var lopHp = _lopHocPhanService.GetById(key);

            JsonConvert.PopulateObject(values, lopHp);


            if (_lopHocPhanService.Update(lopHp))
            {
                return(Request.CreateResponse(HttpStatusCode.OK));
            }

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