public async Task<ActionResult> Create(PhotographViewModel model) { if (ModelState.IsValid) { // TODO: Talvez redimensionar? //var fileName = Guid.NewGuid().ToString() + Path.GetExtension(model.Image.FileName); var banner = new Banner { // UriPath = Path.Combine("Public/BannerPhotographs", fileName), UriPath=model.UriPath, PublicationDate = model.PublicationDate, RemovalDate = model.RemovalDate, IsVisible = model.IsVisible }; //banner.BannerTexts.Add( // new BannerTranslation // { // BannerPhotographId = banner.Id, // LanguageCode = LanguageDefinitions.DefaultLanguage, // Title = model.I18nTexts[0].Title // }); db.Banners.Add(banner); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(model); }
// GET: /BackOffice/BannerPhotograph/Create public ActionResult Create() { var banner = new Banner(); banner.Translations.Add(new BannerTranslation { LanguageCode = LanguageDefinitions.DefaultLanguage }); return View(new BannerPhotographEditViewModel(banner)); }
public BannerPhotographEditViewModel(Banner banner) { this.Banner = banner; }