public bool ReplaceSchoolList(Oldschool data)
        {
            FilterDefinition <Oldschool> filter =
                Builders <Oldschool> .Filter.Eq(x => x.Id, data.Id);

            var updateBuilders = Builders <Oldschool> .Update
                                 .Set(x => x.SchoolList, data.SchoolList);

            var result = Collection.UpdateOne(filter, updateBuilders);

            return(result.IsAcknowledged);
        }
 public bool Insert(Oldschool data)
 {
     try
     {
         Collection.InsertOne(data);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
        public bool Update(Oldschool data)
        {
            FilterDefinition <Oldschool> filter =
                Builders <Oldschool> .Filter.Eq(x => x.Id, data.Id);

            var updateBuilders = Builders <Oldschool> .Update
                                 .Set(x => x.Name, data.Name)
                                 .Set(x => x.LastUpdateDate, DateTime.UtcNow);

            var result = Collection.UpdateOne(filter, updateBuilders);

            return(result.IsAcknowledged);
        }
        public bool Upsert1(Oldschool data)
        {
            var utcnow = DateTime.UtcNow;

            data.CreateDate = utcnow;
            var result = Collection.ReplaceOne(o => o.Id == data.Id,
                                               data,
                                               new ReplaceOptions()
            {
                IsUpsert = true
            });

            return(result.IsAcknowledged);
        }
        public bool Upsert2(Oldschool data)
        {
            var utcnow = DateTime.UtcNow;

            FilterDefinition <Oldschool> filter =
                Builders <Oldschool> .Filter.Eq(x => x.Id, data.Id);

            var updateBuilders = Builders <Oldschool> .Update
                                 .Set(x => x.Name, data.Name)
                                 .SetOnInsert(x => x.CreateDate, utcnow)
                                 .Set(x => x.LastUpdateDate, utcnow);

            var updateOption = new UpdateOptions
            {
                IsUpsert = true
            };

            var result = Collection.UpdateOne(filter, updateBuilders, updateOption);

            return(result.IsAcknowledged);
        }
        public bool Delete(Oldschool data)
        {
            var result = Collection.DeleteOne(x => x.Id == data.Id);

            return(result.IsAcknowledged);
        }