/************************************* * Created by: dandy boy * Created on: March 29, 2017 * Function: GetRefList * Purpose: GetRefList * Inputs: refType * Returns: LookupParameterListResponse *************************************/ public async Task <LookupParameterListResponse> GetRefList(string refType) { Logger.Info("Invoking GetRefList function"); var response = new LookupParameterListResponse() { Status = ResponseStatus.Failure, }; try { using (var scope = Container.BeginLifetimeScope()) { var globalVariableOpDAO = scope.Resolve <IGlobalVariableOpDAO>(); var results = await globalVariableOpDAO.WebRefListSelect(refType); var list = new List <LookupParameterDTO>(); if (results.Count() > 0) { foreach (var item in results) { LookupParameterDTO lookParameter = new LookupParameterDTO(); if (refType.ToLower() == "state") { lookParameter.Country = item.Country; lookParameter.ParamCd = item.CtryCd.ToString(); lookParameter.StateName = item.StateName; lookParameter.StateCd = item.StateCd; } else if (refType.ToLower() == "city") { lookParameter.Country = item.Country; lookParameter.StateName = item.State; lookParameter.ParamCd = item.ParamCd; lookParameter.City = item.City; } else { lookParameter.Descp = item.Descp; lookParameter.ParamCd = item.ParamCd; } list.Add(lookParameter); } } response.lookupParameters = Mapper.Map <List <LookupParameterDTO>, List <LookupParameters> >(list); } } catch (Exception ex) { string msg = string.Format("Error in GetRefList: detail:{0}", ex.Message); Logger.Error(msg, ex); response.Status = ResponseStatus.Exception; response.Message = msg; } return(response); }
/************************************* * Created by: dandy boy * Created on: March 30, 2017 * Function: GetRefDetail * Purpose: GetRefDetail * Inputs: refType,refCd,refNo,refId * Returns: LookupParameterListResponse *************************************/ public async Task <LookupParameterListResponse> GetRefDetail(string refType, string refCd, string refNo, string refId) { Logger.Info("Invoking GetRefDetail function"); var response = new LookupParameterListResponse() { Status = ResponseStatus.Failure, }; try { using (var scope = Container.BeginLifetimeScope()) { var globalVariableOpDAO = scope.Resolve <IGlobalVariableOpDAO>(); var result = await globalVariableOpDAO.WebRefDetail(refType, refCd, refNo, refId); if (result != null) { LookupParameterDTO lookParameter = new LookupParameterDTO(); if (refType.ToLower() == "state") { lookParameter.Country = Convert.ToString(result.CtryCd); lookParameter.StateCd = result.StateCd; lookParameter.StateName = result.Descp; } else if (refType.ToLower() == "city") { lookParameter.ParamCd = result.ParamCd; lookParameter.Country = Convert.ToString(result.RefNo); lookParameter.StateCd = result.RefId; lookParameter.City = result.Descp; } else { lookParameter.ParamCd = result.ParamCd; lookParameter.Descp = result.Descp; } response.lookupParameter = Mapper.Map <LookupParameterDTO, LookupParameters>(lookParameter); } } } catch (Exception ex) { string msg = string.Format("Error in GetRefDetail: detail:{0}", ex.Message); Logger.Error(msg, ex); response.Status = ResponseStatus.Exception; response.Message = msg; } return(response); }
public async Task <int> WebProdGroupRefMaint(LookupParameterDTO _LookupParameters, string userId) { using (var cardtrendentities = new pdb_ccmsContext(_connectionString)) { DataTable dt = new DataTable(); dt.Columns.Add("ProdCd"); foreach (var item in _LookupParameters.ProductItems) { DataRow dr = dt.NewRow(); dr["ProdCd"] = item.ProductCode; dt.Rows.Add(dr); } var parameters = new[] { new SqlParameter("@IssNo", SqlDbType.SmallInt) { SqlValue = Common.Helpers.Common.GetIssueNo() }, new SqlParameter("@ProdGroup", SqlDbType.VarChar) { SqlValue = (object)_LookupParameters.ProductGroup ?? DBNull.Value }, new SqlParameter("@ProdDescp", SqlDbType.VarChar) { SqlValue = (object)_LookupParameters.Descp ?? DBNull.Value }, new SqlParameter("@UserId", SqlDbType.NVarChar) { SqlValue = userId }, new SqlParameter("@ProdDetail", SqlDbType.Structured) { SqlValue = dt, TypeName = "ProdCdData" }, new SqlParameter("@RETURN_VALUE", SqlDbType.BigInt) { Direction = ParameterDirection.Output } }; await cardtrendentities.Database.ExecuteSqlCommandAsync("exec @RETURN_VALUE = WebProdGroupRefMaint @IssNo,@ProdGroup,@ProdDescp,@UserId,@ProdDetail", parameters); var resultCode = parameters.Where(x => x.ParameterName == "@RETURN_VALUE").FirstOrDefault().Value; return(Convert.ToInt32(resultCode)); } }