public async Task <GalleryItemDto> Get(int id) { var result = await _galleryService.GetById(id); var r1 = new GalleryItemDto(result); return(r1); }
public async Task <IActionResult> Put([FromBody] GalleryItemDto value) { try { var entity = new GalleryItem() { CategoryId = value.CategoryId, Description = value.Description, ID = value.ID.Value }; await _galleryService.Edit(entity); return(Ok()); } catch (Exception ex) { System.Diagnostics.Debug.Write($"image id = {value.ID.Value} not found: {ex.Message}"); return(new StatusCodeResult((int)System.Net.HttpStatusCode.InternalServerError)); } }
public async Task <IActionResult> Post(GalleryItemDto imageDto) { var imageFile = imageDto.File; if (imageFile != null) { using (MemoryStream to = new MemoryStream()) { imageFile.CopyTo(to); var entity = new GalleryItem() { CategoryId = imageDto.CategoryId, Description = imageDto.Description, }; await _galleryService.Create(entity, to.GetBuffer()); return(Ok()); } } else { return(BadRequest("file is not attached")); } }