Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
            }
        }