public ActionResult Create(HttpPostedFileBase upload)
 {
     ValidateUploadedFile(upload);
     if (ModelState.IsValid)
     {
         if (upload != null && upload.ContentLength > 0)
         {
             try
             {
                 var stats = _fileAnalyzerClient.ComputeStatistics(upload);
                 var fileStatisticsEntity = new FileStatisticsEntity(stats);
                 _db.FileStatisticsEntities.Add(fileStatisticsEntity);
                 _db.SaveChanges();
                 return RedirectToAction("Index");
             }
             catch (Exception ex)
             {
                 ModelState.AddModelError(modalErrorKey, string.Format("Unexpected exception {0}", ex.Message));
             }
         }
     }
     return View();
 }
        public ActionResult Edit(
            [Bind(Include = "ID")] FileStatisticsEntity fileStatisticsEntity, HttpPostedFileBase upload)
        {
            ValidateUploadedFile(upload);
            if (ModelState.IsValid)
            {
                if (fileStatisticsEntity == null)
                {
                    return HttpNotFound();
                }

                if (upload != null && upload.ContentLength > 0)
                {
                    try
                    {
                        var stats = _fileAnalyzerClient.ComputeStatistics(upload);
                        var newFileStatisticsEntity = new FileStatisticsEntity(stats) {ID = fileStatisticsEntity.ID};
                        _db.Entry(newFileStatisticsEntity).State = EntityState.Modified;
                        _db.SaveChanges();
                        return RedirectToAction("Index");
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError(modalErrorKey, string.Format("Unexpected exception {0}", ex.Message));
                    }
                }
            }
            return View();
        }