/// <summary> /// Update the party details /// </summary> /// <param name="updatedParty"></param> /// <returns></returns> /// <exception cref="Exception"></exception> public PartyTable UpdateParty(PartyTable updatedParty) { using (var context = new EntitiesChooseEm()) { //check for party being null? PartyTable party = context.PartyTables.FirstOrDefault(p => p.ID == updatedParty.ID); party.startDate = updatedParty.startDate; party.endDate = updatedParty.endDate; party.locationLatitude = updatedParty.locationLatitude; party.locationLongitude = updatedParty.locationLongitude; party.privacy = updatedParty.privacy; party.Name = updatedParty.Name; party.RowVersion = updatedParty.RowVersion; party.AvailablePlaces = updatedParty.AvailablePlaces; context.PartyTables.Attach(party); context.Entry(party).State = System.Data.Entity.EntityState.Modified; var num = context.SaveChanges(); if (num != 1) { throw new Exception("Concurrency Error"); } } return(updatedParty); }
public void SetRating(int total, string uri, long partyID, byte[] atmRowVersion) { using (var db = new EntitiesChooseEm()) { var aux = db.SongsForPartyTables.First(p => p.songURL == uri && p.partyID == partyID); aux.rating = total; aux.RowVersion = atmRowVersion; db.SongsForPartyTables.Attach(aux); db.Entry(aux).State = System.Data.Entity.EntityState.Modified; var num = db.SaveChanges(); if (num != 1) { throw new Exception("Concurrency Error"); } } }