public ActionResult AddAlbum(AlbumViewModel avm) { if(ModelState.IsValid) { using (new UnitOfWork(_currentContext)) { var album = new Album { Title = avm.Title, Text = avm.Text, LastChangeAt = DateTime.Now, Account = accountRepository.GetByUsername(CurrentUserName) }; albumRepository.Add(album); } TempData[Const.ActionResultInfo] = "Альбом успешно добавлен"; return RedirectToAction("Gallery"); } TempData[Const.ActionErrorInfo] = "Ошибка добавления альбома. Проверьте корректность заполненных данных"; return View(avm); }
/// <summary> /// Create a new Album object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="text">Initial value of the Text property.</param> /// <param name="accountId">Initial value of the AccountId property.</param> /// <param name="lastChangeAt">Initial value of the LastChangeAt property.</param> public static Album CreateAlbum(global::System.Int32 id, global::System.String title, global::System.String text, global::System.Int32 accountId, global::System.DateTime lastChangeAt) { Album album = new Album(); album.Id = id; album.Title = title; album.Text = text; album.AccountId = accountId; album.LastChangeAt = lastChangeAt; return album; }
/// <summary> /// Deprecated Method for adding a new object to the AlbumSet EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAlbumSet(Album album) { base.AddObject("AlbumSet", album); }