public void Create() { var result = queries.Create(newArtistContract); Assert.IsNotNull(result, "result"); Assert.AreEqual("Tripshots", result.Name, "Name"); artist = repository.Load(result.Id); Assert.IsNotNull(artist, "Artist was saved to repository"); Assert.AreEqual("Tripshots", artist.DefaultName, "Name"); Assert.AreEqual(ContentLanguageSelection.English, artist.Names.SortNames.DefaultLanguage, "Default language should be English"); Assert.AreEqual(1, artist.WebLinks.Count, "Weblinks count"); var archivedVersion = repository.List <ArchivedArtistVersion>().FirstOrDefault(); Assert.IsNotNull(archivedVersion, "Archived version was created"); Assert.AreEqual(artist, archivedVersion.Artist, "Archived version artist"); Assert.AreEqual(ArtistArchiveReason.Created, archivedVersion.Reason, "Archived version reason"); var activityEntry = repository.List <ActivityEntry>().FirstOrDefault(); Assert.IsNotNull(activityEntry, "Activity entry was created"); Assert.AreEqual(artist, activityEntry.EntryBase, "Activity entry's entry"); Assert.AreEqual(EntryEditEvent.Created, activityEntry.EditEvent, "Activity entry event type"); }
public async Task <ActionResult> Create(Create model) { if (string.IsNullOrWhiteSpace(model.NameOriginal) && string.IsNullOrWhiteSpace(model.NameRomaji) && string.IsNullOrWhiteSpace(model.NameEnglish)) { ModelState.AddModelError("Names", ViewRes.EntryCreateStrings.NeedName); } if (string.IsNullOrWhiteSpace(model.Description) && string.IsNullOrWhiteSpace(model.WebLinkUrl)) { ModelState.AddModelError("Description", ViewRes.Artist.CreateStrings.NeedWebLinkOrDescription); } var coverPicUpload = Request.Files["pictureUpload"]; var pictureData = ParsePicture(coverPicUpload, "Picture", ImagePurpose.Main); if (!ModelState.IsValid) { return(View(model)); } var contract = model.ToContract(); contract.PictureData = pictureData; ArtistContract artist; try { artist = await queries.Create(contract); } catch (InvalidPictureException) { ModelState.AddModelError("Picture", "The uploaded image could not processed, it might be broken. Please check the file and try again."); return(View(model)); } return(RedirectToAction("Edit", new { id = artist.Id })); }
public ActionResult Create(Create model) { if (string.IsNullOrWhiteSpace(model.NameOriginal) && string.IsNullOrWhiteSpace(model.NameRomaji) && string.IsNullOrWhiteSpace(model.NameEnglish)) { ModelState.AddModelError("Names", ViewRes.EntryCreateStrings.NeedName); } if (string.IsNullOrWhiteSpace(model.Description) && string.IsNullOrWhiteSpace(model.WebLinkUrl)) { ModelState.AddModelError("Description", ViewRes.Artist.CreateStrings.NeedWebLinkOrDescription); } var coverPicUpload = Request.Files["pictureUpload"]; var pictureData = ParsePicture(coverPicUpload, "Picture"); if (!ModelState.IsValid) { return(View(model)); } var contract = model.ToContract(); contract.PictureData = pictureData; var album = queries.Create(contract); return(RedirectToAction("Edit", new { id = album.Id })); }
public async Task Create() { var result = await _queries.Create(_newArtistContract); result.Should().NotBeNull("result"); result.Name.Should().Be("Tripshots", "Name"); _artist = _repository.Load(result.Id); _artist.Should().NotBeNull("Artist was saved to repository"); _artist.DefaultName.Should().Be("Tripshots", "Name"); _artist.Names.SortNames.DefaultLanguage.Should().Be(ContentLanguageSelection.English, "Default language should be English"); _artist.WebLinks.Count.Should().Be(1, "Weblinks count"); var archivedVersion = _repository.List <ArchivedArtistVersion>().FirstOrDefault(); archivedVersion.Should().NotBeNull("Archived version was created"); archivedVersion.Artist.Should().Be(_artist, "Archived version artist"); archivedVersion.Reason.Should().Be(ArtistArchiveReason.Created, "Archived version reason"); var activityEntry = _repository.List <ActivityEntry>().FirstOrDefault(); activityEntry.Should().NotBeNull("Activity entry was created"); activityEntry.EntryBase.Should().Be(_artist, "Activity entry's entry"); activityEntry.EditEvent.Should().Be(EntryEditEvent.Created, "Activity entry event type"); }