public async Task <IActionResult> GetPictureById(int id) { try { var result = context.GetPhotoById(id); return(Ok(await context.GetPicture(result))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IHttpActionResult> DeletePhoto(int id) { PhotoContext context = new PhotoContext(); try { var result = context.GetPhotoById(id); var path = HttpContext.Current.Server.MapPath(string.Format("~/{0}/", result.Path)); context = new PhotoContext(path); return(Ok(await context.DeletePhoto(result))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }