public ActionResult DangKiMoiPost(ThuyenChuyenDTO thuyenChuyenDTO) { if (ModelState.IsValid) { ThuyenChuyen thuyenChuyen = new ThuyenChuyen(); Mapper.Map(thuyenChuyenDTO, thuyenChuyen); using (var _thuyenChuyenService = new ThuyenChuyenRepository()) { ThuyenChuyen thuyenChuyenCreated = _thuyenChuyenService.CreateThuyenChuyen(thuyenChuyen); return(Json(new ReturnResult(200, "success", thuyenChuyen.Id), JsonRequestBehavior.AllowGet)); } } return(Json(new ReturnResult(400, "failed", null), JsonRequestBehavior.AllowGet)); }
public ActionResult CapNhatPost(ThuyenChuyenDTO thuyenChuyenDTO, int id) { if (ModelState.IsValid) { using (var _thuyenChuyenService = new ThuyenChuyenRepository()) { ThuyenChuyen thuyenChuyen = _thuyenChuyenService.GetThuyenChuyensById(id); Mapper.Map(thuyenChuyenDTO, thuyenChuyen); ThuyenChuyen thuyenChuyenUpdated = _thuyenChuyenService.CapNhatThuyenChuyen(thuyenChuyen); if (thuyenChuyenUpdated == null) { return(Json(new ReturnResult(400, "failed", null), JsonRequestBehavior.AllowGet)); } return(Json(new ReturnResult(200, "success", thuyenChuyenUpdated.Id), JsonRequestBehavior.AllowGet)); } } return(Json(new ReturnResult(400, "failed", null), JsonRequestBehavior.AllowGet)); }