public AuthorModel(int mainId, int?authorId) { MainId = mainId; Authors = AuthorObject.GetAuthors(MainId); if (authorId.HasValue) { var author = AuthorObject.GetAuthor(authorId.Value); if (author != null) { AuthorId = author.AuthorId; Affiliation = author.Affiliation; AuthorName = author.Name; AuthorOrcidId = author.OrcidId; IsPrimary = author.IsPrimary; AffiliationType = author.AffiliationEnum; AffiliateEmployeeId = author.EmployeeId; CountryId = author.CountryId ?? Helper.UnitedStatesCountryId; StateId = author.StateId; } } else { CountryId = Helper.UnitedStatesCountryId; } }
public ActionResult GetAuthorPartial(int?id) { if (id.HasValue) { var author = AuthorObject.GetAuthor(id.Value); if (author != null) { return(PartialView("Partials/AuthorsPartial", new AuthorModel(author))); } } return(null); }
public ActionResult SetPrimaryAuthor(int?id) { int mid = 0; if (id.HasValue) { var author = AuthorObject.GetAuthor(id.Value); if (author != null) { mid = author.MainId; if (MainObject.CheckUserHasWriteAccess(mid)) { author.SetAsPrimary(); } } } return(GetAuthorListPartial(mid)); }
public ActionResult SetPrimaryAuthor(int?id) { int sid = 0; if (id.HasValue) { var author = AuthorObject.GetAuthor(id.Value); if (author != null) { sid = author.SortMainId; if (SortMainObject.CheckUserHasWriteAccess(sid)) { author.SetAsPrimary(); } } } return(PartialView("Partials/_authorList", AuthorObject.GetAuthors(sid))); }
public void Save() { if (MainId > 0) { if (AuthorId.HasValue) { var author = AuthorObject.GetAuthor(AuthorId.Value); if (author != null) { author.AffiliationEnum = AffiliationType; author.Affiliation = Affiliation; author.OrcidId = AuthorOrcidId; author.IsPrimary = IsPrimary; author.EmployeeId = AffiliateEmployeeId; author.SetName(AuthorName, AffiliationType, AffiliateEmployeeId); if (AffiliationType == AuthorAffilitionEnum.INL) { author.CountryId = null; author.StateId = null; } else { author.CountryId = CountryId; if (CountryId.HasValue && CountryId.Value == Helper.UnitedStatesCountryId) { author.StateId = StateId; } else { author.StateId = null; } } author.Save(); } } else { AuthorObject.Add(AuthorId, MainId, AffiliateEmployeeId, AuthorName, AffiliationType, Affiliation, AuthorOrcidId, IsPrimary, CountryId, StateId); } } }