Ejemplo n.º 1
0
        public HttpResponseMessage Updated(HttpRequestMessage request, HeSoTgViewModel hesotgVM)
        {
            return(CreateReponse(request, () =>
            {
                if (!ModelState.IsValid)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, ModelState.IsValid);
                }
                else
                {
                    var hstg = _heSoThoiGianService.GetById(hesotgVM.Id);
                    hstg.UpdateHeSoTg(hesotgVM);

                    _heSoThoiGianService.Update(hstg);
                    _heSoThoiGianService.save();
                    return request.CreateResponse(HttpStatusCode.Accepted, hesotgVM);
                }
            }));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Created(HttpRequestMessage request, HeSoTgViewModel hesotgVM)
        {
            return(CreateReponse(request, () =>
            {
                if (!ModelState.IsValid)
                {
                    return request.CreateResponse(HttpStatusCode.BadRequest, ModelState.IsValid);
                }
                else
                {
                    var hstg = new HeSoTg();
                    hstg.UpdateHeSoTg(hesotgVM);

                    var model = _heSoThoiGianService.Add(hstg);
                    _heSoThoiGianService.save();
                    var responseData = Mapper.Map <HeSoTg, HeSoTgViewModel>(model);
                    return request.CreateResponse(HttpStatusCode.OK, responseData);
                }
            }));
        }
 public static void UpdateHeSoTg(this HeSoTg hstg, HeSoTgViewModel hstgVm)
 {
     hstg.Id         = hstgVm.Id;
     hstg.ThoiGianDk = hstgVm.ThoiGianDk;
     hstg.HeSoTgdk   = hstgVm.HeSoTgdk;
 }