public ActionResult Publish(HttpPostedFileBase file, string imageBase64String)
        {
            Drawing newDrawing = new Drawing();
            string base64String = string.Empty;

            if (file != null && file.ContentLength > 0)
            {
                byte[] data;
                file.InputStream.Position = 0;

                using (BinaryReader reader = new BinaryReader(file.InputStream))
                {
                    data = reader.ReadBytes((int) file.InputStream.Length);
                }

                base64String = String.Format("{0}{1}", "data:image/png;base64,", Convert.ToBase64String(data));
            }
            else
            {
                // user dragged an image to the canvas
                if (!String.IsNullOrEmpty(imageBase64String))
                {
                    base64String = imageBase64String;
                }
            }

            TryUpdateModel(newDrawing);

            if (ModelState.IsValid)
            {
                newDrawing.Base64Content = base64String;
                newDrawing.CreationDate = DateTime.Now;
                newDrawing.LastUpdate = DateTime.Now;

                if (!string.IsNullOrEmpty(base64String))
                {
                    
                    this._drawingsService.Add(newDrawing);   
                }
            }

            return RedirectToAction("Index");
        }
 public void Add(Drawing newEntity)
 {
     this._drawingsRepository.Add(newEntity);
 }
 public void Add(Drawing entity)
 {
     DrawsBuffer.Add(entity);
 }