public void CreateNullTest() { AlbumManager albumMng = new AlbumManager(); Album album = null; Response actual = albumMng.Create(album); bool expected = false; Console.WriteLine(actual.Message); Assert.AreEqual(expected, actual.Status); }
public AlbumModel Create(AlbumModel model) { var album = _albumManager.Create(model); return(new AlbumModel() { Id = album.Id, SingerId = album.SingerId, CreatorId = album.Creator.Id, CreatorName = album.Creator.NickName, Name = album.Name, SingerName = album.Singer.Name, CreationTime = album.CreationTime }); }
public void CreateRelesedViolationTest() { AlbumManager albumMng = new AlbumManager(); Album album = new Album() { name = "Relesed Violation", relesed = 2022 }; Response actual = albumMng.Create(album); bool expected = false; Console.WriteLine(actual.Message); Assert.AreEqual(expected, actual.Status); }
public void CreateEmptyNameTest() { AlbumManager albumMng = new AlbumManager(); Album album = new Album() { name = "", relesed = 1990 }; Response actual = albumMng.Create(album); bool expected = false; Console.WriteLine(actual.Message); Assert.AreEqual(expected, actual.Status); }
public ActionResult Create(ManageAlbumViewModel model, System.Web.HttpPostedFileBase file) { if (!ModelState.IsValid) { return(View(model)); } if (file != null && file.ContentLength > 0) { var fileName = System.IO.Path.Combine(Request.MapPath("~/Content/Album/"), System.IO.Path.GetFileName(file.FileName)); file.SaveAs(fileName); model.Cover = System.IO.Path.GetFileName(file.FileName); } else { model.Cover = "Album_1.jpg"; } model.UserId = AccountManager.GetId(CookieHepler.GetCookie("user")); model.Id = AlbumManager.Create(model); return(RedirectToAction("Detail", new { id = model.Id })); }
public ActionResult Create(ManageAlbumViewModel model, System.Web.HttpPostedFileBase file) { if (!ModelState.IsValid) { return(View(model)); } if (file != null && file.ContentLength > 0) { var fileName = System.IO.Path.Combine(Request.MapPath("~/Content/Album/"), System.IO.Path.GetFileName(file.FileName)); file.SaveAs(fileName); model.Cover = System.IO.Path.GetFileName(file.FileName); } else { model.Cover = "Album_1.jpg"; } model.UserId = AccountManager.GetId(User.Identity.Name); AlbumManager.Create(model); return(View(new ManageAlbumViewModel())); }