public async Task <Models.LicenseType> ModifyLicenseType([Service] DBAttendanceContext dBAttendanceContext, LicenseTypeInput input) { try { var licenseType = await dBAttendanceContext.LicenseType.FindAsync(input.Id); if (licenseType != null) { licenseType.Description = input.Description; licenseType.MaximumDays = input.MaximumDays; await dBAttendanceContext.SaveChangesAsync(); return(licenseType); } else { throw new QueryException("Tipo de licencia no encontrada."); } } catch (System.Exception e) { throw new QueryException(e.Message); } }
public async Task <Models.LicenseType> AddLicenseType([Service] DBAttendanceContext dBAttendanceContext, LicenseTypeInput input) { try { var licenseType = new Models.LicenseType { Description = input.Description, MaximumDays = input.MaximumDays }; dBAttendanceContext.LicenseType.Add(licenseType); await dBAttendanceContext.SaveChangesAsync(); return(licenseType); } catch (System.Exception e) { throw new QueryException(e.Message); } }