public async Task <HolidayModel> AddAsync(HolidayModel model, int clientId, int userId) { if (model == null) { throw new ArgumentNullException(); } if (!await _permissionManager.HasPermission(clientId, userId, Permission.CanAddHoliday)) { throw new Exception("User has not permission to perform this operation"); } var result = await _holidayRepository.IsHolidayExistsAsync(clientId, model.Id, model.StartDate, model.EndDate); if (result) { throw new Exception("Already inserted holiday"); } var holiday = _holidayMapper.ConvertToDataModel(model); holiday.ClientId = clientId; holiday = await _holidayRepository.AddAsync(holiday); return(_holidayMapper.ConvertToModel(holiday)); }