public virtual ActionResult Update([FromBody] CatalogItem catalogItem, int id) { if (ModelState.IsValid) { var item = service.FindCatalogItem(id); if (item == null) { return(NotFound()); } service.UpdateCatalogItem(catalogItem); return(Ok(catalogItem)); } return(BadRequest()); }
// GET: Catalog/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CatalogItem catalogItem = service.FindCatalogItem(id.Value); if (catalogItem == null) { return(HttpNotFound()); } AddUriPlaceHolder(catalogItem); return(View(catalogItem)); }
public ActionResult Index(int catalogItemId) { _logger.LogInformation($"Now loading... /items/Index?{catalogItemId}/pic"); if (catalogItemId <= 0) { return(BadRequest()); } var item = service.FindCatalogItem(catalogItemId); if (item != null) { var path = Path.Combine(_webHostEnvironment.WebRootPath, "Pics", item.PictureFileName); string imageFileExtension = Path.GetExtension(item.PictureFileName); string mimetype = GetImageMimeTypeFromImageFileExtension(imageFileExtension); var buffer = System.IO.File.ReadAllBytes(path); return(File(buffer, mimetype)); } return(NotFound()); }
public ActionResult Index(int catalogItemId) { _log.Info($"Now loading... /items/Index?{catalogItemId}/pic"); if (catalogItemId <= 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var item = service.FindCatalogItem(catalogItemId); if (item != null) { var webRoot = ""; //var webRoot = Server.MapPath("~/Pics"); var path = Path.Combine(webRoot, item.PictureFileName); string imageFileExtension = Path.GetExtension(item.PictureFileName); string mimetype = GetImageMimeTypeFromImageFileExtension(imageFileExtension); var buffer = System.IO.File.ReadAllBytes(path); return(File(buffer, mimetype)); } return(HttpNotFound()); }
// GET: Catalog/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } _log.Info($"Now loading... /Catalog/Details?id={id}"); CatalogItem catalogItem = _service.FindCatalogItem(id.Value); if (catalogItem == null) { return(HttpNotFound()); } AddUriPlaceHolder(catalogItem); return(View(catalogItem)); }
// GET: Catalog/Details/5 public ActionResult Details(int?id) { _logger.LogInformation($"Now loading... /Catalog/Details?id={id}"); if (id == null) { return(BadRequest()); } CatalogItem catalogItem = service.FindCatalogItem(id.Value); if (catalogItem == null) { return(NotFound()); } AddUriPlaceHolder(catalogItem); return(View(catalogItem)); }
// GET: Catalog/Edit/5 public ActionResult Edit(int?id) { _log.Info($"Now loading... /Catalog/Edit?id={id}"); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CatalogItem catalogItem = service.FindCatalogItem(id.Value); if (catalogItem == null) { return(HttpNotFound()); } AddUriPlaceHolder(catalogItem); ViewBag.CatalogBrandId = new SelectList(service.GetCatalogBrands(), "Id", "Brand", catalogItem.CatalogBrandId); ViewBag.CatalogTypeId = new SelectList(service.GetCatalogTypes(), "Id", "Type", catalogItem.CatalogTypeId); return(View(catalogItem)); }