Make release screenshots optional.

This commit is contained in:
Michael 2017-04-06 17:51:38 -04:00
parent 6f41a9f80f
commit e8b18cbf92
3 changed files with 19 additions and 14 deletions

View file

@ -145,6 +145,8 @@ namespace Project_Unite.Controllers
//Now the download is saved in the DB. Let's get it on the server. //Now the download is saved in the DB. Let's get it on the server.
model.Download.SaveAs(mapped_dir); model.Download.SaveAs(mapped_dir);
if (model.Screenshot != null)
{
download_dir = "~/Uploads/Releases/Screenshots/"; download_dir = "~/Uploads/Releases/Screenshots/";
mapped_dir = Server.MapPath(download_dir); mapped_dir = Server.MapPath(download_dir);
if (!Directory.Exists(mapped_dir)) if (!Directory.Exists(mapped_dir))
@ -158,8 +160,9 @@ namespace Project_Unite.Controllers
} }
download_dir += file_name_d; download_dir += file_name_d;
mapped_dir = Server.MapPath(download_dir); mapped_dir = Server.MapPath(download_dir);
download.ScreenshotUrl = download_dir.Remove(0,1); download.ScreenshotUrl = download_dir.Remove(0, 1);
model.Screenshot.SaveAs(mapped_dir); model.Screenshot.SaveAs(mapped_dir);
}
//Now we just save to the database... //Now we just save to the database...
db.Downloads.Add(download); db.Downloads.Add(download);

View file

@ -45,7 +45,6 @@ namespace Project_Unite.Models
[Required(ErrorMessage = "You must name your build!")] [Required(ErrorMessage = "You must name your build!")]
public string Name { get; set; } public string Name { get; set; }
[Required(ErrorMessage ="A screenshot is necessary for getting users into the game.")]
[DataType(DataType.Upload)] [DataType(DataType.Upload)]
public HttpPostedFileBase Screenshot { get; set; } public HttpPostedFileBase Screenshot { get; set; }

View file

@ -24,7 +24,10 @@
<iframe src="http://youtube.com/embed/@Model.DevUpdateId" frameborder="0" allowfullscreen autoplay="true" style="width:720px;height:480px;"></iframe> <iframe src="http://youtube.com/embed/@Model.DevUpdateId" frameborder="0" allowfullscreen autoplay="true" style="width:720px;height:480px;"></iframe>
} }
@if (!string.IsNullOrWhiteSpace(Model.ScreenshotUrl))
{
<img src="@Model.ScreenshotUrl" style="width:auto;height:auto;max-width:100%" /> <img src="@Model.ScreenshotUrl" style="width:auto;height:auto;max-width:100%" />
}
@Html.Markdown(Model.Changelog) @Html.Markdown(Model.Changelog)
</div> </div>