// // GET: /Contribution/ public ActionResult Index() { var con0 = from c in db.ContributionTypeTable where c.ContributionTypeID == 1 select c; if (con0.Count() == 0) { ContributionType con1 = new ContributionType(); con1.ContributionTypeID = 1; con1.ContributionTypeName = "Money"; ContributionType con2 = new ContributionType(); con2.ContributionTypeID = 2; con2.ContributionTypeName = "Food"; ContributionType con3 = new ContributionType(); con3.ContributionTypeID = 3; con3.ContributionTypeName = "Beverage"; ContributionType con4 = new ContributionType(); con4.ContributionTypeID = 4; con4.ContributionTypeName = "Else"; db.ContributionTypeTable.Add(con1); db.ContributionTypeTable.Add(con2); db.ContributionTypeTable.Add(con3); db.ContributionTypeTable.Add(con4); db.SaveChanges(); } var contributiontable = db.ContributionTable.Include(c => c.contributiontype); return(View(contributiontable.ToList())); }
public IActionResult Get(int id) { IActionResult ret = null; ContributionType entity = null; try { using (var db = new BTAContext()) { entity = db.ContributionType.Find(id); if (entity != null) { ret = StatusCode(StatusCodes.Status200OK, entity); } else { ret = StatusCode(StatusCodes.Status404NotFound, "Can't Find contribution type for id: " + id.ToString()); } } } catch (Exception ex) { Logger.LogError(ex, "An exception occurred while trying to retrieve a single contribution type."); ret = StatusCode(StatusCodes.Status500InternalServerError); } return(ret); }
public void Populate(ContributionType contributionType, ActivityTechnology contributionTechnology) { this.Populate(null); this.Type = contributionType; this.Technology = contributionTechnology; }
private static string StoreAndGetIssueRelation(bool isInternal, string issueType) { string relation = (isInternal ? "Internal" : "External") + issueType; ContributionType contributionType = Enum.Parse <ContributionType>(relation); stats[contributionType]++; return(relation); }
public Contribution(int id, int userId, DateTime date, ContributionType type = ContributionType.None, bool like = false, bool report = false) { ID = id; UserID = userId; Date = date; Type = type; Like = like; Report = report; }
public ActionResult Edit(ContributionType contributiontype) { if (ModelState.IsValid) { _contributiontypeRepository.InsertOrUpdate(contributiontype); _contributiontypeRepository.Save(); return(RedirectToAction("Index")); } return(View()); }
private string SetContributionTypeAndRemoveString(string copyrightString, string strToMatch, string replace, ContributionType type) { var modified = copyrightString.Replace(strToMatch, replace); if (modified != copyrightString) { this.type = type; } return(modified); }
public void Populate( ContributionType contributionType, ActivityTechnology contributionTechnology, ItemVisibility visibility) { this.Populate(default(Contribution)); this.Type = contributionType; this.Technology = contributionTechnology; this.VisibilityValue = visibility?.Description; }
/// <summary> /// Creates a new SongContributor based on an input string /// </summary> /// <param name="modifiedCopyright">A copyright string containing 1 author</param> /// <param name="originalCopyright">The original copyright string where an explicit partial removal is required</param> public SongContributor(string modifiedCopyright, string originalCopyright) { modifiedCopyright = modifiedCopyright.Trim() // input has lowercase L instead of 1 so regex breaks .Replace("Nicolaus Ludwig von Zinzendorf, 1700-60, v. l", "Nicolaus Ludwig von Zinzendorf, 1700-60, v. 1") .Replace("Graham D S Deans", "Graham DS Deans") .Replace("David G. Preston", "David G Preston") .Replace("*", ""); // " Text (mod.)" - remove and manually handle // "as in Scottish Paraphrases" is appendix data // "From [A-Z ](, [0-9]{4})? is usually from a book // "By permission pf" followed by a copyright text // Copyright Control (no (c) so difficult to match // [Cc]ent - e.g. Latin 12th Cent. // Once removed, parse text like usual // starts with "tr. by" is a translation // "v. [0-9]?[0-9]{0,9} by" is a specific author for a verse modifiedCopyright = this.SetContributionTypeAndRemoveString( modifiedCopyright, "tr. by ", "", ChristianHymns.ContributionType.Translator); modifiedCopyright = this.SetContributionTypeAndRemoveString( modifiedCopyright, "alt. by", "", ChristianHymns.ContributionType.Alterer); modifiedCopyright = this.SetContributionTypeAndRemoveString( modifiedCopyright, "altd. by", "", ChristianHymns.ContributionType.Alterer); modifiedCopyright = this.SetContributionTypeAndRemoveString( modifiedCopyright, "translated and adapted by ", "", ChristianHymns.ContributionType.Alterer); modifiedCopyright = this.SetContributionTypeAndRemoveString( modifiedCopyright, "translated and adapted by", "", ChristianHymns.ContributionType.Alterer); modifiedCopyright = modifiedCopyright.Replace(" and ", ""); this.modifiedCopyright = modifiedCopyright; this.originalCopyright = originalCopyright; var nameOrig = this.Name(); var upper = this.Name().ToUpper(); if (upper != string.Empty && upper == nameOrig) { type = ChristianHymns.ContributionType.Book; } if (type == null) { this.type = ChristianHymns.ContributionType.Author; } }
protected override OpResult _Store(ContributionType _obj) { if (_obj == null) { return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "ContributionType object cannot be created as it is null")); } if (Exists(_obj)) { ExecuteNonQuery(GetQuery_UpdateQuery(_obj)); return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj)); } ExecuteNonQuery(GetQuery_InsertQuery(_obj)); _obj.FromDb = true; return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj)); }
public IActionResult Put([FromBody] ContributionType contributionType) { var returnResult = new ContributionTypeActionResult(false, new List <string>(), null); if (contributionType != null) { try { using (var db = new BTAContext()) { var resultContributionType = db.ContributionType.SingleOrDefault(x => x.ContributionTypeId == contributionType.ContributionTypeId); if (resultContributionType != null) { resultContributionType.CategoryId = contributionType.CategoryId; resultContributionType.ContributionTypeName = contributionType.ContributionTypeName; resultContributionType.Description = contributionType.Description; db.SaveChanges(); returnResult.Success = true; returnResult.Data = resultContributionType; returnResult.StatusMessages.Add("Successfully updated contribution type."); } else { returnResult.Success = false; returnResult.StatusMessages.Add(string.Format("Unable to locate contribution type for id: {0}", contributionType.ContributionTypeId)); returnResult.Data = null; } } } catch (Exception e) { returnResult.Success = false; returnResult.StatusMessages.Add(e.Message); returnResult.Data = null; } } else { returnResult.Success = false; returnResult.StatusMessages.Add("Empty contribution type posted for update."); returnResult.Data = null; } return(StatusCode(StatusCodes.Status200OK, returnResult)); }
/* */ public Contribution(String decTempAmount, String stringTempFullName, String stringTempContributionType, String stringTempContributionDate, String stringTempFullCityStateZip = "", String stringTempFullStreetAddress = "", String stringTempCandidateCommittee = "", String stringTempOccupation = "", String stringTempInKindDescription = "") { this.decAmount = Convert.ToDecimal(decTempAmount); this.enumCotributionType = this.FloridaContributionTypeToEnum(stringTempContributionType); DateTime dtTempContributionDate; /* Out Variables Are Cool. Like Fezzes. */ if (DateTime.TryParse(stringTempContributionDate, out dtTempContributionDate)) { this.dtContributionDate = dtTempContributionDate; } else { this.dtContributionDate = this.dtDefault; listSimpleErrors.Add("We have a bad date: |" + stringTempContributionDate + "|"); } this.stringFullName = stringTempFullName; this.stringCandidateCommittee = stringTempCandidateCommittee; this.stringFullCityStateZip = stringTempFullCityStateZip; this.stringFullStreetAddress = stringTempFullStreetAddress; this.stringOccupation = stringTempOccupation; this.stringInKindDescription = stringTempInKindDescription; }
// // GET: /Contribution/Create public ActionResult Create() { var contribute = from con in db.ContributionTypes select con; int number = contribute.Count<ContributionType>(); if (number == 0) { ContributionType ct1 = new ContributionType(); ct1.type = "food"; db.ContributionTypes.Add(ct1); db.SaveChanges(); ContributionType ct2 = new ContributionType(); ct2.type = "money"; db.ContributionTypes.Add(ct2); db.SaveChanges(); ContributionType ct3 = new ContributionType(); ct3.type = "berverage"; db.ContributionTypes.Add(ct3); db.SaveChanges(); } ViewBag.TypeID = new SelectList(db.ContributionTypes, "ID", "type"); ViewBag.E_ID = new SelectList(db.Events, "E_ID", "Name"); return View(); }
public IActionResult Post([FromBody] ContributionType contributionType) { var returnResult = new ContributionTypeActionResult(false, new List <string>(), null); if (contributionType != null) { try { using (var db = new BTAContext()) { var resultContributionType = db.ContributionType.Add(contributionType); db.SaveChanges(); var entity = resultContributionType.Entity; if (entity != null) { returnResult.Success = true; returnResult.StatusMessages.Add("Successfully added contribution type."); returnResult.Data = entity; } } } catch (Exception e) { Logger.LogError(e, "An exception occurred while attempting to add a contribution type."); returnResult.Success = false; returnResult.StatusMessages.Add("An exception occurred while attempting to add a contribution type."); returnResult.Data = null; } } else { returnResult.Success = false; returnResult.StatusMessages.Add("Empty contribution type posted for add."); returnResult.Data = null; } return(StatusCode(StatusCodes.Status200OK, returnResult)); }
ContributionType FloridaContributionTypeToEnum(String stringType) { ContributionType contribReturn = ContributionType.UNKNOWN; switch (stringType) { case "CHK": contribReturn = ContributionType.CHECK; break; case "CAS": contribReturn = ContributionType.CASH; break; case "INK": contribReturn = ContributionType.INKIND; break; case "REF": contribReturn = ContributionType.REFUND; break; } return(contribReturn); }
private static async Task TestContributionAsync() { IEnumerable <ItemVisibility> visibilities; try { visibilities = await App.API.GetSharingPreferencesAsync(); } catch (Exception ex) { await App.MessageDialogManager.ShowAsync( "Error", $"Error in {nameof(ApiClient.GetSharingPreferencesAsync)} method. Error: {ex}"); return; } IEnumerable <AwardContribution> contributionAreas; try { contributionAreas = await App.API.GetContributionAreasAsync(); } catch (Exception ex) { await App.MessageDialogManager.ShowAsync( "Error", $"Error in GetContributionAreasAsync method. Error: {ex}"); return; } Contributions contributions; try { contributions = await App.API.GetContributionsAsync(0, 25); } catch (Exception ex) { await App.MessageDialogManager.ShowAsync( "Error", $"Error in GetContributionsAsync method. Error: {ex}"); return; } if (contributions != null) { try { Contribution ctb = contributions.Items.FirstOrDefault(); Contribution contribution = await App.API.GetContributionByIdAsync(ctb.Id.Value); } catch (Exception ex) { await App.MessageDialogManager.ShowAsync( "Error", $"Error in GetContributionByIdAsync method. Error: {ex}"); return; } } IEnumerable <ContributionType> contributionTypes; try { contributionTypes = await App.API.GetContributionTypesAsync(); } catch (Exception ex) { await App.MessageDialogManager.ShowAsync( "Error", $"Error in GetContributionTypesAsync method. Error: {ex}"); return; } if (contributionTypes != null && contributionAreas != null) { ContributionType contributionType = contributionTypes.FirstOrDefault(); AwardContribution awardContribution = contributionAreas.FirstOrDefault(); ContributionArea area = awardContribution.Areas.FirstOrDefault(); var technology = new ContributionTechnology { AwardCategory = awardContribution.AwardCategory, AwardName = area.AwardName, Id = area.Items.FirstOrDefault().Id, Name = area.Items.FirstOrDefault().Name }; var newContribution = new Contribution { Type = contributionType, TypeName = contributionType.Name, Technology = technology, StartDate = DateTime.Now, Title = "MVP API Test", ReferenceUrl = "https://github.com/jamesmcroft/mvp-api-portable", Visibility = visibilities.FirstOrDefault(), AnnualQuantity = 0, SecondAnnualQuantity = 0, AnnualReach = 0, Description = "Hello, World!" }; Contribution submittedContribution; try { submittedContribution = await App.API.AddContributionAsync(newContribution); } catch (Exception ex) { await App.MessageDialogManager.ShowAsync( "Error", $"Error in AddContributionAsync method. Error: {ex}"); return; } if (submittedContribution != null) { submittedContribution.Description = "This is a new description"; try { bool updated = await App.API.UpdateContributionAsync(submittedContribution); } catch (Exception ex) { await App.MessageDialogManager.ShowAsync( "Error", $"Error in UpdateContributionAsync method. Error: {ex}"); return; } try { bool deleted = await App.API.DeleteContributionAsync(submittedContribution.Id.Value); } catch (Exception ex) { await App.MessageDialogManager.ShowAsync( "Error", $"Error in DeleteContributionAsync method. Error: {ex}"); return; } } } }
private async Task AddContribution(long subscriptionId, long pullRequestNumber, PullRequestFile pullRequestFile, string login, ContributionType contributionType, DateTimeOffset?mergedDateTime) { var file = await GetFile(pullRequestFile, subscriptionId); if (file == null || login == null) { return; } var contributor = await GetContributor(login, subscriptionId); var contribution = new Contribution() { ActivityId = pullRequestNumber.ToString(), ContributionType = contributionType, ContributorId = contributor.Id, SubscriptionId = subscriptionId, FileId = file.Id, DateTime = mergedDateTime, ContributorGithubLogin = login }; _dbContext.Add(contribution); }
public Task <IEnumerable <Contribution> > GetByNoteIdAndContributionType(string noteId, ContributionType contributionType) { return(GetByFilters(storedContribution => storedContribution.Entity.NoteId == noteId, storedContribution => storedContribution.Entity.ContributionType == contributionType)); }
public Task <IEnumerable <Contribution> > GetByEmailAndContributionType(string email, ContributionType contributionType) { return(GetByFilters(storedContribution => storedContribution.Entity.UserId == email, storedContribution => storedContribution.Entity.ContributionType == contributionType)); }
public static void Initialize(ModelContext context) { context.Database.EnsureCreated(); // Look for any albums. if (context.Albums.Any()) { return; // DB has been seeded } var mainArtist = new ContributionType { Type = "Main" }; var featuring = new ContributionType { Type = "Featuring" }; var remix = new ContributionType { Type = "Remix" }; context.ContributionTypes.Add(mainArtist); context.ContributionTypes.Add(featuring); context.ContributionTypes.Add(remix); context.SaveChanges(); var albums = new Album[] { new Album { Name = "The First Dose", ReleaseYear = 2020 }, }; foreach (Album a in albums) { context.Albums.Add(a); } context.SaveChanges(); var artists = new Artist[] { new Artist { Name = "Rebelion" }, new Artist { Name = "Radical Redemption" }, }; foreach (Artist a in artists) { context.Artists.Add(a); } context.SaveChanges(); var hardstyle = new Genre { Name = "Hardstyle" }; context.Genres.Add(hardstyle); context.SaveChanges(); var rawHardstyle = new Genre { Name = "Raw Hardstyle", ParentGenreId = 1 }; var euphoricHardstyle = new Genre { Name = "Euphoric Hardstyle", ParentGenreId = 1 }; context.Genres.Add(rawHardstyle); context.Genres.Add(euphoricHardstyle); context.SaveChanges(); context.Discs.Add(new Disc { AlbumId = 1, Number = 1, Name = "Disc One" }); context.SaveChanges(); context.DiscContributions.Add(new DiscContribution { ArtistId = 1, DiscId = 1 }); context.SaveChanges(); context.Tracks.Add(new Track { DiscId = 1, GenreId = 2, Name = "Hardest Baddest M**********r", Number = 2 }); context.Tracks.Add(new Track { DiscId = 1, GenreId = 2, Name = "Modulate", Number = 6 }); context.Tracks.Add(new Track { DiscId = 1, GenreId = 2, Name = "Sydiket", Number = 7 }); context.Tracks.Add(new Track { DiscId = 1, GenreId = 2, Name = "This Is Not A Test", Number = 8 }); context.SaveChanges(); context.Contributions.Add(new Contribution { ContributionTypeId = 1, ArtistId = 1, TrackId = 1 }); context.Contributions.Add(new Contribution { ContributionTypeId = 1, ArtistId = 1, TrackId = 2 }); context.Contributions.Add(new Contribution { ContributionTypeId = 1, ArtistId = 1, TrackId = 3 }); context.Contributions.Add(new Contribution { ContributionTypeId = 1, ArtistId = 1, TrackId = 4 }); context.SaveChanges(); }
public Contribution(string name, string quantity, ContributionType type, Person person) { this.Name = name; this.Quantity = quantity; this.Type = type; }
private DbInsertStatement GetQuery_InsertQuery(ContributionType _obj) { Dictionary <string, DbFieldEntry> fields = GetFields(_obj); return(DbMgr.CreateInsertClause("ContributionTypes", fields)); }
private DbUpdateStatement GetQuery_UpdateQuery(ContributionType _obj) { return(DbMgr.CreateUpdateClause("ContributionTypes", GetFields(_obj), "ContributionTypeID", _obj.ContributionTypeID)); }
public Task <IEnumerable <Contribution> > GetByNoteIdAndContributionType(string noteId, ContributionType contributionType) { return(Get(storedContribution => storedContribution.NoteId == noteId && storedContribution.ContributionType == contributionType)); }
public Contribution(string userId, string noteId, ContributionType contributionType) { UserId = userId; NoteId = noteId; ContributionType = contributionType; }
public Task <IEnumerable <Contribution> > GetByEmailAndContributionType(string email, ContributionType contributionType) { return(Get(storedContribution => storedContribution.UserId == email && storedContribution.ContributionType == contributionType)); }