Exemplo n.º 1
0
        public async Task <CertificateBatch> GetCertificateBatchByIDFull(long id)
        {
            var param = new DynamicParameters();

            param.Add("@ID", id);

            var mapper = new CertificateBatchMapper();

            return((await SqlMapper.QueryAsync(_unitOfWork.Connection,
                                               "GetCertificateBatchByIDFull",
                                               new[]
            {
                typeof(CertificateBatch),
                typeof(Certificate),
                typeof(Premise),
                typeof(Premise),
                typeof(Comment),
                typeof(Menu)
            },
                                               obj =>
            {
                return mapper.Map(obj[0] as CertificateBatch,
                                  obj[1] as Certificate,
                                  obj[2] as Premise,
                                  obj[3] as Premise,
                                  obj[4] as Comment,
                                  obj[5] as Menu);
            },
                                               param,
                                               splitOn: "ID,CertificateID,PremID,MailPremID,CommentID,MenuID",
                                               commandType: CommandType.StoredProcedure,
                                               transaction: _unitOfWork.Transaction)).FirstOrDefault());
        }
Exemplo n.º 2
0
        public async Task <IList <CertificateBatch> > BatchFullFilter(CertificateBatchFilter filter)
        {
            var statusList = new DataTable();

            statusList.Columns.Add("Val", typeof(int));

            if (filter.Status?.Any() ?? false)
            {
                foreach (var status in filter.Status)
                {
                    statusList.Rows.Add((int)status);
                }
            }

            var param = new DynamicParameters();

            param.Add("@From", filter.From);
            param.Add("@To", filter.To);
            param.Add("@RequestID", filter.RequestID);
            param.Add("@Status", statusList.AsTableValuedParameter("dbo.SmallIntType"));

            var mapper = new CertificateBatchMapper();

            return((await SqlMapper.QueryAsync(_unitOfWork.Connection,
                                               "SelectCertificateBatchFull",
                                               new[]
            {
                typeof(CertificateBatch),
                typeof(Certificate),
                typeof(Premise),
                typeof(Premise),
                typeof(Comment)
            },
                                               obj =>
            {
                return mapper.Map(obj[0] as CertificateBatch,
                                  obj[1] as Certificate,
                                  obj[2] as Premise,
                                  obj[3] as Premise,
                                  obj[4] as Comment);
            },
                                               param,
                                               splitOn: "ID,CertificateID,PremID,MailPremID,CommentID",
                                               commandType: CommandType.StoredProcedure,
                                               transaction: _unitOfWork.Transaction)).Distinct().ToList());
        }