Пример #1
0
 public async Task AddVacation(Model.Vacation item)
 {
     try
     {
         await _context.Vacation.InsertOneAsync(item);
     }
     catch (Exception ex)
     {
         // log or manage the exception
         throw ex;
     }
 }
Пример #2
0
        public async Task <bool> UpdateVacation(string id, Model.Vacation item)
        {
            var filter = Builders <Model.Vacation> .Filter.Eq(s => s.Id, id);

            var update = Builders <Model.Vacation> .Update
                         .Set(s => s.Status, item.Status)
                         .Set(s => s.ApprovedBy, item.ApprovedBy)
                         .Set(sim => sim.VacationPeriod, item.VacationPeriod)
                         .CurrentDate(s => s.ChangedOn);

            try
            {
                UpdateResult actionResult
                    = await _context.Vacation.UpdateOneAsync(filter, update);

                return(actionResult.IsAcknowledged &&
                       actionResult.ModifiedCount > 0);
            }
            catch (Exception ex)
            {
                // log or manage the exception
                throw ex;
            }
        }