public ActionResult Create(PhotoAchivement photoAchivement, HttpPostedFileBase photo) { AchivementCollection c = db.AchivementCollections.Find(photoAchivement.AchivementCollectionID); if (ModelState.IsValid && photo != null && c.UserID == User.Identity.GetUserId() && c.AchivementType == AchivementTypes.Photo) { photoAchivement.PhotoName = Download.SaveFile(photo, "~/Uploads/PhotoAchivements/Photo/"); db.PhotoAchivements.Add(photoAchivement); db.SaveChanges(); return RedirectToAction("Collection", "Account", new { id = photoAchivement.AchivementCollectionID }); } return View(photoAchivement); }
public ActionResult Edit(PhotoAchivement photoAchivement) { if (ModelState.IsValid) { db.Entry(photoAchivement).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(photoAchivement); }