public ActionResult Create(ActivityPackageViewModel activityPackage, ICollection<HttpPostedFileBase> uploads)
        {
            if (uploads.Count() >= 10)
            {
                ModelState.AddModelError("StoredFiles", "Maxim 10 fisiere pot fi incarcate.");
            }

            if (ModelState.IsValid)
            {
                var newActivityPackage = ActivityPackageContext.Save(activityPackage.ToModel());

                foreach (var file in uploads)
                {
                    if (file == null) continue;
                    SaveUploadedFile(file, newActivityPackage.Id);
                }

                return RedirectToAction("Index");
            }

            return View(activityPackage);
        }
 public ActionResult Create()
 {
     var supplier = SupplierContext.GetAll(p => p.AspNetUserId == CurrentUserId).First();
     var activityPackageViewModel = new ActivityPackageViewModel { SupplierId = supplier.Id };
     return View(activityPackageViewModel);
 }
 public ActionResult Edit(ActivityPackageViewModel activityPackageViewModel, ICollection<HttpPostedFileBase> uploads)
 {
     if (ModelState.IsValid)
     {
         var newActivityPackage = ActivityPackageContext.Save(activityPackageViewModel.ToModel());
         if (uploads != null)
         {
             foreach (var file in uploads)
                 if (file != null)
                     SaveUploadedFile(file, newActivityPackage.Id);
         }
         return RedirectToAction("Index");
     }
     return View(activityPackageViewModel);
 }