コード例 #1
0
ファイル: ReplaysController.cs プロジェクト: ck3g/sc_news
        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" );
            }
        }
コード例 #2
0
ファイル: ReplaysRepository.cs プロジェクト: ck3g/sc_news
 public void Insert( Replay replay )
 {
     _db.Replays.InsertOnSubmit( replay );
 }
コード例 #3
0
ファイル: ReplaysRepository.cs プロジェクト: ck3g/sc_news
 public void Delete( Replay replay )
 {
     _db.Replays.DeleteOnSubmit( replay );
 }
コード例 #4
0
ファイル: ReplaysController.cs プロジェクト: ck3g/sc_news
 public ActionResult Create()
 {
     var replays = new Replay();
     return View( replays );
 }
コード例 #5
0
ファイル: Replays.designer.cs プロジェクト: ck3g/sc_news
		private void detach_Replays(Replay entity)
		{
			this.SendPropertyChanging();
			entity.ReplayUser = null;
		}
コード例 #6
0
ファイル: Replays.designer.cs プロジェクト: ck3g/sc_news
		private void attach_Replays(Replay entity)
		{
			this.SendPropertyChanging();
			entity.ReplayUser = this;
		}
コード例 #7
0
ファイル: Replays.designer.cs プロジェクト: ck3g/sc_news
 partial void DeleteReplay(Replay instance);
コード例 #8
0
ファイル: Replays.designer.cs プロジェクト: ck3g/sc_news
 partial void UpdateReplay(Replay instance);
コード例 #9
0
ファイル: Replays.designer.cs プロジェクト: ck3g/sc_news
 partial void InsertReplay(Replay instance);