private int getAverage(IceCream iceCream) { var temp = 0; if (iceCream.Recommendations != null) { foreach (var Rec in iceCream.Recommendations) { temp += Rec.Rank; } temp = temp / iceCream.Recommendations.Count(); } return(temp); }
public bool insertIcecream(IceCream iceCream) { var document = _dbContext._database.GetCollection <IceCream>("iceCreams"); var query = Query.And(Query.EQ("Name", iceCream.Name), Query.EQ("Store", iceCream.Store)); var count = document.FindAs <IceCream>(query).Count(); if (count == 0) { document.Insert(iceCream); return(true); } return(false); }