/// <summary> Add one insurance to the database
        /// <param name="insurance"> Inner_Insurance Object - represents the fields of a Insurance in the database </param>
        /// <returns> Returns inputted (and formatted) Insurance </returns>
        /// </summary>
        public async Task <Inner_Insurance> AddInsuranceAsync(Inner_Insurance insurance)
        {
            var newInsurance = Mapper.UnMapInsurance(insurance);

            newInsurance.InsuranceId = (await GetInsuranceAsync()).Max(p => p.InsuranceId) + 1;
            _context.Insurances.Add(newInsurance);
            await _context.SaveChangesAsync();

            return(Mapper.MapInsurance(newInsurance));
        }
 /// <summary> An internal save method when changes are made to the database
 /// <returns> no return </returns>
 /// </summary>
 private async Task Save()
 {
     try
     {
         await _context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         _logger.LogCritical("Error Saving!");
         _logger.LogCritical(ex.Message);
         throw ex;
     }
 }
Пример #3
0
 /// <summary> An internal save method when changes are made to the database
 /// <returns> no return </returns>
 /// </summary>
 private async Task Save()
 {
     await _context.SaveChangesAsync();
 }