Beispiel #1
0
 private void ValidateContract(CreateDaysOffContract contract)
 {
     try
     {
         _createDaysOffContractValidator.ValidateAndThrow(contract,
                                                          $"{ValidatorConstants.RULESET_CREATE}");
     }
     catch (ValidationException ex)
     {
         throw new CreateContractInvalidException(ex.ToListOfMessages());
     }
 }
Beispiel #2
0
        public CreatedDaysOffContract Create(CreateDaysOffContract contract)
        {
            ValidateContract(contract);

            var daysOff = _mapper.Map <DaysOff>(contract);

            var createdDaysOff = _daysOffRepository.Create(daysOff);

            if (daysOff.Status == Model.Enum.DaysOffStatus.Accepted)
            {
                var googleCalendarEventId = this.AddModelToGoogleCalendar(daysOff);

                createdDaysOff.GoogleCalendarEventId = googleCalendarEventId;
            }

            _unitOfWork.Complete();
            return(_mapper.Map <CreatedDaysOffContract>(createdDaysOff));
        }