Ejemplo n.º 1
0
        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" );
            }
        }
Ejemplo n.º 2
0
 public void Insert( Replay replay )
 {
     _db.Replays.InsertOnSubmit( replay );
 }
Ejemplo n.º 3
0
 public void Delete( Replay replay )
 {
     _db.Replays.DeleteOnSubmit( replay );
 }
Ejemplo n.º 4
0
 public ActionResult Create()
 {
     var replays = new Replay();
     return View( replays );
 }
Ejemplo n.º 5
0
		private void detach_Replays(Replay entity)
		{
			this.SendPropertyChanging();
			entity.ReplayUser = null;
		}
Ejemplo n.º 6
0
		private void attach_Replays(Replay entity)
		{
			this.SendPropertyChanging();
			entity.ReplayUser = this;
		}
Ejemplo n.º 7
0
 partial void DeleteReplay(Replay instance);
Ejemplo n.º 8
0
 partial void UpdateReplay(Replay instance);
Ejemplo n.º 9
0
 partial void InsertReplay(Replay instance);