예제 #1
0
        public static async Task<UpdateBranchOutput> Update(UpdateBranchInput Parameters)
        {
            UpdateBranchOutput output = new UpdateBranchOutput()
            {
                Type = 0,
                Message = "Hata Oluştu"
            };

            var filter = Builders<Branch>.Filter.Eq(Parameters.FilterCol, Parameters.FilterVal);

            var update = Builders<Branch>.Update
                .Set(x => x.Name, Parameters.Name)
                .Set(x => x.Address, Parameters.Address)
                .Set(x => x.Phone, Parameters.Phone);


            var projection = Builders<Branch>.Projection;
            var project = projection.Exclude("_id");

            //var result = await db.GetCollection<Branch>("Branches").UpdateOne(filter, update);
            var result = await db.GetCollection<Branch>("Branches").UpdateManyAsync(filter, update);
            // var branches = db.GetCollection<Branch>("Branches").Find("{}").Project(project).ToList();

            if (result.ModifiedCount > 0)
            {
                output.Type = 1;
                output.Message = "Kayıt başarıyla güncellendi";
            }

            return output;
        }
예제 #2
0
 public async Task <UpdateBranchOutput> UpdateBranch(UpdateBranchInput Parameters)
 {
     return(await BranchManager.Update(Parameters));
 }