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 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); }