public ActionResult ManageImage(ImageModel imageModel, HttpPostedFileBase file) { try { // Verify that the user selected a file if (file != null && file.ContentLength > 0) { // extract only the fielname imageModel.ImageFileName = Path.GetFileName(file.FileName); // TODO: need to define destination using (var reader = new BinaryReader(file.InputStream)) { imageModel.ImageFile = reader.ReadBytes(file.ContentLength); } } ContentClientProcessor.SaveImage(imageModel); TempData["Message"] = new ControllerMessage{ Message="Image saved successfully.", MessageType=ControllerMessageType.Info} ; return RedirectToAction("Images", new { Id = imageModel.ImageGalleryId }); } catch (Exception ex) { HandleError(ex); } return View(imageModel); }
/// <summary> /// SaveImage /// </summary> /// <param name="image"></param> public void SaveImage(ImageModel image) { ImageDC ImageDC = Mapper.Map<ImageModel, ImageDC>(image); ServiceResponse<int> saveImageResponse = _contentProxy.Execute(opt => opt.SaveImage(ImageDC)); if (saveImageResponse.Status != ResponseStatus.Success) HandleError(saveImageResponse.Status, saveImageResponse.ResponseMessage); else image.ImageId = saveImageResponse.Result; }
public ActionResult ManageImage(int Id = 0, int LibId = 0) { if (!SavePermissionsToViewBag(FeatureEnum.ImageGallery)) return Redirect("~/home/unauthorized"); ImageModel imageModel = new ImageModel(); imageModel.ImageId = Id; imageModel.ImageGalleryId = LibId; if (Request.IsAjaxRequest()) return PartialView(imageModel); else return View(imageModel); }
/// <summary> /// GetImage /// </summary> /// <param name="imageId"></param> /// <returns></returns> public ImageModel GetImage(int imageId) { ImageModel imageResult = new ImageModel(); ServiceResponse<ImageDC> imageResponse = _contentProxy.Execute(opt => opt.GetImage(imageId)); if (imageResponse.Status == ResponseStatus.Success) { imageResult = Mapper.Map<ImageDC, ImageModel>(imageResponse.Result); } else { HandleError(imageResponse.Status, imageResponse.ResponseMessage); } return imageResult; }