public async Task <HttpResponseMessage> GetByIdAsync(AdvertisementModel _params) { var Res = Request.CreateResponse(); var Result = new Res(); try { var data = await Task.Run(() => _advertisementService.GetById(_params)); if (data != null) { Result.Data = data; Result.Status = true; Result.Message = "Call API Success"; Result.StatusCode = HttpStatusCode.OK; } else { Result.Data = null; Result.Status = false; Result.Message = "Không tìm thấy dữ liệu"; Result.StatusCode = HttpStatusCode.InternalServerError; } Res.Content = new StringContent(JsonConvert.SerializeObject(Result)); return(Res); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult Detail(int id) { AdvertisementService advertisementService = new AdvertisementService(); var dty = advertisementService.GetById(id); return(View("Detail", dty)); }
public ActionResult Update(int id) { ViewBag.CarList = new SelectList(_db.Cars, "CarId", "CarId"); Advertisement advertisement = _advService.GetById(id); if (advertisement == null) { return(HttpNotFound()); } return(View(advertisement)); }