Ejemplo n.º 1
0
 public Gift AddNewGift(Gifted.Entities.Gift gift)
 {
     if (mongoServer != null && giftedDB != null)
     {
         giftCollection = giftedDB.GetCollection<Gift>("Gift");
         gift.Id = Guid.NewGuid();
         gift.ModifiedDate = DateTime.UtcNow;
         gift.CreateDate = DateTime.UtcNow;
         giftCollection.Insert(gift);
         return gift;
     }
     else
         return null;
 }
Ejemplo n.º 2
0
 public bool UpdateGift(Guid id, Gifted.Entities.Gift gift)
 {
     if (mongoServer != null && giftedDB != null)
     {
         IMongoQuery query = Query.EQ("_id", id);
         gift.ModifiedDate = DateTime.UtcNow;
         IMongoUpdate update = Update
             .Set("Name", gift.Name)
             .Set("Cost", gift.Cost)
             .Set("Rank", gift.Rank)
             .Set("ModifiedDate", gift.ModifiedDate);
         SafeModeResult result = giftCollection.Update(query, update);
         return result.UpdatedExisting;
     }
     else
         return false;
 }