public ApplicationDraft CreateEmpty(CreateDraftAppDto draftAppDto)
        {
            int?     applicationStatus = (int?)Zit.Dto.DtoModels.ApplicationStatus.Черновик;
            DateTime currentDate       = _dateProvider.GetDateTimeNow();
            int      userId            = _userContextRepository.GetCurrentUserId();

            string query         = $@"
INSERT INTO [{nameof(Applications)}]
           ([{nameof(Applications.Agency)}]
           ,[{nameof(Applications.ApplicationDate)}]
           ,[{nameof(Applications.User_Id)}]
           ,[{nameof(Applications.Status)}]
           ,[{nameof(Applications.Process)}])
     VALUES
           (@{nameof(CreateDraftAppDto.Agency)}
           ,@{nameof(currentDate)}
           ,@{nameof(userId)}
           ,@{nameof(applicationStatus)}
           ,@{nameof(CreateDraftAppDto.Process)});
SELECT CAST(SCOPE_IDENTITY() as int)
";
            int    applicationId = _unitOfWork.DbConnection.QuerySingle <int>(query,
                                                                              new
            {
                draftAppDto.Agency,
                currentDate,
                userId,
                applicationStatus,
                draftAppDto.Process
            }
                                                                              , _unitOfWork.DbTransaction);

            string AssessmentQuery = $@"
INSERT INTO [{nameof(Applications_Assessment)}]
           ([{nameof(Applications_Assessment.Application_Id)}])
     VALUES
           (@{nameof(applicationId)})
";

            _unitOfWork.DbConnection.Execute(AssessmentQuery, new { applicationId }, _unitOfWork.DbTransaction);

            return(new ApplicationDraft()
            {
                Id = applicationId,
                agency = draftAppDto.Agency,
                status = (Zit.Dto.DtoModels.ApplicationStatus)applicationStatus,
                process = draftAppDto.Process,
            });
        }
Exemple #2
0
 public ApplicationDraft CreateDraftApplication(CreateDraftAppDto draftAppDto)
 {
     try
     {
         _unitOfWork.OpenConnection();
         _unitOfWork.Begin();
         ApplicationDraft result = _applicationService.CreateDraftApplication(draftAppDto);
         _unitOfWork.Commit();
         return(result);
     }
     finally
     {
         _unitOfWork.CloseConnection();
     }
 }
 public ApplicationDraft CreateDraftApplication(CreateDraftAppDto draftAppDto)
 {
     return(_applicationRepository.CreateEmpty(draftAppDto));
 }
Exemple #4
0
 public ApplicationDraft CreateDraftApplication(CreateDraftAppDto draftAppDto)
 {
     return(_applicationService.CreateDraftApplication(draftAppDto));
 }