/// <summary> /// Get list of product status in application /// </summary> /// <param name="sessionKey">string</param> /// <returns>ResponseObjectForAnything</returns> public ResponseObjectForAnything GetProductStatusList(string sessionKey) { List<ProductStatus> productstatuslist = new List<ProductStatus>(); AuthenticationEngine authEngine = new AuthenticationEngine(); bool isValid = authEngine.IsValidSession(sessionKey); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); int count = 0; try { if (isValid) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_GetProductStatus"); using (IDataReader dr = db.ExecuteReader(dbCommand)) { while (dr.Read()) { ProductStatus productstatus = new ProductStatus(); if (dr["ProductStatusID"] != DBNull.Value) { productstatus.ProductStatusID = Convert.ToInt32(dr["ProductStatusID"]); } if (dr["ProductStatusName"] != DBNull.Value) { productstatus.ProductStatusName = dr["ProductStatusName"].ToString(); } productstatuslist.Add(productstatus); count++; } } responseObject.ResultCode = "SUCCESS"; responseObject.ResultObjectJSON = Serializer.ObjectToJSON(productstatuslist); responseObject.ResultObjectRecordCount = count; if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No product statuses configured."; } } } catch (Exception ex) { responseObject.ResultCode = "ERROR"; responseObject.ResultMessage = ex.Message; CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetProductStatus", System.DateTime.Now); ExceptionManager.PublishException(exc); } return (responseObject); }
/// <summary> /// Get master list of dropdowns for create problem page. /// </summary> /// <param name="sessionkey">string</param> /// <returns>string</returns> public ResponseObjectForAnything GetDropDownItems(string sessionkey) { List<Company> lstcompany = new List<Company>(); List<Category> lstcategory = new List<Category>(); List<Country> lstcountry = new List<Country>(); List<ProductStatus> lstproductstatus = new List<ProductStatus>(); List<ResolutionMethod> lstresolutionmethod = new List<ResolutionMethod>(); CreateProblemObject createproblemobj = new CreateProblemObject(); AuthenticationEngine authEngine = new AuthenticationEngine(); bool isValid = authEngine.IsValidSession(sessionkey); int count = 0; ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); try { if (isValid) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_GetDropDownItems"); db.AddInParameter(dbCommand, "SessionKey", DbType.String, sessionkey); DataSet dsDropdowns = db.ExecuteDataSet(dbCommand); if(dsDropdowns.Tables.Count > 0) { DataTable tDropDowns = dsDropdowns.Tables[0]; foreach(DataRow dr in tDropDowns.Rows) { Company company = new Company(); if (dr["CompanyID"] != DBNull.Value) { company.CompanyID = Convert.ToInt32(dr["CompanyID"]); } if (dr["CompanyName"] != DBNull.Value) { company.CompanyName = dr["CompanyName"].ToString(); } lstcompany.Add(company); count++; } createproblemobj.companies = lstcompany; } if (dsDropdowns.Tables.Count > 1) { DataTable tDropDowns = dsDropdowns.Tables[1]; foreach (DataRow dr in tDropDowns.Rows) { Category category = new Category(); if (dr["ID"] != DBNull.Value) { category.ID = Convert.ToInt32(dr["ID"]); } if (dr["Name"] != DBNull.Value) { category.Name = dr["Name"].ToString(); } lstcategory.Add(category); count++; } createproblemobj.categories = lstcategory; } if (dsDropdowns.Tables.Count > 2) { DataTable tDropDowns = dsDropdowns.Tables[2]; foreach (DataRow dr in tDropDowns.Rows) { ProductStatus productstatus = new ProductStatus(); if (dr["ProductStatusID"] != DBNull.Value) { productstatus.ProductStatusID = Convert.ToInt32(dr["ProductStatusID"]); } if (dr["ProductStatusName"] != DBNull.Value) { productstatus.ProductStatusName = dr["ProductStatusName"].ToString(); } lstproductstatus.Add(productstatus); count++; } createproblemobj.productstatuses = lstproductstatus; } if (dsDropdowns.Tables.Count > 3) { DataTable tDropDowns = dsDropdowns.Tables[3]; foreach (DataRow dr in tDropDowns.Rows) { Country country = new Country(); if (dr["CountryID"] != DBNull.Value) { country.CountryID = Convert.ToInt32(dr["CountryID"]); } if (dr["CountryName"] != DBNull.Value) { country.CountryName = dr["CountryName"].ToString(); } if (dr["IsDefaulted"] != DBNull.Value) { country.IsDefaulted = Convert.ToBoolean(dr["IsDefaulted"].ToString()); } lstcountry.Add(country); count++; } createproblemobj.countries = lstcountry; } if (dsDropdowns.Tables.Count > 4) { DataTable tDropDowns = dsDropdowns.Tables[4]; foreach (DataRow dr in tDropDowns.Rows) { if (dr["PinCode"] != DBNull.Value) { createproblemobj.PinCode = dr["PinCode"].ToString(); } } } } responseObject.ResultCode = "SUCCESS"; responseObject.ResultObjectJSON = Serializer.ObjectToJSON(createproblemobj); responseObject.ResultObjectRecordCount = count; if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No master items configured."; } } catch (Exception ex) { responseObject.ResultCode = "ERROR"; responseObject.ResultMessage = ex.Message; CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetDropDownItems", System.DateTime.Now); ExceptionManager.PublishException(exc); } return (responseObject); }