public List <Pubs> GetAllPubList() { try { List <Pubs> Pubs = new List <Pubs>(); using (var db = new rftkocsmadbEntities3()) { Pubs = db.Pubs.ToList(); foreach (Pubs pub in Pubs) { pub.customerOverallRatings = PubManager.CalculateOverAllRatingPub(pub.pubID.ToString()); } db.SaveChanges(); Pubs = db.Pubs.ToList(); return(Pubs); } } catch (Exception e) { throw e; } }
public void AddOpinion(customerOpinions OpinionToBeAdded) { try { using (var db = new rftkocsmadbEntities3()) { db.customerOpinions.Add(OpinionToBeAdded); db.Pubs.Find(OpinionToBeAdded.pubID).customerOverallRatings = PubManager.CalculateOverAllRatingPub(OpinionToBeAdded.pubID.ToString()); db.SaveChanges(); } } catch (System.Data.Entity.Core.UpdateException e) { Debug.WriteLine(e.ToString()); throw e; } }
public void DeleteOpinionByID(string opinionID) { try { using (var db = new rftkocsmadbEntities3()) { db.customerOpinions.Remove(db.customerOpinions.Find(opinionID)); db.Pubs.Find(db.customerOpinions.Find(opinionID).pubID).customerOverallRatings = PubManager.CalculateOverAllRatingPub(db.customerOpinions.Find(opinionID).pubID.ToString()); db.SaveChanges(); } } catch (Exception e) { throw e; } }