Exemplo n.º 1
0
        public async Task <IEnumerable <Model.Request> > SelectRelatedRequests(long id)
        {
            var mapper = new RequestMapper();

            var param = new DynamicParameters();

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

            return((await SqlMapper.QueryAsync(_unitOfWork.Connection,
                                               "SelectRelatedRequest",
                                               new[]
            {
                typeof(Model.Request),
                typeof(RequestLineItem),
                typeof(Premise)
            },
                                               obj =>
            {
                return mapper.Map(obj[0] as Model.Request,
                                  obj[1] as RequestLineItem,
                                  obj[2] as Premise);
            },
                                               param,
                                               splitOn: "ID,LineItemID,PremiseID",
                                               commandType: CommandType.StoredProcedure,
                                               transaction: _unitOfWork.Transaction)).Distinct());
        }
Exemplo n.º 2
0
        public async Task <Model.Request> GetRequestByIDBasic(long id)
        {
            var param = new DynamicParameters();

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

            var mapper = new RequestMapper();

            return((await SqlMapper.QueryAsync <Model.Request>(_unitOfWork.Connection,
                                                               "GetRequestByIDBasic",
                                                               new[]
            {
                typeof(Model.Request),
                typeof(RequestLineItem),
                typeof(Characteristic)
            },
                                                               obj =>
            {
                return mapper.Map(obj[0] as Model.Request,
                                  lineItem: obj[1] as RequestLineItem,
                                  lineItemChar: obj[2] as Characteristic);
            },
                                                               param,
                                                               splitOn: "ID,LineItemID,LineItemCharID",
                                                               commandType: CommandType.StoredProcedure,
                                                               transaction: _unitOfWork.Transaction)).FirstOrDefault());
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <Model.Request> > GetRecentRequest(Guid ID,
                                                                          long?rowFrom  = 0,
                                                                          long?rowCount = 10)
        {
            var mapper = new RequestMapper();

            var param = new DynamicParameters();

            param.Add("@ID", ID);
            param.Add("@RowFrom", rowFrom);
            param.Add("@RowCount", rowCount);

            return((await SqlMapper.QueryAsync(_unitOfWork.Connection,
                                               "GetCustomerRecentRequest",
                                               new[]
            {
                typeof(Model.Request),
                typeof(RequestLineItem)
            },
                                               obj =>
            {
                return mapper.Map(obj[0] as Model.Request,
                                  obj[1] as RequestLineItem);
            },
                                               param,
                                               splitOn: "ID,LineItemID",
                                               commandType: CommandType.StoredProcedure,
                                               transaction: _unitOfWork.Transaction)).Distinct());
        }
Exemplo n.º 4
0
        public async Task <Model.Request> GetRequestByID(long id)
        {
            var param = new DynamicParameters();

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

            var mapper = new RequestMapper();

            return((await SqlMapper.QueryAsync(_unitOfWork.Connection,
                                               "GetRequestByID",
                                               new[]
            {
                typeof(Model.Request),
                typeof(Code),
                typeof(Code),
                typeof(HalalTeam),
                typeof(Premise),
                typeof(Characteristic),
                typeof(RFA),
                typeof(Log),
                typeof(Attachment),
                typeof(RequestLineItem),
                typeof(Review),
                typeof(ReviewLineItem),
                typeof(Characteristic)
            },
                                               obj =>
            {
                return mapper.Map(obj[0] as Model.Request,
                                  obj[1] as Code,
                                  obj[2] as Code,
                                  obj[3] as HalalTeam,
                                  obj[4] as Premise,
                                  obj[5] as Characteristic,
                                  obj[6] as RFA,
                                  obj[7] as Log,
                                  obj[8] as Attachment,
                                  obj[9] as RequestLineItem,
                                  obj[10] as Review,
                                  obj[11] as ReviewLineItem,
                                  obj[12] as Characteristic);
            },
                                               param,
                                               splitOn: "ID,CCID,GCID,HalalTeamID,PremiseID,CharID,RFAID,LogID,AttID,LineItemID,ReviewID," +
                                               "ReviewLineItemID,LiCharID",
                                               commandType: CommandType.StoredProcedure,
                                               transaction: _unitOfWork.Transaction)).FirstOrDefault());
        }
Exemplo n.º 5
0
        static void Execute(ISystem system, string path)
        {
            IEnumerable <IEnumerable <string> > allInputs = ReadInputs(path);

            foreach (var inputs in allInputs)
            {
                foreach (string input in inputs)
                {
                    system.Form.Insert(input);
                }
                var request = RequestMapper.Map(system.Form);
                var result  = ServeRequest(request);
                system.Display.Print(result);
                Console.WriteLine("==============================================================");
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Get all request records
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Request> GetAllRequests()
 {
     using (var command = new SqlCommand("sp_GetAllRequests", _connection))
     {
         command.CommandType = CommandType.StoredProcedure;
         var requestList = new List <Request>();
         using (var reader = command.ExecuteReader())
         {
             while (reader.Read())
             {
                 var request = RequestMapper.Map(reader);
                 requestList.Add(request);
             }
         }
         return(requestList);
     }
 }
Exemplo n.º 7
0
        public async Task <Model.Request> GetRequestByRefID(string refID)
        {
            var param = new DynamicParameters();

            param.Add("@RefID", refID);

            var mapper = new RequestMapper();

            return((await SqlMapper.QueryAsync(_unitOfWork.Connection,
                                               "GetRequestByRefID",
                                               new[]
            {
                typeof(Model.Request),
                typeof(HalalTeam),
                typeof(Premise),
                typeof(Characteristic),
                typeof(RFA),
                typeof(Log),
                typeof(Attachment),
                typeof(RequestLineItem),
                typeof(Review),
                typeof(ReviewLineItem),
                typeof(Characteristic)
            },
                                               obj =>
            {
                Model.Request re = obj[0] as Model.Request;
                HalalTeam ha = obj[1] as HalalTeam;
                Premise pr = obj[2] as Premise;
                Characteristic ch = obj[3] as Characteristic;
                RFA r = obj[4] as RFA;
                Log l = obj[5] as Log;
                Attachment att = obj[6] as Attachment;
                RequestLineItem rli = obj[7] as RequestLineItem;
                Review rev = obj[8] as Review;
                ReviewLineItem revli = obj[9] as ReviewLineItem;
                Characteristic licha = obj[10] as Characteristic;

                return mapper.Map(re, null, null, ha, pr, ch, r, l, att, rli, rev, revli, licha);
            },
                                               param,
                                               splitOn: "ID,HalalTeamID,PremiseID,CharID,RFAID,LogID,AttID,LineItemID,ReviewID," +
                                               "ReviewLineItemID,LiCharID",
                                               commandType: CommandType.StoredProcedure,
                                               transaction: _unitOfWork.Transaction)).FirstOrDefault());
        }
Exemplo n.º 8
0
 public Request GetRequestById(int id)
 {
     using (var command = new SqlCommand("sp_GetRequestById", _connection))
     {
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@RequestId", id);
         var request = new Request();
         using (var reader = command.ExecuteReader())
         {
             while (reader.Read())
             {
                 request = RequestMapper.Map(reader);
             }
         }
         return(request);
     }
 }
Exemplo n.º 9
0
 public IEnumerable <Request> GetAllRequestsByStatus(int status)
 {
     using (var command = new SqlCommand("sp_GetAllRequestsByState", _connection))
     {
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@State", status);
         var requestList = new List <Request>();
         using (var reader = command.ExecuteReader())
         {
             while (reader.Read())
             {
                 var request = RequestMapper.Map(reader);
                 requestList.Add(request);
             }
         }
         return(requestList);
     }
 }
Exemplo n.º 10
0
        public async Task <Model.Request> ValidateRequest
            (Scheme?Scheme, SubScheme?SubScheme, Premise premise)
        {
            var dp = DataConverter.ToPremiseData(premise);

            var param = new DynamicParameters();

            param.Add("@Scheme", (int)Scheme);
            if (SubScheme != null)
            {
                param.Add("@SubScheme", (int)SubScheme);
            }
            else
            {
                param.Add("@SubScheme", SubScheme);
            }
            param.Add("@Premise", dp.AsTableValuedParameter("dbo.PremiseType"));

            var mapper = new RequestMapper();

            return((await SqlMapper.QueryAsync <Model.Request>(_unitOfWork.Connection,
                                                               "ValidateRequest",
                                                               new[]
            {
                typeof(Model.Request),
                typeof(Model.RequestLineItem),
                typeof(Model.Premise)
            },
                                                               obj =>
            {
                return mapper.Map(obj[0] as Model.Request,
                                  obj[1] as RequestLineItem,
                                  obj[2] as Premise);
            },
                                                               param,
                                                               splitOn: "ID,LineItemID,PremiseID",
                                                               commandType: CommandType.StoredProcedure,
                                                               transaction: _unitOfWork.Transaction)).FirstOrDefault());
        }
Exemplo n.º 11
0
        /// <summary>
        /// Deploys a new android in the field.
        /// </summary>
        /// <param name="teamId">The unique identifier of the registered team that is sending this request.</param>
        /// <param name="androidId">The unique identifier of the deployed android this reuest is meant for.</param>
        /// <param name="request">The actual request.</param>
        /// <returns>The android the request is for.</returns>
        public async Task <AndroidDto> SendRequest(Guid teamId, Guid androidId, AndroidRequestDto request)
        {
            Team teamToCheck = await _dbContext.Teams.SingleOrDefaultAsync(x => x.Id == teamId);

            if (teamToCheck == null)
            {
                throw new HtfValidationException("The specified team is unknown!");
            }
            if (!Crypt.EnhancedVerify(request.Password, teamToCheck.Password))
            {
                throw new HtfValidationException("The specified password is not correct!");
            }
            Android androidToRequest = await _dbContext.Androids.SingleOrDefaultAsync(x => x.Id == androidId);

            if (androidToRequest == null)
            {
                throw new HtfValidationException("The specified android is unknown!");
            }
            if (androidToRequest.Compromised)
            {
                throw new HtfValidationException("The specified android is compromised!");
            }
            if (androidToRequest.AutoPilot == AutoPilot.Level1)
            {
                throw new HtfValidationException("The specified level-1 android does not support manual requests!");
            }

            SensoryDataRequest requestToCreate = _requestMapper.Map(request);

            requestToCreate.AndroidId = androidId;
            requestToCreate.TimeStamp = DateTime.UtcNow;
            await _dbContext.SensoryDataRequests.AddAsync(requestToCreate);

            await _dbContext.SaveChangesAsync();

            return(_androidMapper.Map(androidToRequest));
        }
Exemplo n.º 12
0
 private async Task WhenMapped()
 {
     _mappedRequest = await _requestMapper.Map(_inputRequest, _downstreamReRoute);
 }
Exemplo n.º 13
0
 private async Task WhenMapped()
 {
     _mappedRequest = await _requestMapper.Map(_inputRequest);
 }
Exemplo n.º 14
0
        public async Task <Model.Request> GetParentRequest
            (Scheme?Scheme, SubScheme?SubScheme, Premise premise,
            RequestStatus[] statuses, RequestType[] requestTypes)
        {
            var statusTable = new DataTable();

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

            if (statuses?.Any() ?? false)
            {
                foreach (var status in statuses)
                {
                    statusTable.Rows.Add(status);
                }
            }

            var typeTable = new DataTable();

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

            if (requestTypes?.Any() ?? false)
            {
                foreach (var rtype in requestTypes)
                {
                    typeTable.Rows.Add(rtype);
                }
            }

            var param = new DynamicParameters();

            param.Add("@Scheme", (int)Scheme);
            if (SubScheme != null)
            {
                param.Add("@SubScheme", (int)SubScheme);
            }
            else
            {
                param.Add("@SubScheme", SubScheme);
            }
            param.Add("@BlockNo", premise.BlockNo);
            param.Add("@UnitNo", premise.UnitNo);
            param.Add("@FloorNo", premise.FloorNo);
            param.Add("@BuildingName", premise.BuildingName);
            param.Add("@Address1", premise.Address1);
            param.Add("@Postal", premise.Postal);
            param.Add("@Status", statusTable.AsTableValuedParameter("dbo.SmallIntType"));
            param.Add("@ReqTypes", typeTable.AsTableValuedParameter("dbo.SmallIntType"));

            var mapper = new RequestMapper();

            return((await SqlMapper.QueryAsync <Model.Request>(_unitOfWork.Connection,
                                                               "GetParentRequest",
                                                               new[]
            {
                typeof(Model.Request),
                typeof(Model.RequestLineItem),
                typeof(Model.Premise)
            },
                                                               obj =>
            {
                return mapper.Map(obj[0] as Model.Request,
                                  obj[1] as RequestLineItem,
                                  obj[2] as Premise);
            },
                                                               param,
                                                               splitOn: "ID,LineItemID,PremiseID",
                                                               commandType: CommandType.StoredProcedure,
                                                               transaction: _unitOfWork.Transaction)).FirstOrDefault());
        }
Exemplo n.º 15
0
        public async Task <IEnumerable <Model.Request> > Select(
            RequestOptions options)
        {
            var statusTable = new DataTable();

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

            if (options.Status?.Any() ?? false)
            {
                foreach (var status in options.Status)
                {
                    statusTable.Rows.Add(status);
                }
            }

            var typeTable = new DataTable();

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

            if (options.Type?.Any() ?? false)
            {
                foreach (var type in options.Type)
                {
                    typeTable.Rows.Add(type);
                }
            }

            var assignedToTable = new DataTable();

            assignedToTable.Columns.Add("Val", typeof(Guid));

            if (options.AssignedTo?.Any() ?? false)
            {
                foreach (var assignedTo in options.AssignedTo)
                {
                    assignedToTable.Rows.Add(assignedTo);
                }
            }

            var statusMinorTable = new DataTable();

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

            if (options.StatusMinor?.Any() ?? false)
            {
                foreach (var status in options.StatusMinor)
                {
                    statusMinorTable.Rows.Add(status);
                }
            }

            var mapper = new RequestMapper();

            var param = new DynamicParameters();

            param.Add("@ID", options.ID);
            param.Add("@CustomerID", options.CustomerID);
            param.Add("@CustomerCode", StringUtils.NullIfEmptyOrNull(options.CustomerCode));
            param.Add("@CustomerName", StringUtils.NullIfEmptyOrNull(options.Customer));
            param.Add("@RFAStatus", options.RFAStatus);
            param.Add("@EscalateStatus", options.EscalateStatus);
            param.Add("@From", options.From);
            param.Add("@To", options.To);
            param.Add("@Premise", StringUtils.NullIfEmptyOrNull(options.Premise));
            param.Add("@PremiseID", options.PremiseID);
            param.Add("@Type", typeTable.AsTableValuedParameter("dbo.SmallIntType"));
            param.Add("@Status", statusTable.AsTableValuedParameter("dbo.SmallIntType"));
            param.Add("@AssignedTo", assignedToTable.AsTableValuedParameter("dbo.UniqueIdentifierType"));
            param.Add("@StatusMinor", statusMinorTable.AsTableValuedParameter("dbo.SmallIntType"));

            return((await SqlMapper.QueryAsync(_unitOfWork.Connection,
                                               "SelectRequest",
                                               new[]
            {
                typeof(Model.Request),
                typeof(Code),
                typeof(RequestLineItem),
                typeof(Premise),
                typeof(RFA)
            },
                                               obj =>
            {
                return mapper.Map(obj[0] as Model.Request,
                                  obj[1] as Code,
                                  obj[2] as RequestLineItem,
                                  obj[3] as Premise,
                                  obj[4] as RFA);
            },
                                               param,
                                               splitOn: "ID,CCID,LineItemID,PremiseID,RFAID",
                                               commandType: CommandType.StoredProcedure,
                                               transaction: _unitOfWork.Transaction)).Distinct());
        }
Exemplo n.º 16
0
 private void WhenMapped()
 {
     _mappedRequest = _requestMapper.Map(_inputRequest);
 }
Exemplo n.º 17
0
 private void WhenMapped()
 {
     _mappedRequest = _requestMapper.Map(_inputRequest).GetAwaiter().GetResult();
 }