public ActionResult Create( FormCollection collection ) { try { var replay = new Replay(); var info = new StringBuilder(); foreach (string file in Request.Files) { HttpPostedFileBase postedFile = Request.Files[file]; if (postedFile == null || postedFile.ContentLength == 0) continue; if (postedFile.ContentLength > 8 * 1024 * 1024) { return RedirectToAction( "Create" ); } var newFileName = Guid.NewGuid() + "-" + postedFile.FileName; var newFilePath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory + @"Content\Replays\", Path.GetFileName( newFileName ) ); postedFile.SaveAs( newFilePath ); replay.name = Request.Form["name"]; replay.file_name = newFileName; replay.file_size = postedFile.ContentLength; replay.description = Request.Form["description"]; replay.uploaded_by = replaysRepository.GetAuthorId( User.Identity.Name ); replay.uploaded_at = DateTime.UtcNow; replaysRepository.Insert( replay ); replaysRepository.Save(); } ViewData["Info"] = "Реплей успешно загружен"; return RedirectToAction( "Index" ); } catch { return View( "Error" ); } }
public void Insert( Replay replay ) { _db.Replays.InsertOnSubmit( replay ); }
public void Delete( Replay replay ) { _db.Replays.DeleteOnSubmit( replay ); }
public ActionResult Create() { var replays = new Replay(); return View( replays ); }
private void detach_Replays(Replay entity) { this.SendPropertyChanging(); entity.ReplayUser = null; }
private void attach_Replays(Replay entity) { this.SendPropertyChanging(); entity.ReplayUser = this; }
partial void DeleteReplay(Replay instance);
partial void UpdateReplay(Replay instance);
partial void InsertReplay(Replay instance);