/// <summary>
        /// This method gets categories based on selected company.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="companyID">int</param>
        /// <returns>ResponseObjectForAnything</returns>
        public ResponseObjectForAnything GetCategories()
        {
            List<Category> categorylist = new List<Category>();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            int count = 0;

            try
            {
                Database db = DatabaseFactory.CreateDatabase();
                DbCommand dbCommand = db.GetStoredProcCommand("usp_GetCategories");

                using (IDataReader dr = db.ExecuteReader(dbCommand))
                {
                    while (dr.Read())
                    {
                        Category category = new Category();
                        if (dr["ID"] != DBNull.Value) { category.ID = Int32.Parse(dr["ID"].ToString()); }
                        if (dr["Name"] != DBNull.Value) { category.Name = dr["Name"].ToString(); }
                        count++;
                        categorylist.Add(category);
                    }
                }
                responseObject.ResultCode = "SUCCESS";
                responseObject.ResultObjectJSON = Serializer.ObjectToJSON(categorylist);
                responseObject.ResultObjectRecordCount = count;
                if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No categories configured."; }
            }
            catch (Exception ex)
            {
                responseObject.ResultCode = "ERROR";
                responseObject.ResultMessage = ex.Message;
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetCompanies", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            return (responseObject);
        }
        /// <summary>
        /// This method gets the details for a particular 
        /// problem. It contains all bid details and details
        /// of all users who bidded on that problem.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="problemId">int</param>
        /// <returns>ProblemObject</returns>
        public ResponseObjectForAnything GetProblemDetailById(string sessionKey, string problemId, bool ispaging)
        {
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            ProblemObject problemdetailobject = new ProblemObject();
            List<Problem> lstproblem = new List<Problem>();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            List<User> lstuser = new List<User>();
            List<ProblemHashTag> lstproblemhashtag = new List<ProblemHashTag>();
            List<ProblemMedia> lstproblemmedia = new List<ProblemMedia>();
            int count = 0;
            bool isValid = true;
            if (!string.IsNullOrEmpty(sessionKey)) { isValid = authEngine.IsValidSession(sessionKey); }

            if (isValid)
            {
                try
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetProblemDetailByID");
                    db.AddInParameter(dbCommand, "@Sessionkey", DbType.String, sessionKey);
                    if (!string.IsNullOrEmpty(problemId)) { db.AddInParameter(dbCommand, "@ProblemID", DbType.Int32, Int32.Parse(problemId)); }
                    else { db.AddInParameter(dbCommand, "@ProblemID", DbType.Int32, null); }
                    db.AddInParameter(dbCommand, "@IsPaging", DbType.Boolean, ispaging);
                    DataSet dsProblemDetail = db.ExecuteDataSet(dbCommand);
                    if (!ispaging)
                    {
                        if (dsProblemDetail.Tables.Count > 0)
                        {
                            DataTable tUser = dsProblemDetail.Tables[0];
                            foreach (DataRow tRow in tUser.Rows)
                            {
                                User user = new User();
                                if (tRow["UserID"] != DBNull.Value) { user.UserID = Int32.Parse(tRow["UserID"].ToString()); }
                                if (tRow["EmailId"] != DBNull.Value) { user.EmailID = tRow["EmailId"].ToString(); }
                                if (tRow["FirstName"] != DBNull.Value) { user.FirstName = tRow["FirstName"].ToString(); }
                                if (tRow["LastName"] != DBNull.Value) { user.LastName = tRow["LastName"].ToString(); }
                                if (tRow["ProfilePicPath"] != DBNull.Value) { user.ProfilePicPath = tRow["ProfilePicPath"].ToString(); }
                                if (tRow["DisplayName"] != DBNull.Value) { user.DisplayName = tRow["DisplayName"].ToString(); }
                                if (tRow["CountryCode"] != DBNull.Value) { user.CountryCode = tRow["CountryCode"].ToString(); }
                                if (tRow["PhoneNumber"] != DBNull.Value) { user.PhoneNumber = tRow["PhoneNumber"].ToString(); }
                                if (tRow["Address1"] != DBNull.Value) { user.Address1 = tRow["Address1"].ToString(); }
                                if (tRow["Address2"] != DBNull.Value) { user.Address2 = tRow["Address2"].ToString(); }
                                if (tRow["Address3"] != DBNull.Value) { user.Address3 = tRow["Address3"].ToString(); }
                                if (tRow["City"] != DBNull.Value) { user.City = tRow["City"].ToString(); }
                                if (tRow["StateID"] != DBNull.Value) { user.StateID = Int32.Parse(tRow["StateID"].ToString()); }
                                if (tRow["CountryID"] != DBNull.Value) { user.CountryID = Int32.Parse(tRow["CountryID"].ToString()); }
                                if (tRow["BriefDescription"] != DBNull.Value) { user.BriefDescription = tRow["BriefDescription"].ToString(); }
                                if (tRow["QuickBloxUserName"] != DBNull.Value) { user.QuickBloxUserName = tRow["QuickBloxUserName"].ToString(); }
                                if (tRow["QuickBloxPassword"] != DBNull.Value) { user.QuickBloxPassword = tRow["QuickBloxPassword"].ToString(); }
                                if (tRow["ProfileCompleteness"] != DBNull.Value) { user.ProfileCompleteness = Int32.Parse(tRow["ProfileCompleteness"].ToString()); }
                                lstuser.Add(user);
                            }
                            problemdetailobject.user = lstuser;
                        }

                        if (dsProblemDetail.Tables.Count > 1)
                        {
                            DataTable tProblem = dsProblemDetail.Tables[1];
                            Problem problem = new Problem();
                            foreach (DataRow dRow in tProblem.Rows)
                            {
                                if (dRow["ID"] != DBNull.Value) { problem.ID = Int32.Parse(dRow["ID"].ToString()); }
                                if (dRow["UserID"] != DBNull.Value) { problem.UserID = Int32.Parse(dRow["UserID"].ToString()); }
                                if (dRow["FirstName"] != DBNull.Value) { problem.FirstName = dRow["FirstName"].ToString(); }
                                if (dRow["LastName"] != DBNull.Value) { problem.LastName = dRow["LastName"].ToString(); }
                                if (dRow["DisplayName"] != DBNull.Value) { problem.DisplayName = dRow["DisplayName"].ToString(); }
                                if (dRow["EmailID"] != DBNull.Value) { problem.EmailID = dRow["EmailID"].ToString(); }
                                if (dRow["CompanyRelated"] != DBNull.Value) { problem.IsCompanyRelated = Convert.ToBoolean(dRow["CompanyRelated"].ToString()); }
                                if (dRow["CompanyID"] != DBNull.Value) { problem.CompanyID = Int32.Parse(dRow["CompanyID"].ToString()); }
                                if (dRow["CompanyName"] != DBNull.Value) { problem.CompanyName = dRow["CompanyName"].ToString(); }
                                if (dRow["ProblemHeading"] != DBNull.Value) { problem.ProblemHeading = dRow["ProblemHeading"].ToString(); }
                                if (dRow["CategoryID"] != DBNull.Value) { problem.CategoryID = Int32.Parse(dRow["CategoryID"].ToString()); }
                                if (dRow["CategoryName"] != DBNull.Value) { problem.CategoryName = dRow["CategoryName"].ToString(); }
                                if (dRow["SubCategoryID"] != DBNull.Value) { problem.SubCategoryID = Int32.Parse(dRow["SubCategoryID"].ToString()); }
                                if (dRow["SubCategoryName"] != DBNull.Value) { problem.SubCategoryName = dRow["SubCategoryName"].ToString(); }
                                if (dRow["ProductID"] != DBNull.Value) { problem.ProductID = Int32.Parse(dRow["ProductID"].ToString()); }
                                if (dRow["ModelNo"] != DBNull.Value) { problem.ModelNo = dRow["ModelNo"].ToString(); }
                                if (dRow["Description"] != DBNull.Value) { problem.Description = dRow["Description"].ToString(); }
                                if (dRow["PurchaseMonth"] != DBNull.Value) { problem.PurchaseMonth = Int32.Parse(dRow["PurchaseMonth"].ToString()); }
                                if (dRow["PurchaseYear"] != DBNull.Value) { problem.PurchaseYear = Int32.Parse(dRow["PurchaseYear"].ToString()); }
                                if (dRow["ProductStatusID"] != DBNull.Value) { problem.ProductStatusID = Int32.Parse(dRow["ProductStatusID"].ToString()); }
                                if (dRow["ProductStatusName"] != DBNull.Value) { problem.ProductStatusName = dRow["ProductStatusName"].ToString(); }
                                if (dRow["ProblemStatusID"] != DBNull.Value) { problem.ProblemStatusID = Int32.Parse(dRow["ProblemStatusID"].ToString()); }
                                if (dRow["ProblemStatusName"] != DBNull.Value) { problem.ProblemStatusName = dRow["ProblemStatusName"].ToString(); }
                                if (dRow["ResolutionNeededBy"] != DBNull.Value) { problem.ResolutionNeededBy = Convert.ToDateTime(dRow["ResolutionNeededBy"].ToString()); }
                                if (dRow["IsVirtual"] != DBNull.Value) { problem.IsVirtual = Convert.ToBoolean(dRow["IsVirtual"].ToString()); }
                                if (dRow["IsRegisteredAddress"] != DBNull.Value) { problem.IsRegisteredAddress = Convert.ToBoolean(dRow["IsRegisteredAddress"].ToString()); }
                                if (dRow["Address1"] != DBNull.Value) { problem.Address1 = dRow["Address1"].ToString(); }
                                if (dRow["Address2"] != DBNull.Value) { problem.Address2 = dRow["Address2"].ToString(); }
                                if (dRow["Address3"] != DBNull.Value) { problem.Address3 = dRow["Address3"].ToString(); }
                                if (dRow["City"] != DBNull.Value) { problem.City = dRow["City"].ToString(); }
                                if (dRow["StateID"] != DBNull.Value) { problem.StateID = Int32.Parse(dRow["StateID"].ToString()); }
                                if (dRow["StateName"] != DBNull.Value) { problem.StateName = dRow["StateName"].ToString(); }
                                if (dRow["CountryID"] != DBNull.Value) { problem.CountryID = Int32.Parse(dRow["CountryID"].ToString()); }
                                if (dRow["CountryName"] != DBNull.Value) { problem.CountryName = dRow["CountryName"].ToString(); }
                                if (dRow["PinCode"] != DBNull.Value) { problem.PinCode = dRow["PinCode"].ToString(); }
                                if (dRow["Latitude"] != DBNull.Value) { problem.Latitude = Convert.ToDecimal(dRow["Latitude"].ToString()); }
                                if (dRow["Longitude"] != DBNull.Value) { problem.Longitude = Convert.ToDecimal(dRow["Longitude"].ToString()); }
                                if (dRow["Distance"] != DBNull.Value) { problem.Distance = Convert.ToDecimal(dRow["Distance"].ToString()); }
                                if (dRow["ThumbnailMedia"] != DBNull.Value) { problem.ThumbnailMedia = dRow["ThumbnailMedia"].ToString(); }
                                //lstproblem.Add(problem);
                            }
                            problemdetailobject.individualproblem = problem;
                        }

                        if (dsProblemDetail.Tables.Count > 2)
                        {
                            DataTable tProblemHashTag = dsProblemDetail.Tables[2];
                            List<ProblemHashTag> lstHashTag = new List<ProblemHashTag>();

                            foreach (DataRow dRow in tProblemHashTag.Rows)
                            {
                                ProblemHashTag problemhashtag = new ProblemHashTag();
                                if (dRow["ProblemID"] != DBNull.Value) { problemhashtag.ProblemID = Int32.Parse(dRow["ProblemID"].ToString()); }
                                if (dRow["HashTagID"] != DBNull.Value) { problemhashtag.HashTagID = Int32.Parse(dRow["HashTagID"].ToString()); }
                                if (dRow["Name"] != DBNull.Value) { problemhashtag.HashTag = dRow["Name"].ToString(); }
                                lstHashTag.Add(problemhashtag);
                            }
                            problemdetailobject.problemhashtag = lstHashTag;
                        }

                        if (dsProblemDetail.Tables.Count > 3)
                        {
                            DataTable tProblemMedia = dsProblemDetail.Tables[3];
                            List<ProblemMedia> lstHashTag = new List<ProblemMedia>();

                            foreach (DataRow dRow in tProblemMedia.Rows)
                            {
                                ProblemMedia problemmedia = new ProblemMedia();
                                if (dRow["ProblemMediaID"] != DBNull.Value) { problemmedia.ProblemMediaID = Int32.Parse(dRow["ProblemMediaID"].ToString()); }
                                if (dRow["ProblemID"] != DBNull.Value) { problemmedia.ProblemID = Int32.Parse(dRow["ProblemID"].ToString()); }
                                if (dRow["IsImage"] != DBNull.Value) { problemmedia.IsImage = Convert.ToBoolean(dRow["IsImage"].ToString()); }
                                if (dRow["MediaPath"] != DBNull.Value) { problemmedia.MediaPath = dRow["MediaPath"].ToString(); }
                                lstHashTag.Add(problemmedia);
                            }
                            problemdetailobject.problemmedia = lstproblemmedia;
                        }
                    }
                    if (!ispaging && dsProblemDetail.Tables.Count > 4 || ispaging && dsProblemDetail.Tables.Count > 0)
                    {
                        DataTable tProblemBids = dsProblemDetail.Tables[4];
                        List<ProblemBid> lstproblembid = new List<ProblemBid>();

                        foreach (DataRow dRow in tProblemBids.Rows)
                        {
                            ProblemBid bid = new ProblemBid();
                            if (dRow["BidId"] != DBNull.Value) { bid.BidID = Int32.Parse(dRow["BidId"].ToString()); }
                            if (dRow["ProblemID"] != DBNull.Value) { bid.ProblemID = Int32.Parse(dRow["ProblemID"].ToString()); }
                            if (dRow["UserID"] != DBNull.Value) { bid.UserID = Int32.Parse(dRow["UserID"].ToString()); }
                            if (dRow["DisplayName"] != DBNull.Value) { bid.DisplayName = dRow["DisplayName"].ToString(); }
                            if (dRow["ProfilePicPath"] != DBNull.Value) { bid.ProfileImagePath = dRow["ProfilePicPath"].ToString(); }
                            if (dRow["BriefDescription"] != DBNull.Value) { bid.BriefDescription = dRow["BriefDescription"].ToString(); }
                            if (dRow["QuickBloxUserName"] != DBNull.Value) { bid.QuickBloxUserID = dRow["QuickBloxUserName"].ToString(); }
                            if (dRow["Longitude"] != DBNull.Value) { bid.Longitude = Convert.ToDecimal(dRow["Longitude"].ToString()); }
                            if (dRow["Latitude"] != DBNull.Value) { bid.Latitude = Convert.ToDecimal(dRow["Latitude"].ToString()); }
                            if (dRow["Distance"] != DBNull.Value) { bid.Distance = Convert.ToDecimal(dRow["Distance"].ToString()); }
                            if (dRow["Description"] != DBNull.Value) { bid.ResolutionDescription = dRow["Description"].ToString(); }
                            if (dRow["ResolutionMethodID"] != DBNull.Value) { bid.ResolutionMethodID = Int32.Parse(dRow["ResolutionMethodID"].ToString()); }
                            if (dRow["ResolutionLink1"] != DBNull.Value) { bid.ResolutionLink1 = dRow["ResolutionLink1"].ToString(); }
                            if (dRow["ResolutionLink2"] != DBNull.Value) { bid.ResolutionLink2 = dRow["ResolutionLink2"].ToString(); }
                            if (dRow["CurrencyID"] != DBNull.Value) { bid.CurrencyID = Int32.Parse(dRow["CurrencyID"].ToString()); }
                            if (dRow["CurrencyName"] != DBNull.Value) { bid.CurrencyName = dRow["CurrencyName"].ToString(); }
                            if (dRow["CurrencyDisplayText"] != DBNull.Value) { bid.CurrencyDisplayText = dRow["CurrencyDisplayText"].ToString(); }
                            if (dRow["Amount"] != DBNull.Value) { bid.Amount = Convert.ToDecimal(dRow["Amount"].ToString()); }
                            if (dRow["CompanyID"] != DBNull.Value) { bid.CompanyID = Int32.Parse(dRow["CompanyID"].ToString()); }
                            if (dRow["CompanyName"] != DBNull.Value) { bid.CompanyName = dRow["CompanyName"].ToString(); }
                            if (dRow["UserID"] != DBNull.Value) { bid.UserID = Int32.Parse(dRow["UserID"].ToString()); }
                            if (dRow["IsSelected"] != DBNull.Value) { bid.IsSelected = Convert.ToBoolean(dRow["IsSelected"].ToString()); }
                            if (dRow["IsInvited"] != DBNull.Value) { bid.IsInvited = Convert.ToBoolean(dRow["IsInvited"].ToString()); }
                            if (dRow["SubmittedDate"] != DBNull.Value) { bid.SubmittedDate = Convert.ToDateTime(dRow["SubmittedDate"].ToString()); }
                            if (dRow["IsRated"] != DBNull.Value) { bid.IsRated = Convert.ToBoolean(dRow["IsRated"].ToString()); }
                            if (dRow["UserRating"] != DBNull.Value) { bid.UserRating = Convert.ToDecimal(dRow["UserRating"].ToString()); }
                            lstproblembid.Add(bid);
                            count++;
                        }
                        problemdetailobject.problembid = lstproblembid;
                    }
                    if (!ispaging)
                    {
                        if (dsProblemDetail.Tables.Count > 5)
                        {
                            DataTable tResolutionMedia = dsProblemDetail.Tables[5];
                            List<ResolutionMedia> lstresolutionmedia = new List<ResolutionMedia>();

                            foreach (DataRow dRow in tResolutionMedia.Rows)
                            {
                                ResolutionMedia resmedia = new ResolutionMedia();
                                if (dRow["BidID"] != DBNull.Value) { resmedia.BidID = Int32.Parse(dRow["BidID"].ToString()); }
                                if (dRow["IsImage"] != DBNull.Value) { resmedia.IsImage = Convert.ToBoolean(dRow["IsImage"].ToString()); }
                                if (dRow["ResolutionMediaPath"] != DBNull.Value) { resmedia.MediaPath = dRow["ResolutionMediaPath"].ToString(); }
                                lstresolutionmedia.Add(resmedia);
                            }
                            problemdetailobject.resolutionmedia = lstresolutionmedia;
                        }

                        if (dsProblemDetail.Tables.Count > 6)
                        {
                            DataTable tResolutionProposedTime = dsProblemDetail.Tables[6];
                            List<ResolutionProposedTime> lstresproposedtime = new List<ResolutionProposedTime>();

                            foreach (DataRow dRow in tResolutionProposedTime.Rows)
                            {
                                ResolutionProposedTime proposedtime = new ResolutionProposedTime();
                                if (dRow["ID"] != DBNull.Value) { proposedtime.ID = Int32.Parse(dRow["ID"].ToString()); }
                                if (dRow["BidID"] != DBNull.Value) { proposedtime.BidID = Int32.Parse(dRow["BidID"].ToString()); }
                                if (dRow["IsSelected"] != DBNull.Value) { proposedtime.IsSelected = Convert.ToBoolean(dRow["IsSelected"].ToString()); }
                                if (dRow["ResolutionProposedTime"] != DBNull.Value) { proposedtime.ProposedTime = Convert.ToDateTime(dRow["ResolutionProposedTime"].ToString()); }
                                lstresproposedtime.Add(proposedtime);
                            }
                            problemdetailobject.proposedtime = lstresproposedtime;
                        }
                        if (!ispaging && dsProblemDetail.Tables.Count > 7 || ispaging && dsProblemDetail.Tables.Count > 0)
                        {
                            DataTable tProblemBids = dsProblemDetail.Tables[7];
                            List<ProblemBid> lstproblembid = new List<ProblemBid>();

                            foreach (DataRow dRow in tProblemBids.Rows)
                            {
                                ProblemBid bid = new ProblemBid();
                                if (dRow["BidId"] != DBNull.Value) { bid.BidID = Int32.Parse(dRow["BidId"].ToString()); }
                                if (dRow["ProblemID"] != DBNull.Value) { bid.ProblemID = Int32.Parse(dRow["ProblemID"].ToString()); }
                                if (dRow["UserID"] != DBNull.Value) { bid.UserID = Int32.Parse(dRow["UserID"].ToString()); }
                                if (dRow["DisplayName"] != DBNull.Value) { bid.DisplayName = dRow["DisplayName"].ToString(); }
                                if (dRow["ProfilePicPath"] != DBNull.Value) { bid.ProfileImagePath = dRow["ProfilePicPath"].ToString(); }
                                if (dRow["BriefDescription"] != DBNull.Value) { bid.BriefDescription = dRow["BriefDescription"].ToString(); }
                                if (dRow["QuickBloxUserName"] != DBNull.Value) { bid.QuickBloxUserID = dRow["QuickBloxUserName"].ToString(); }
                                if (dRow["Longitude"] != DBNull.Value) { bid.Longitude = Convert.ToDecimal(dRow["Longitude"].ToString()); }
                                if (dRow["Latitude"] != DBNull.Value) { bid.Latitude = Convert.ToDecimal(dRow["Latitude"].ToString()); }
                                if (dRow["Distance"] != DBNull.Value) { bid.Distance = Convert.ToDecimal(dRow["Distance"].ToString()); }
                                if (dRow["Description"] != DBNull.Value) { bid.ResolutionDescription = dRow["Description"].ToString(); }
                                if (dRow["ResolutionMethodID"] != DBNull.Value) { bid.ResolutionMethodID = Int32.Parse(dRow["ResolutionMethodID"].ToString()); }
                                if (dRow["ResolutionLink1"] != DBNull.Value) { bid.ResolutionLink1 = dRow["ResolutionLink1"].ToString(); }
                                if (dRow["ResolutionLink2"] != DBNull.Value) { bid.ResolutionLink2 = dRow["ResolutionLink2"].ToString(); }
                                if (dRow["CurrencyID"] != DBNull.Value) { bid.CurrencyID = Int32.Parse(dRow["CurrencyID"].ToString()); }
                                if (dRow["CurrencyName"] != DBNull.Value) { bid.CurrencyName = dRow["CurrencyName"].ToString(); }
                                if (dRow["CurrencyDisplayText"] != DBNull.Value) { bid.CurrencyDisplayText = dRow["CurrencyDisplayText"].ToString(); }
                                if (dRow["Amount"] != DBNull.Value) { bid.Amount = Convert.ToDecimal(dRow["Amount"].ToString()); }
                                if (dRow["CompanyID"] != DBNull.Value) { bid.CompanyID = Int32.Parse(dRow["CompanyID"].ToString()); }
                                if (dRow["CompanyName"] != DBNull.Value) { bid.CompanyName = dRow["CompanyName"].ToString(); }
                                if (dRow["IsSelected"] != DBNull.Value) { bid.IsSelected = Convert.ToBoolean(dRow["IsSelected"].ToString()); }
                                if (dRow["IsInvited"] != DBNull.Value) { bid.IsInvited = Convert.ToBoolean(dRow["IsInvited"].ToString()); }
                                if (dRow["SubmittedDate"] != DBNull.Value) { bid.SubmittedDate = Convert.ToDateTime(dRow["SubmittedDate"].ToString()); }
                                if (dRow["IsRated"] != DBNull.Value) { bid.IsRated = Convert.ToBoolean(dRow["IsRated"].ToString()); }
                                if (dRow["UserRating"] != DBNull.Value) { bid.UserRating = Convert.ToDecimal(dRow["UserRating"].ToString()); }
                                lstproblembid.Add(bid);
                                count++;
                            }
                            problemdetailobject.invitedproblembid = lstproblembid;
                        }
                        if (!ispaging && dsProblemDetail.Tables.Count > 8 || ispaging && dsProblemDetail.Tables.Count > 0)
                        {
                            DataTable tProblemBids = dsProblemDetail.Tables[8];
                            List<ProblemBid> lstproblembid = new List<ProblemBid>();

                            foreach (DataRow dRow in tProblemBids.Rows)
                            {
                                ProblemBid bid = new ProblemBid();
                                if (dRow["BidId"] != DBNull.Value) { bid.BidID = Int32.Parse(dRow["BidId"].ToString()); }
                                if (dRow["ProblemID"] != DBNull.Value) { bid.ProblemID = Int32.Parse(dRow["ProblemID"].ToString()); }
                                if (dRow["UserID"] != DBNull.Value) { bid.UserID = Int32.Parse(dRow["UserID"].ToString()); }
                                if (dRow["DisplayName"] != DBNull.Value) { bid.DisplayName = dRow["DisplayName"].ToString(); }
                                if (dRow["ProfilePicPath"] != DBNull.Value) { bid.ProfileImagePath = dRow["ProfilePicPath"].ToString(); }
                                if (dRow["BriefDescription"] != DBNull.Value) { bid.BriefDescription = dRow["BriefDescription"].ToString(); }
                                if (dRow["QuickBloxUserName"] != DBNull.Value) { bid.QuickBloxUserID = dRow["QuickBloxUserName"].ToString(); }
                                if (dRow["Longitude"] != DBNull.Value) { bid.Longitude = Convert.ToDecimal(dRow["Longitude"].ToString()); }
                                if (dRow["Latitude"] != DBNull.Value) { bid.Latitude = Convert.ToDecimal(dRow["Latitude"].ToString()); }
                                if (dRow["Distance"] != DBNull.Value) { bid.Distance = Convert.ToDecimal(dRow["Distance"].ToString()); }
                                if (dRow["Description"] != DBNull.Value) { bid.ResolutionDescription = dRow["Description"].ToString(); }
                                if (dRow["ResolutionMethodID"] != DBNull.Value) { bid.ResolutionMethodID = Int32.Parse(dRow["ResolutionMethodID"].ToString()); }
                                if (dRow["ResolutionLink1"] != DBNull.Value) { bid.ResolutionLink1 = dRow["ResolutionLink1"].ToString(); }
                                if (dRow["ResolutionLink2"] != DBNull.Value) { bid.ResolutionLink2 = dRow["ResolutionLink2"].ToString(); }
                                if (dRow["CurrencyID"] != DBNull.Value) { bid.CurrencyID = Int32.Parse(dRow["CurrencyID"].ToString()); }
                                if (dRow["CurrencyName"] != DBNull.Value) { bid.CurrencyName = dRow["CurrencyName"].ToString(); }
                                if (dRow["CurrencyDisplayText"] != DBNull.Value) { bid.CurrencyDisplayText = dRow["CurrencyDisplayText"].ToString(); }
                                if (dRow["Amount"] != DBNull.Value) { bid.Amount = Convert.ToDecimal(dRow["Amount"].ToString()); }
                                if (dRow["CompanyID"] != DBNull.Value) { bid.CompanyID = Int32.Parse(dRow["CompanyID"].ToString()); }
                                if (dRow["CompanyName"] != DBNull.Value) { bid.CompanyName = dRow["CompanyName"].ToString(); }
                                if (dRow["UserID"] != DBNull.Value) { bid.UserID = Int32.Parse(dRow["UserID"].ToString()); }
                                if (dRow["IsSelected"] != DBNull.Value) { bid.IsSelected = Convert.ToBoolean(dRow["IsSelected"].ToString()); }
                                if (dRow["IsInvited"] != DBNull.Value) { bid.IsInvited = Convert.ToBoolean(dRow["IsInvited"].ToString()); }
                                if (dRow["SubmittedDate"] != DBNull.Value) { bid.SubmittedDate = Convert.ToDateTime(dRow["SubmittedDate"].ToString()); }
                                if (dRow["IsRated"] != DBNull.Value) { bid.IsRated = Convert.ToBoolean(dRow["IsRated"].ToString()); }
                                if (dRow["UserRating"] != DBNull.Value) { bid.UserRating = Convert.ToDecimal(dRow["UserRating"].ToString()); }
                                lstproblembid.Add(bid);
                                count++;
                            }
                            problemdetailobject.selectedproblembid = lstproblembid;
                        }
                    }
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectRecordCount = count;
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(problemdetailobject);
                    if (count <= 0) { responseObject.ResultMessage = "No bids currently available for this problem."; }
                }
                catch (Exception ex)
                {
                    responseObject.ResultCode = "ERROR";
                    responseObject.ResultMessage = ex.Message;
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetProblemDetailById", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            return responseObject;
        }
Beispiel #3
0
        /// <summary>
        /// Update contact info for a user ID.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="address1">string</param>
        /// <param name="address2">string</param>
        /// <param name="address3">string</param>
        /// <param name="state">string</param>
        /// <param name="city">string</param>
        /// <param name="pincode">string</param>
        /// <returns>SessionResponseObject</returns>
        public ResponseObjectForAnything UpdateContactInfoByUserId(string sessionKey, string address1, string address2, string address3, string stateID, string countryID, string city, string pincode)
        {
            AuthenticationEngine authEngine = new AuthenticationEngine();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            User user = new User();
            bool isValid = authEngine.IsValidSession(sessionKey);
            if (isValid)
            {
                if (!string.IsNullOrEmpty(sessionKey))
                {
                    responseObject = authEngine.GetUserFromSession(sessionKey);
                    user = (User)Serializer.JSONStringToObject<User>(responseObject.ResultObjectJSON);
                }

                if (user != null)
                {
                    try
                    {
                        Database db = DatabaseFactory.CreateDatabase();
                        DbCommand dbCommand = db.GetStoredProcCommand("usp_UpdateContactByUserID");

                        db.AddInParameter(dbCommand, "UserID", DbType.Int32, user.UserID);
                        db.AddInParameter(dbCommand, "Address1", DbType.String, address1);
                        db.AddInParameter(dbCommand, "Address2", DbType.String, address2);
                        db.AddInParameter(dbCommand, "Address3", DbType.String, address3);
                        db.AddInParameter(dbCommand, "State", DbType.String, stateID);
                        db.AddInParameter(dbCommand, "City", DbType.String, city);
                        db.AddInParameter(dbCommand, "PinCode", DbType.String, pincode);

                        dbCommand.ExecuteNonQuery();

                        responseObject.ResultCode = "SUCCESS";
                        responseObject.ResultMessage = "Contact information updated successfully.";
                    }
                    catch (Exception ex)
                    {
                        responseObject.ResultCode = "ERROR";
                        responseObject.ResultMessage = ex.Message;
                        CustomException exc = new CustomException(ex.ToString(), this.ToString(), "UpdateContactInfoByUserId", System.DateTime.Now);
                        ExceptionManager.PublishException(exc);
                    }
                }
            }
            return (responseObject);
        }
Beispiel #4
0
        /// <summary>
        /// This method creates a user/expert into the system
        /// and then creates the session for the user to log in.
        /// </summary>
        /// <param name="firstName">string</param>
        /// <param name="lastName">string</param>
        /// <param name="displayName">string</param>
        /// <param name="emailID">string</param>
        /// <param name="isUser">string</param>
        /// <param name="isExpert">string</param>
        /// <param name="catsubcat">string</param>
        /// <param name="area">string</param>
        /// <param name="city">string</param>
        /// <param name="password">string</param>
        /// <param name="deviceTokenId">string</param>
        /// <returns>SessionResponseObject</returns>
        public ResponseObjectForAnything CreateUser(string firstName, string lastName, string displayName, string emailID, string address2, string city, string pinCode,
                                                    string isUser, string isExpert, string catsubcat, string password, string deviceTokenId)
        {
            AuthenticationEngine authEngine = new AuthenticationEngine();
            int userId = -1;
            SessionResponseObject sessionObject = new SessionResponseObject();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();

            try
            {
                string useraccount = authEngine.CheckExistingAccount(emailID);

                if (useraccount == "SUCCESS")
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_CreateUser");

                    db.AddInParameter(dbCommand, "FirstName", DbType.String, firstName);
                    db.AddInParameter(dbCommand, "LastName", DbType.String, lastName);
                    db.AddInParameter(dbCommand, "DisplayName", DbType.String, displayName);
                    db.AddInParameter(dbCommand, "EmailID", DbType.String, emailID);
                    db.AddInParameter(dbCommand, "Address2", DbType.String, address2);
                    db.AddInParameter(dbCommand, "City", DbType.String, city);
                    db.AddInParameter(dbCommand, "PinCode", DbType.String, pinCode);
                    float latitude, longitude;
                    GeoHelper geoHelper = new GeoHelper();
                    geoHelper.GetGeoLocationByPinCode(pinCode, out latitude, out longitude);
                    db.AddInParameter(dbCommand, "Latitude", DbType.Decimal, latitude);
                    db.AddInParameter(dbCommand, "Longitude", DbType.Decimal, longitude);
                    db.AddInParameter(dbCommand, "IsUser", DbType.Boolean, Convert.ToBoolean(isUser));
                    db.AddInParameter(dbCommand, "IsExpert", DbType.Boolean, Convert.ToBoolean(isExpert));
                    string[] lstcatsubcat = catsubcat.Split(";".ToCharArray());
                    DataSet dataSet = new DataSet();
                    DataTable dataTable = dataSet.Tables.Add();
                    dataTable.Columns.Add("CategoryID");
                    dataTable.Columns.Add("SubCategoryID");
                    for(int count =0; count <lstcatsubcat.Length - 1; count++)
                    {
                        string category = lstcatsubcat[count].Split(",".ToCharArray())[0];
                        string subcategory = lstcatsubcat[count].Split(",".ToCharArray())[1];
                        dataTable.Rows.Add(new object[] { category, subcategory });
                    }
                    db.AddInParameter(dbCommand, "CatSubCat", DbType.String, dataSet.GetXml());
                    db.AddInParameter(dbCommand, "Password", DbType.String, BitConverter.ToString(SHA1.Create().ComputeHash(Encoding.Default.GetBytes(password + ""))).Replace("-", ""));
                    db.AddInParameter(dbCommand, "DeviceTokenId", DbType.String, deviceTokenId);

                    userId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString());

                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(sessionObject);
                    responseObject.ResultObjectRecordCount = userId;
                    if (responseObject.ResultObjectRecordCount <= 0) { responseObject.ResultMessage = "Email Id already exists."; }
                }
                else
                {
                    responseObject.ResultCode = "ERROR";
                    responseObject.ResultMessage = "Email Id already exists.";
                }
            }
            catch (Exception ex)
            {
                responseObject.ResultCode = "ERROR";
                responseObject.ResultMessage = ex.Message;
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "CreateUser", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            return (responseObject);
        }
Beispiel #5
0
        /// <summary>
        /// This method saves the quick blox credentials
        /// for newly registered user.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="email">string</param>
        /// <param name="password">string</param>
        /// <returns>string</returns>
        public SessionResponseObject SaveQBDetails(string sessionKey, string email, string password)
        {
            SessionResponseObject responseObject = new SessionResponseObject();
            int qbuserid = 0;

            try
            {
                Database db = DatabaseFactory.CreateDatabase();
                DbCommand dbCommand = db.GetStoredProcCommand("usp_SaveQBDetails");

                db.AddInParameter(dbCommand, "SessionKey", DbType.String, sessionKey);
                db.AddInParameter(dbCommand, "QBUserName", DbType.String, email);
                db.AddInParameter(dbCommand, "QBPassword", DbType.String, password);

                qbuserid = Int32.Parse(db.ExecuteScalar(dbCommand).ToString());
            }
            catch(Exception ex)
            {
                responseObject.ResultCode = "ERROR";
                responseObject.ResultMessage = ex.Message;
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SaveQBDetails", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            if (qbuserid > 0)
            {
                responseObject.ResultCode = "SUCCESS";
                responseObject.ResultMessage = "Quickblox user credentials created successfully.";
            }
            else
            {
                responseObject.ResultCode = "ERROR";
                responseObject.ResultMessage = "A problem occured while creating quickblox user.";
            }
            return (responseObject);
        }
Beispiel #6
0
        /// <summary>
        /// Get problem spefic experts who quoted or all
        /// experts for a category/sub category combination.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="problemid">string</param>
        /// <param name="categoryid">string</param>
        /// <param name="subcategoryid">string</param>
        /// <returns>SessionResponseObject</returns>
        public ResponseObjectForAnything GetExpertsByCatSubCat(string sessionKey, string pincode, string distance, string categoryid, string subcategoryid)
        {
            List<User> lstexperts = new List<User>();
            List<ProblemBid> lstProblemBids = new List<ProblemBid>();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            SessionResponseObject session = new SessionResponseObject();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            bool isValid = authEngine.IsValidSession(sessionKey);
            DataSet dsExperts = new DataSet();

            if(isValid)
            {
                try
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetExperts");
                    float latitude, longitude;
                    GeoHelper geoHelper = new GeoHelper();
                    geoHelper.GetGeoLocationByPinCode(pincode, out latitude, out longitude);
                    db.AddInParameter(dbCommand, "@Distance", DbType.Decimal, distance);
                    db.AddInParameter(dbCommand, "@Latitude", DbType.Decimal, latitude);
                    db.AddInParameter(dbCommand, "@Longitude", DbType.Decimal, longitude);
                    db.AddInParameter(dbCommand, "@CategoryID", DbType.Int32, Int32.Parse(categoryid));
                    db.AddInParameter(dbCommand, "@SubCategoryID", DbType.Int32, Int32.Parse(subcategoryid));
                    dsExperts = db.ExecuteDataSet(dbCommand);

                    if(dsExperts.Tables.Count > 0)
                    {
                        DataTable tUser = dsExperts.Tables[0];
                        foreach(DataRow tRow in tUser.Rows)
                        {
                            User user = new User();
                            if (tRow["UserID"] != DBNull.Value) { user.UserID = Int32.Parse(tRow["UserID"].ToString()); }
                            if (tRow["UserRoleID"] != DBNull.Value) { user.UserID = Int32.Parse(tRow["UserRoleID"].ToString()); }
                            if (tRow["FirstName"] != DBNull.Value) { user.FirstName = tRow["FirstName"].ToString(); }
                            if (tRow["LastName"] != DBNull.Value) { user.LastName = tRow["LastName"].ToString(); }
                            if (tRow["DisplayName"] != DBNull.Value) { user.DisplayName = tRow["DisplayName"].ToString(); }
                            if (tRow["EmailID"] != DBNull.Value) { user.EmailID = tRow["EmailID"].ToString(); }
                            if (tRow["PinCode"] != DBNull.Value) { user.PinCode = tRow["PinCode"].ToString(); }
                            if (tRow["Address1"] != DBNull.Value) { user.Address1 = tRow["Address1"].ToString(); }
                            if (tRow["Address2"] != DBNull.Value) { user.Address2 = tRow["Address2"].ToString(); }
                            if (tRow["Address3"] != DBNull.Value) { user.Address3 = tRow["Address3"].ToString(); }
                            if (tRow["City"] != DBNull.Value) { user.City = tRow["City"].ToString(); }
                            if (tRow["Distance"] != DBNull.Value) { user.Distance = Convert.ToDecimal(tRow["Distance"].ToString()); }
                            if (tRow["PhoneNumber"] != DBNull.Value) { user.PhoneNumber = tRow["PhoneNumber"].ToString(); }
                            if (tRow["ProfilePicPath"] != DBNull.Value) { user.ProfilePicPath = tRow["ProfilePicPath"].ToString(); }
                            if (tRow["AvgRating"] != DBNull.Value) { user.AvgRating = Convert.ToDecimal(tRow["AvgRating"].ToString()); }
                            lstexperts.Add(user);
                        }
                        responseObject.ResultCode = "SUCCESS";
                        responseObject.ResultObjectRecordCount = tUser.Rows.Count;
                        responseObject.ResultObjectJSON = Serializer.ObjectToJSON(lstexperts);
                        if (tUser.Rows.Count == 0) { responseObject.ResultMessage = "No Experts found for this combination of category and subcategory."; }
                    }
                }
                catch (Exception ex)
                {
                    responseObject.ResultCode = "ERROR";
                    responseObject.ResultMessage = ex.Message;
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetExpertsByCatSubCat", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            return responseObject;
        }
        /// <summary>
        /// get sub categories for all selected categories.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="categorylist">string</param>
        /// <returns>string</returns>
        public ResponseObjectForAnything GetSubCatsbyCategories(string sessionKey, string categorylist)
        {
            List<SubCategory> lstsubcategory = new List<SubCategory>();
            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_GetSubCategoriesByCategories");

                    using (IDataReader dr = db.ExecuteReader(dbCommand))
                    {
                        while (dr.Read())
                        {
                            SubCategory subcategory = new SubCategory();
                            if (dr["SubCategoryID"] != DBNull.Value) { subcategory.SubCategoryID = Convert.ToInt32(dr["SubCategoryID"]); }
                            if (dr["SubCategoryName"] != DBNull.Value) { subcategory.SubCategoryName = dr["SubCategoryName"].ToString(); }
                            lstsubcategory.Add(subcategory);
                            count++;
                        }
                    }
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(lstsubcategory);
                    responseObject.ResultObjectRecordCount = count;
                    if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No subcategories configured."; }
                }
            }
            catch (Exception ex)
            {
                responseObject.ResultCode = "ERROR";
                responseObject.ResultMessage = ex.Message;
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetSubCatsbyCategories", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            return (responseObject);
        }
        /// <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);
        }
        public ResponseObjectForAnything GetRecentProblems(string sessionkey)
        {
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            List<Problem> recentproblst = new List<Problem>();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            int count = 0;
            bool isValid = true;
            if (!string.IsNullOrEmpty(sessionkey)) { isValid = authEngine.IsValidSession(sessionkey); }
            if(isValid)
            {
                try
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetRecentProblems");
                    DataSet dsRecentProbs = db.ExecuteDataSet(dbCommand);
                    if(dsRecentProbs.Tables.Count > 0)
                    {
                        DataTable tRecentProbs = dsRecentProbs.Tables[0];

                        foreach(DataRow dRow in tRecentProbs.Rows)
                        {
                            Problem problem = new Problem();
                            if (dRow["ID"] != DBNull.Value) { problem.ID = Int32.Parse(dRow["ID"].ToString()); }
                            if (dRow["Thumbnailmedia"] != DBNull.Value) { problem.ThumbnailMedia = dRow["Thumbnailmedia"].ToString(); }
                            if (dRow["ProblemHeading"] != DBNull.Value) { problem.ProblemHeading = dRow["ProblemHeading"].ToString(); }
                            if (dRow["Description"] != DBNull.Value) { problem.Description = dRow["Description"].ToString(); }
                            recentproblst.Add(problem);
                            count++;
                        }
                    }
                    else
                    {
                        responseObject.ResultCode = "SUCCESS";
                        responseObject.ResultMessage = "No recently resolved videos found.";
                    }
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectRecordCount = count;
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(recentproblst);
                    if (count <= 0) { responseObject.ResultMessage = "No recently resolved videos found."; }
                }
                catch (Exception ex)
                {
                    responseObject.ResultCode = "ERROR";
                    responseObject.ResultMessage = ex.Message;
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetProblemDetailById", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            return responseObject;
        }
Beispiel #10
0
        /// <summary>
        /// Get Problems by user ID.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <returns>string</returns>
        public ResponseObjectForAnything GetProblemsByUserID(string sessionKey, string startindex, string pageindex, bool paging, string problemstatusid)
        {
            DashboardObject dashboardobject = new DashboardObject();
            List<RecentProblemObject> recentproblemlist = new List<RecentProblemObject>();
            List<Problem> problemlist = new List<Problem>();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            bool isValid = true;
            int count = 0;
            if (!string.IsNullOrEmpty(sessionKey))
            {
                isValid = authEngine.IsValidSession(sessionKey);
            }
            List<ProblemStatus> lstproblemstatus = new List<ProblemStatus>();
            List<Category> lstcategory = new List<Category>();
            List<Company> lstcompany = new List<Company>();

            if (isValid)
            {
                try
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetProblemsByUserID");
                    db.AddInParameter(dbCommand, "@SessionKey", DbType.String, sessionKey);
                    db.AddInParameter(dbCommand, "@StartCount", DbType.Int32, Int32.Parse(startindex));
                    db.AddInParameter(dbCommand, "@PageSize", DbType.Int32, Int32.Parse(pageindex));
                    db.AddInParameter(dbCommand, "@IsPaging", DbType.Boolean, Convert.ToBoolean(paging));
                    db.AddInParameter(dbCommand, "@ProblemStatusID", DbType.Boolean, Int32.Parse(problemstatusid));

                    DataSet dsProblem = db.ExecuteDataSet(dbCommand);

                    if (dsProblem.Tables.Count > 0)
                    {
                        DataTable tProblem = dsProblem.Tables[0];

                        foreach (DataRow dRow in tProblem.Rows)
                        {
                            Problem problem = new Problem();
                            User user = new User();
                            if (dRow["ID"] != DBNull.Value) { problem.ID = Int32.Parse(dRow["ID"].ToString()); }
                            if (dRow["UserID"] != DBNull.Value) { problem.UserID = Int32.Parse(dRow["UserID"].ToString()); }
                            if (dRow["FirstName"] != DBNull.Value) { problem.FirstName = dRow["FirstName"].ToString(); }
                            if (dRow["LastName"] != DBNull.Value) { problem.LastName = dRow["LastName"].ToString(); }
                            if (dRow["DisplayName"] != DBNull.Value) { problem.DisplayName = dRow["DisplayName"].ToString(); }
                            if (dRow["EmailID"] != DBNull.Value) { problem.EmailID = dRow["EmailID"].ToString(); }
                            if (dRow["CompanyRelated"] != DBNull.Value) { problem.IsCompanyRelated = Convert.ToBoolean(dRow["CompanyRelated"].ToString()); }
                            if (dRow["CompanyID"] != DBNull.Value) { problem.CompanyID = Int32.Parse(dRow["CompanyID"].ToString()); }
                            if (dRow["CompanyName"] != DBNull.Value) { problem.CompanyName = dRow["CompanyName"].ToString(); }
                            if (dRow["ProblemHeading"] != DBNull.Value) { problem.ProblemHeading = dRow["ProblemHeading"].ToString(); }
                            if (dRow["CategoryID"] != DBNull.Value) { problem.CategoryID = Int32.Parse(dRow["CategoryID"].ToString()); }
                            if (dRow["SubCategoryID"] != DBNull.Value) { problem.SubCategoryID = Int32.Parse(dRow["SubCategoryID"].ToString()); }
                            if (dRow["ProductID"] != DBNull.Value) { problem.ProductID = Int32.Parse(dRow["ProductID"].ToString()); }
                            if (dRow["ModelNo"] != DBNull.Value) { problem.ModelNo = dRow["ModelNo"].ToString(); }
                            if (dRow["Description"] != DBNull.Value) { problem.Description = dRow["Description"].ToString(); }
                            if (dRow["PurchaseMonth"] != DBNull.Value) { problem.PurchaseMonth = Int32.Parse(dRow["PurchaseMonth"].ToString()); }
                            if (dRow["PurchaseYear"] != DBNull.Value) { problem.PurchaseYear = Int32.Parse(dRow["PurchaseYear"].ToString()); }
                            if (dRow["ProductStatusID"] != DBNull.Value) { problem.ProductStatusID = Int32.Parse(dRow["ProductStatusID"].ToString()); }
                            if (dRow["ProductStatusName"] != DBNull.Value) { problem.ProductStatusName = dRow["ProductStatusName"].ToString(); }
                            if (dRow["ProblemStatusID"] != DBNull.Value) { problem.ProblemStatusID = Int32.Parse(dRow["ProblemStatusID"].ToString()); }
                            if (dRow["ProblemStatusName"] != DBNull.Value) { problem.ProblemStatusName = dRow["ProblemStatusName"].ToString(); }
                            if (dRow["ResolutionNeededBy"] != DBNull.Value) { problem.ResolutionNeededBy = Convert.ToDateTime(dRow["ResolutionNeededBy"].ToString()); }
                            if (dRow["IsVirtual"] != DBNull.Value) { problem.IsVirtual = Convert.ToBoolean(dRow["IsVirtual"].ToString()); }
                            if (dRow["IsRegisteredAddress"] != DBNull.Value) { problem.IsRegisteredAddress = Convert.ToBoolean(dRow["IsRegisteredAddress"].ToString()); }
                            if (dRow["Address1"] != DBNull.Value) { problem.Address1 = dRow["Address1"].ToString(); }
                            if (dRow["Address2"] != DBNull.Value) { problem.Address2 = dRow["Address2"].ToString(); }
                            if (dRow["Address3"] != DBNull.Value) { problem.Address3 = dRow["Address3"].ToString(); }
                            if (dRow["City"] != DBNull.Value) { problem.City = dRow["City"].ToString(); }
                            if (dRow["StateID"] != DBNull.Value) { problem.StateID = Int32.Parse(dRow["StateID"].ToString()); }
                            if (dRow["StateName"] != DBNull.Value) { problem.StateName = dRow["StateName"].ToString(); }
                            if (dRow["CountryID"] != DBNull.Value) { problem.CountryID = Int32.Parse(dRow["CountryID"].ToString()); }
                            if (dRow["CountryName"] != DBNull.Value) { problem.CountryName = dRow["CountryName"].ToString(); }
                            if (dRow["PinCode"] != DBNull.Value) { problem.PinCode = dRow["PinCode"].ToString(); }
                            if (dRow["Latitude"] != DBNull.Value) { problem.Latitude = Convert.ToDecimal(dRow["Latitude"].ToString()); }
                            if (dRow["Longitude"] != DBNull.Value) { problem.Longitude = Convert.ToDecimal(dRow["Longitude"].ToString()); }
                            if (dRow["Distance"] != DBNull.Value) { problem.Distance = Convert.ToDecimal(dRow["Distance"].ToString()); }
                            if (dRow["ThumbnailMedia"] != DBNull.Value) { problem.ThumbnailMedia = dRow["ThumbnailMedia"].ToString(); }
                            problemlist.Add(problem);
                            count++;
                        }
                        dashboardobject.ProblemList = problemlist;
                    }
                    if (dsProblem.Tables.Count > 1)
                    {
                        DataTable tProblemStatus = dsProblem.Tables[1];

                        foreach (DataRow dRow in tProblemStatus.Rows)
                        {
                            ProblemStatus probstatus = new ProblemStatus();
                            if (dRow["ProblemStatusID"] != DBNull.Value) { probstatus.ProblemStatusID = Int32.Parse(dRow["ProblemStatusID"].ToString()); }
                            if (dRow["ProblemStatusName"] != DBNull.Value) { probstatus.ProblemStatusName = dRow["ProblemStatusName"].ToString(); }
                            lstproblemstatus.Add(probstatus);
                        }
                        dashboardobject.ProblemStatus = lstproblemstatus;
                    }
                    if (!paging)
                    {
                        if (dsProblem.Tables.Count > 2)
                        {
                            DataTable tCategories = dsProblem.Tables[2];
                            foreach (DataRow dRow in tCategories.Rows)
                            {
                                Category category = new Category();
                                if (dRow["ID"] != DBNull.Value) { category.ID = Int32.Parse(dRow["ID"].ToString()); }
                                if (dRow["Name"] != DBNull.Value) { category.Name = dRow["Name"].ToString(); }
                                lstcategory.Add(category);
                            }
                            dashboardobject.Categories = lstcategory;
                        }
                        if (dsProblem.Tables.Count > 3)
                        {
                            DataTable tCountries = dsProblem.Tables[3];
                            foreach (DataRow dRow in tCountries.Rows)
                            {
                                Company company = new Company();
                                if (dRow["CompanyID"] != DBNull.Value) { company.CompanyID = Int32.Parse(dRow["CompanyID"].ToString()); }
                                if (dRow["CompanyName"] != DBNull.Value) { company.CompanyName = dRow["CompanyName"].ToString(); }
                                lstcompany.Add(company);
                            }
                            dashboardobject.Companies = lstcompany;
                        }
                        if (dsProblem.Tables.Count > 4)
                        {
                            DataTable tProblem = dsProblem.Tables[4];

                            foreach (DataRow dRow in tProblem.Rows)
                            {
                                RecentProblemObject problem = new RecentProblemObject();
                                if (dRow["ProblemID"] != DBNull.Value) { problem.ProblemID = Int32.Parse(dRow["ProblemID"].ToString()); }
                                if (dRow["ProblemTitle"] != DBNull.Value) { problem.ProblemTitle = dRow["ProblemTitle"].ToString(); }
                                if (dRow["Description"] != DBNull.Value) { problem.Description = dRow["Description"].ToString(); }
                                if (dRow["ProblemImagePath"] != DBNull.Value) { problem.ProblemImagePath = dRow["ProblemImagePath"].ToString(); }
                                recentproblemlist.Add(problem);
                            }
                            dashboardobject.RecentProblems = recentproblemlist;
                        }
                    }
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectRecordCount = count;
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(dashboardobject);
                    if (responseObject.ResultObjectRecordCount <= 0) { responseObject.ResultMessage = "No records found."; }
                }
                catch (Exception ex)
                {
                    responseObject.ResultCode = "ERROR";
                    responseObject.ResultMessage = ex.Message;
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetProblemsByUserID", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            return responseObject;
        }
Beispiel #11
0
        /// <summary>
        /// This method gets the problems based on search criteria.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="startIndex">string</param>
        /// <param name="pageSize">string</param>
        /// <param name="latitude">string</param>
        /// <param name="longitude">string</param>
        /// <param name="distance">string</param>
        /// <param name="categoryid">string</param>
        /// <param name="subcategoryid">string</param>
        /// <param name="companyname">string</param>
        /// <param name="isLandingPage">string</param>
        /// <returns>List<Problem></returns>
        public List<Problem> GetProblemsBySearchCriteria(string sessionKey, string startIndex, string pageSize, string latitude, string longitude, string location, string distance, string categoryid, string subcategoryid,
                                                         string companyname, string modelno, string problemheading, string posteddate)
        {
            List<Problem> problemlist = new List<Problem>();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            bool isValid = true;
            if (!string.IsNullOrEmpty(sessionKey)) { isValid = authEngine.IsValidSession(sessionKey); }
            List<Problem> lstproblem = new List<Problem>();
            Int32 sIndex = 1;
            Int32 pSize = 10;
            if (isValid)
            {
                try
                {
                    if (!string.IsNullOrEmpty(startIndex)) { sIndex = Int32.Parse(startIndex); }
                    if (!string.IsNullOrEmpty(pageSize)) { pSize = Int32.Parse(pageSize); }

                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetProblemsAll");
                    db.AddInParameter(dbCommand, "@StartIndex", DbType.Int32, sIndex);
                    db.AddInParameter(dbCommand, "@PageSize", DbType.Int32, pSize);
                    db.AddInParameter(dbCommand, "@Latitude", DbType.Decimal, Convert.ToDecimal(latitude));
                    db.AddInParameter(dbCommand, "@Longitude", DbType.Decimal, Convert.ToDecimal(longitude));
                    db.AddInParameter(dbCommand, "@Location", DbType.String, location);
                    db.AddInParameter(dbCommand, "@Distance", DbType.Int32, Int32.Parse(distance));
                    db.AddInParameter(dbCommand, "@CategoryID", DbType.Int32, Int32.Parse(categoryid));
                    db.AddInParameter(dbCommand, "@SubCategoryID", DbType.Int32, Int32.Parse(subcategoryid));
                    db.AddInParameter(dbCommand, "@CompanyName", DbType.String, companyname);
                    db.AddInParameter(dbCommand, "@ProblemHeading", DbType.String, problemheading);
                    db.AddInParameter(dbCommand, "@ModelNo", DbType.String, modelno);
                    db.AddInParameter(dbCommand, "@PostedDate", DbType.DateTime, Int32.Parse(posteddate));

                    DataSet dsProblem = db.ExecuteDataSet(dbCommand);

                    if (dsProblem.Tables.Count > 0)
                    {
                        DataTable tProblem = dsProblem.Tables[0];

                        foreach (DataRow dRow in tProblem.Rows)
                        {
                            Problem problem = new Problem();
                            if (dRow["ID"] != DBNull.Value) { problem.ID = Int32.Parse(dRow["ID"].ToString()); }
                            if (dRow["CompanyRelated"] != DBNull.Value) { problem.IsCompanyRelated = Convert.ToBoolean(dRow["CompanyRelated"].ToString()); }
                            if (dRow["CompanyID"] != DBNull.Value) { problem.CompanyID = Int32.Parse(dRow["CompanyID"].ToString()); }
                            if (dRow["ProblemHeading"] != DBNull.Value) { problem.ProblemHeading = dRow["ProblemHeading"].ToString(); }
                            if (dRow["CategoryID"] != DBNull.Value) { problem.CategoryID = Int32.Parse(dRow["CategoryID"].ToString()); }
                            if (dRow["SubCategoryID"] != DBNull.Value) { problem.SubCategoryID = Int32.Parse(dRow["SubCategoryID"].ToString()); }
                            if (dRow["ProductID"] != DBNull.Value) { problem.ProductID = Int32.Parse(dRow["ProductID"].ToString()); }
                            if (dRow["ModelNo"] != DBNull.Value) { problem.ModelNo = dRow["ModelNo"].ToString(); }
                            if (dRow["Description"] != DBNull.Value) { problem.Description = dRow["Description"].ToString(); }
                            if (dRow["PurchaseMonth"] != DBNull.Value) { problem.PurchaseMonth = Int32.Parse(dRow["PurchaseMonth"].ToString()); }
                            if (dRow["PurchaseYear"] != DBNull.Value) { problem.PurchaseYear = Int32.Parse(dRow["PurchaseYear"].ToString()); }
                            if (dRow["ProductStatusID"] != DBNull.Value) { problem.ProductStatusID = Int32.Parse(dRow["ProductStatusID"].ToString()); }
                            if (dRow["ResolutionNeededBy"] != DBNull.Value) { problem.ResolutionNeededBy = Convert.ToDateTime(dRow["ResolutionNeededBy"].ToString()); }
                            if (dRow["IsVirtual"] != DBNull.Value) { problem.IsVirtual = Convert.ToBoolean(dRow["IsVirtual"].ToString()); }
                            if (dRow["IsRegisteredAddress"] != DBNull.Value) { problem.IsRegisteredAddress = Convert.ToBoolean(dRow["IsRegisteredAddress"].ToString()); }
                            if (dRow["Address1"] != DBNull.Value) { problem.Address1 = dRow["Address1"].ToString(); }
                            if (dRow["Address2"] != DBNull.Value) { problem.Address2 = dRow["Address2"].ToString(); }
                            if (dRow["Address3"] != DBNull.Value) { problem.Address3 = dRow["Address3"].ToString(); }
                            if (dRow["City"] != DBNull.Value) { problem.City = dRow["City"].ToString(); }
                            if (dRow["StateID"] != DBNull.Value) { problem.StateID = Int32.Parse(dRow["StateID"].ToString()); }
                            if (dRow["CountryID"] != DBNull.Value) { problem.CountryID = Int32.Parse(dRow["CountryID"].ToString()); }
                            if (dRow["PinCode"] != DBNull.Value) { problem.PinCode = dRow["PinCode"].ToString(); }
                            if (dRow["ThumbnailMedia"] != DBNull.Value) { problem.PinCode = dRow["ThumbnailMedia"].ToString(); }
                            lstproblem.Add(problem);
                        }
                    }
                }
                catch (Exception ex)
                {
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetProblemsBySearchCriteria", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            if (lstproblem.Count > 0)
                return (lstproblem);
            else
                return null;
        }
Beispiel #12
0
 /// <summary>
 /// Get media content for specified problem
 /// </summary>
 /// <param name="sessionkey">string</param>
 /// <param name="problemid">string</param>
 /// <returns>string</returns>
 public ResponseObjectForAnything GetProblemMediaForProblemID(string sessionkey, string problemid)
 {
     ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
     List<ProblemMedia> lstproblemmedia = new List<ProblemMedia>();
     AuthenticationEngine authEngine = new AuthenticationEngine();
     bool isValid = true;
     int count = 0;
     if (!string.IsNullOrEmpty(sessionkey)) { isValid = authEngine.IsValidSession(sessionkey); }
     if(isValid)
     {
         try
         {
             Database db = DatabaseFactory.CreateDatabase();
             DbCommand dbCommand = db.GetStoredProcCommand("usp_GetMediaByProblemID");
             db.AddInParameter(dbCommand, "@ProblemID", DbType.Int32, Int32.Parse(problemid));
             DataSet dsMedia = db.ExecuteDataSet(dbCommand);
             if (dsMedia.Tables.Count > 0)
             {
                 DataTable tMedia = dsMedia.Tables[0];
                 foreach (DataRow dRow in tMedia.Rows)
                 {
                     ProblemMedia media = new ProblemMedia();
                     if (dRow["ProblemMediaID"] != DBNull.Value) { media.ProblemMediaID = Int32.Parse(dRow["ProblemMediaID"].ToString()); }
                     if (dRow["ProblemID"] != DBNull.Value) { media.ProblemID = Int32.Parse(dRow["ProblemID"].ToString()); }
                     if (dRow["IsImage"] != DBNull.Value) { media.IsImage = Convert.ToBoolean(dRow["IsImage"].ToString()); }
                     if (dRow["MediaPath"] != DBNull.Value) { media.MediaPath = dRow["MediaPath"].ToString(); }
                     lstproblemmedia.Add(media);
                     count++;
                 }
             }
             else
             {
                 responseObject.ResultCode = "SUCCESS";
                 responseObject.ResultMessage = "No media details found for this problem.";
             }
             responseObject.ResultCode = "SUCCESS";
             responseObject.ResultObjectRecordCount = count;
             responseObject.ResultObjectJSON = Serializer.ObjectToJSON(lstproblemmedia);
             if (responseObject.ResultObjectRecordCount <= 0) { responseObject.ResultMessage = "No media details found for this problem."; }
         }
         catch (Exception ex)
         {
             responseObject.ResultCode = "ERROR";
             responseObject.ResultMessage = ex.Message;
             CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetProblemDetailsForMarkup", System.DateTime.Now);
             ExceptionManager.PublishException(exc);
         }
     }
     return (responseObject);
 }
Beispiel #13
0
        /// <summary>
        /// This method is used to retrieve Problem media details from database.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="probImageId">string</param>
        /// <returns>string</returns>
        public ProblemMedia GetProblemMediaDetail(string sessionKey, Int32 probImageId)
        {
            ProblemMedia probMedia = new ProblemMedia();
            try
            {

                Database db = DatabaseFactory.CreateDatabase();
                DbCommand dbCommand = db.GetStoredProcCommand("usp_GetImageDetail");
                db.AddInParameter(dbCommand, "@ProblemMediaId", DbType.Int32, probImageId);
                db.AddInParameter(dbCommand, "@SessionKey", DbType.String, sessionKey);

                using (IDataReader dr = db.ExecuteReader(dbCommand))
                {
                    while (dr.Read())
                    {
                        if (dr["ProblemMediaID"] != DBNull.Value) { probMedia.ProblemMediaID = Int32.Parse(dr["ProblemMediaID"].ToString()); }
                        if (dr["ProblemID"] != DBNull.Value) { probMedia.ProblemID = Int32.Parse(dr["ProblemID"].ToString()); }
                        if (dr["MediaPath"] != DBNull.Value) { probMedia.MediaPath = dr["MediaPath"].ToString(); }
                        if (dr["IsImage"] != DBNull.Value) { probMedia.IsImage = Convert.ToBoolean(dr["IsImage"].ToString()); }
                    }
                }
            }
            catch (Exception ex)
            {
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetAssetImageDetail", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }

            return probMedia;
        }
Beispiel #14
0
 /// <summary>
 /// Get problem details for markup on maps
 /// </summary>
 /// <param name="sessionkey">string</param>
 /// <param name="problemid">string</param>
 /// <returns>string</returns>
 public ResponseObjectForAnything GetProblemDetailsForMarkup(string sessionkey, string problemid)
 {
     Problem problem = new Problem();
     ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
     AuthenticationEngine authEngine = new AuthenticationEngine();
     bool isValid = true;
     int count = 0;
     if (!string.IsNullOrEmpty(sessionkey)) { isValid = authEngine.IsValidSession(sessionkey); }
     if (isValid)
     {
         try
         {
             Database db = DatabaseFactory.CreateDatabase();
             DbCommand dbCommand = db.GetStoredProcCommand("usp_GetProblemDetailsForMarkup");
             db.AddInParameter(dbCommand, "@ProblemID", DbType.Int32, Int32.Parse(problemid));
             DataSet dsProblem = db.ExecuteDataSet(dbCommand);
             if (dsProblem.Tables.Count > 0)
             {
                 DataTable tProblem = dsProblem.Tables[0];
                 foreach (DataRow dRow in tProblem.Rows)
                 {
                     if (dRow["ID"] != DBNull.Value) { problem.ID = Int32.Parse(dRow["ID"].ToString()); }
                     if (dRow["Address1"] != DBNull.Value) { problem.Address1 = dRow["Address1"].ToString(); }
                     if (dRow["Address2"] != DBNull.Value) { problem.Address2 = dRow["Address2"].ToString(); }
                     if (dRow["City"] != DBNull.Value) { problem.City = dRow["City"].ToString(); }
                     if (dRow["StateName"] != DBNull.Value) { problem.StateName = dRow["StateName"].ToString(); }
                     if (dRow["CountryName"] != DBNull.Value) { problem.CountryName = dRow["CountryName"].ToString(); }
                     if (dRow["PinCode"] != DBNull.Value) { problem.PinCode = dRow["PinCode"].ToString(); }
                     if (dRow["ProblemImageCount"] != DBNull.Value) { problem.ProblemImageCount = Int32.Parse(dRow["ProblemImageCount"].ToString()); }
                     if (dRow["ProblemVideoCount"] != DBNull.Value) { problem.ProblemVideoCount = Int32.Parse(dRow["ProblemVideoCount"].ToString()); }
                     count++;
                 }
             }
             else
             {
                 responseObject.ResultCode = "SUCCESS";
                 responseObject.ResultMessage = "No information found for this problem.";
             }
             responseObject.ResultCode = "SUCCESS";
             responseObject.ResultObjectRecordCount = count;
             responseObject.ResultObjectJSON = Serializer.ObjectToJSON(problem);
             if (responseObject.ResultObjectRecordCount <= 0) { responseObject.ResultMessage = "No records found."; }
         }
         catch (Exception ex)
         {
             responseObject.ResultCode = "ERROR";
             responseObject.ResultMessage = ex.Message;
             CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetProblemDetailsForMarkup", System.DateTime.Now);
             ExceptionManager.PublishException(exc);
         }
     }
     return (responseObject);
 }
Beispiel #15
0
        public ResponseObjectForAnything InviteExperts(string sessionkey, string problemid, string expertids)
        {
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            User user = new User();
            int expertid = 0;
            bool isValid = authEngine.IsValidSession(sessionkey);
            if(isValid)
            {
                try
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_InviteExperts");
                    db.AddInParameter(dbCommand, "@SessionKey", DbType.String, sessionkey);
                    db.AddInParameter(dbCommand, "@ProblemID", DbType.Int32, Int32.Parse(problemid));
                    string[] invitedexperts = expertids.Split(",".ToCharArray());
                    DataSet dsExperts = ToDataSet(invitedexperts, "Name");
                    db.AddInParameter(dbCommand, "@UserIDs", DbType.String, dsExperts.GetXml());

                    expertid = Int32.Parse(db.ExecuteScalar(dbCommand).ToString());
                    if (expertid > 0)
                    {
                        responseObject.ResultCode = "SUCCESS";
                        responseObject.ResultMessage = "Problem created successfully.";
                        responseObject.ResultObjectID = expertid;
                    }
                    else
                    {
                        responseObject.ResultCode = "ERROR";
                        responseObject.ResultMessage = "Unknown error occured, please try again later.";
                    }

                }
                catch(Exception ex)
                {
                    responseObject.ResultCode = "ERROR";
                    responseObject.ResultMessage = ex.Message;
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SaveProblem", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            return (responseObject);
        }
        /// <summary>
        /// This method gets products based on selected 
        /// categoryID and subcategoryID.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="categoryID">int</param>
        /// <param name="subcategoryID">int</param>
        /// <returns>ResponseObjectForAnything</returns>
        public ResponseObjectForAnything GetProductByCatSubCatID(string sessionKey, string categoryID, string subcategoryID)
        {
            List<Product> productlist = new List<Product>();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            bool isValid = authEngine.IsValidSession(sessionKey);
            int count = 0;

            try
            {
                if (isValid)
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetProductsByCatSubCatID");
                    db.AddInParameter(dbCommand, "CategoryID", DbType.Int32, Int32.Parse(categoryID));
                    db.AddInParameter(dbCommand, "SubCategoryID", DbType.Int32, Int32.Parse(subcategoryID));

                    using (IDataReader dr = db.ExecuteReader(dbCommand))
                    {
                        while (dr.Read())
                        {
                            Product product = new Product();
                            if (dr["ProductID"] != DBNull.Value) { product.ProductID = Convert.ToInt32(dr["ProductID"]); }
                            if (dr["ProductName"] != DBNull.Value) { product.ProductName = dr["ProductName"].ToString(); }
                            if (dr["CategoryID"] != DBNull.Value) { product.CategoryID = Int32.Parse(dr["CategoryID"].ToString()); }
                            if (dr["SubCategoryID"] != DBNull.Value) { product.SubCategoryID = Int32.Parse(dr["SubCategoryID"].ToString()); }
                            productlist.Add(product);
                            count++;
                        }
                    }
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectRecordCount = count;
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(productlist);
                    if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No products configured."; }
                }
            }
            catch (Exception ex)
            {
                responseObject.ResultCode = "ERROR";
                responseObject.ResultMessage = ex.Message;
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetProducts", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            return (responseObject);
        }
Beispiel #17
0
        /// <summary>
        /// Save problem media files.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="problemId">string</param>
        /// <param name="filePath">string</param>
        /// <param name="fileType">string</param>
        /// <returns>string</returns>
        public string SaveMedia(string sessionKey, string problemId, string filePath, string fileType, bool isThumbnailmedia)
        {
            string retValue = string.Empty;
            ResponseObjectForAnything obj = new ResponseObjectForAnything();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            Int32 probId = -1;
            Int32 probMediaId = -1;
            bool isValid = authEngine.IsValidSession(sessionKey);
            if (isValid)
            {

                try
                {
                    if (!string.IsNullOrEmpty(problemId))
                    {
                        probId = Int32.Parse(problemId);
                    }

                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_SaveProblemMedia");

                    db.AddInParameter(dbCommand, "@SessionKey", DbType.String, sessionKey);
                    db.AddInParameter(dbCommand, "@ProblemID", DbType.Int32, probId);
                    db.AddInParameter(dbCommand, "@MediaPath", DbType.String, filePath);
                    if(fileType == "image")
                        db.AddInParameter(dbCommand, "@IsImage", DbType.Boolean, true);
                    else
                        db.AddInParameter(dbCommand, "@IsImage", DbType.Boolean, false);
                    db.AddInParameter(dbCommand, "@IsThumbnailMedia", DbType.Boolean, isThumbnailmedia);
                    probMediaId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString());
                    ProblemMedia problemmedia = GetProblemMediaDetail(sessionKey, probMediaId);
                    obj.ResultObject = filePath;
                    obj.ResultObjectID = probMediaId;
                }
                catch (Exception ex)
                {
                    obj.ResultCode = "ERROR";
                    obj.ResultMessage = ex.Message.ToString();
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SaveImageforProblem", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            if (probMediaId > 0)
            {
                obj.ResultCode = "SUCCESS";
            }
            else
            {
                obj.ResultCode = "ERROR";
            }
            retValue = Serializer.ObjectToJSON(obj);

            return retValue;
        }
        /// <summary>
        /// This method gets list of states from
        /// system based on selected/defaulted country.
        /// </summary>
        /// <returns>ResponseObjectForAnything</returns>
        public ResponseObjectForAnything GetStateList(string countryID)
        {
            List<State> statelist = new List<State>();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            int count = 0;

            try
            {
                Database db = DatabaseFactory.CreateDatabase();
                DbCommand dbCommand = db.GetStoredProcCommand("usp_GetStates");
                db.AddInParameter(dbCommand, "CountryID", DbType.Int32, Int32.Parse(countryID));

                using (IDataReader dr = db.ExecuteReader(dbCommand))
                {
                    while (dr.Read())
                    {
                        State state = new State();
                        if (dr["ID"] != DBNull.Value) { state.StateID = Convert.ToInt32(dr["ID"]); }
                        if (dr["Name"] != DBNull.Value) { state.StateName = dr["Name"].ToString(); }
                        statelist.Add(state);
                        count++;
                    }
                }
                responseObject.ResultCode = "SUCCESS";
                responseObject.ResultObjectJSON = Serializer.ObjectToJSON(statelist);
                responseObject.ResultObjectRecordCount = count;
                if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No states configured."; }
            }
            catch (Exception ex)
            {
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetStates", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            return (responseObject);
        }
Beispiel #19
0
        /// <summary>
        /// This method is used to upload images and videos.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="filename">string</param>
        /// <param name="context">string</param>
        /// <param name="filetype">string</param>
        /// <param name="problemId">string</param>
        /// <returns>string</returns>
        public string UploadFiles(string sessionKey, HttpContext context, string fileType, 
                                  string problemId, string resolutionId)
        {
            string retValue = string.Empty;
            string fileUploadPath = "media";
            string newFileName = string.Empty;
            AuthenticationEngine authEngine = new AuthenticationEngine();
            ResponseObjectForAnything obj = new ResponseObjectForAnything();
            ProblemEngine probEngine = new ProblemEngine();
            BidEngine bidEngine = new BidEngine();
            UserEngine user = new UserEngine();
            try
            {
                bool isValid = true;
                if (!string.IsNullOrEmpty(sessionKey)) { authEngine.IsValidSession(sessionKey); }

                if (isValid)
                {
                    obj.ResultCode = "SUCCESS";

                    if (Directory.Exists(fileUploadPath) == false) { Directory.CreateDirectory(fileUploadPath); }

                    HttpFileCollection files = context.Request.Files;
                    string[] uplaodedfiles = new string[files.Count];
                    for (int filecount = 0; filecount < files.Count; filecount++)
                    {
                        HttpPostedFile file = files[filecount];
                        string fname;
                        if (HttpContext.Current.Request.Browser.Browser.ToUpper() == "IE" || HttpContext.Current.Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                        {
                            string[] testfiles = file.FileName.Split(new char[] { '\\' });
                            fname = testfiles[testfiles.Length - 1];
                        }
                        else
                        {
                            fname = file.FileName;
                        }
                        //fname = System.IO.Path.Combine(context.Server.MapPath("~/uploads/"), fname);
                        newFileName = Guid.NewGuid().ToString() + "_" + fname.Replace(" ", "_");
                        if (ConfigurationManager.AppSettings["FileUploadPath"] != null)
                        {
                            fileUploadPath = ConfigurationManager.AppSettings["FileUploadPath"].ToString();
                        }

                        fileUploadPath = context.Server.MapPath("~/" + fileUploadPath + "/");

                        string sPath = fileUploadPath + newFileName;
                        file.SaveAs(sPath);
                        obj.ResultMessage = newFileName;
                        //if (fileType.ToLower() == "profileimage") { user.SaveUserProfileImage(sessionKey, newFileName); }
                        //else if (fileType.ToLower() == "problemimage") { obj.ResultObjectJSON = probEngine.SaveMedia(sessionKey, problemId, sPath, "image"); }
                        //else if (fileType.ToLower() == "problemvideo") { obj.ResultObjectJSON = probEngine.SaveMedia(sessionKey, problemId, sPath, "video"); }
                        //else if (fileType.ToLower() == "resolutionimage") { obj.ResultObjectJSON = bidEngine.SaveMedia(sessionKey, resolutionId, sPath, "image"); }
                        //else if (fileType.ToLower() == "resolutionvideo") { obj.ResultObjectJSON = bidEngine.SaveMedia(sessionKey, resolutionId, sPath, "video"); }
                    }
                    //Stream objStream = context.Request.InputStream;
                    //StreamReader objStreamReader = new StreamReader(objStream);
                    //// instance a filestream pointing to the
                    //// storage folder, use the original file name
                    //// to name the resulting file
                    //FileStream fs = new FileStream(sPath, FileMode.Create);

                    //// write the memory stream containing the original
                    //// file as a byte array to the filestream
                    //ms.WriteTo(fs);
                    //// clean up
                    //ms.Close();
                    //fs.Close();
                    //fs.Dispose();
                }
            }
            catch (Exception ex)
            {
                obj.ResultCode = "ERROR";
                obj.ResultMessage = ex.Message.ToString();
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "UploadFiles", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            retValue = Serializer.ObjectToJSON(obj);
            return retValue;
        }
        /// <summary>
        /// This method gets the complete list of all companies
        /// in the system.
        /// </summary>
        /// <returns>ResponseObjectForAnything</returns>
        public ResponseObjectForAnything GetCompanyList(string sessionKey)
        {
            List<Company> companylist = new List<Company>();
            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_GetCompanies");

                    using (IDataReader dr = db.ExecuteReader(dbCommand))
                    {
                        while (dr.Read())
                        {
                            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(); }
                            if (dr["Address1"] != DBNull.Value) { company.Address1 = dr["Address1"].ToString(); }
                            if (dr["Address2"] != DBNull.Value) { company.Address2 = dr["Address2"].ToString(); }
                            if (dr["Address3"] != DBNull.Value) { company.Address3 = dr["Address3"].ToString(); }
                            if (dr["City"] != DBNull.Value) { company.City = dr["City"].ToString(); }
                            if (dr["StateID"] != DBNull.Value) { company.StateID = Convert.ToInt32(dr["StateID"]); }
                            if (dr["StateName"] != DBNull.Value) { company.StateName = dr["StateName"].ToString(); }
                            if (dr["CountryID"] != DBNull.Value) { company.CountryID = Convert.ToInt32(dr["CountryID"]); }
                            if (dr["CountryName"] != DBNull.Value) { company.CountryName = dr["CountryName"].ToString(); }
                            if (dr["Phone"] != DBNull.Value) { company.Phone = dr["Phone"].ToString(); }
                            if (dr["EmailID"] != DBNull.Value) { company.EmailID = dr["EmailID"].ToString(); }
                            if (dr["LogoPath"] != DBNull.Value) { company.EmailID = dr["LogoPath"].ToString(); }
                            if (dr["WeekdaysStartTime"] != DBNull.Value) { company.WeekdaysStartTime = dr["WeekdaysStartTime"].ToString(); }
                            if (dr["WeekdaysEndTime"] != DBNull.Value) { company.WeekdaysEndTime = dr["WeekdaysEndTime"].ToString(); }
                            if (dr["WeekendsStartTime"] != DBNull.Value) { company.WeekendsStartTime = dr["WeekendsStartTime"].ToString(); }
                            if (dr["WeekendsEndTime"] != DBNull.Value) { company.WeekendsEndTime = dr["WeekendsEndTime"].ToString(); }
                            companylist.Add(company);
                            count++;
                        }
                    }
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(companylist);
                    responseObject.ResultObjectRecordCount = count;
                    if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No companies configured."; }
                }
            }
            catch (Exception ex)
            {
                responseObject.ResultCode = "ERROR";
                responseObject.ResultMessage = ex.Message;
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetCompanies", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            return (responseObject);
        }
Beispiel #21
0
        public ResponseObjectForAnything GetPaymentHistory(string sessionkey)
        {
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            PaymentObject paymentobj = new PaymentObject();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            List<Payment> lstpaymentreceived = new List<Payment>();
            List<Payment> lstpaymentmade = new List<Payment>();
            bool isValid = true;
            if (!string.IsNullOrEmpty(sessionkey)) { isValid = authEngine.IsValidSession(sessionkey); }
            if(isValid)
            {
                try
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetPaymentsByUserID");
                    db.AddInParameter(dbCommand, "@SessionKey", DbType.String, sessionkey);

                    DataSet dsPayment = db.ExecuteDataSet(dbCommand);

                    if (dsPayment.Tables.Count > 0)
                    {
                        DataTable tPayment = dsPayment.Tables[0];

                        foreach (DataRow dRow in tPayment.Rows)
                        {
                            Payment payment = new Payment();
                            if (dRow["ID"] != DBNull.Value) { payment.ID = Int32.Parse(dRow["ID"].ToString()); }
                            if (dRow["ProblemID"] != DBNull.Value) { payment.ProblemID = Int32.Parse(dRow["ProblemID"].ToString()); }
                            if (dRow["ProblemHeading"] != DBNull.Value) { payment.ProblemHeading = dRow["ProblemHeading"].ToString(); }
                            if (dRow["ProfilePicPath"] != DBNull.Value) { payment.ProfilePicPath = dRow["ProfilePicPath"].ToString(); }
                            if (dRow["DisplayName"] != DBNull.Value) { payment.DisplayName = dRow["DisplayName"].ToString(); }
                            if (dRow["Amount"] != DBNull.Value) { payment.Amount = Convert.ToDecimal(dRow["Amount"].ToString()); }
                            if (dRow["PaymentDate"] != DBNull.Value) { payment.PaymentDate = Convert.ToDateTime(dRow["PaymentDate"].ToString()); }
                            if (dRow["PaymentStatus"] != DBNull.Value) { payment.PaymentStatus = dRow["PaymentStatus"].ToString(); }
                            if (dRow["PaymentCount"] != DBNull.Value) { payment.PaymentCount = Int32.Parse(dRow["PaymentCount"].ToString()); }
                            if (dRow["TotalPayment"] != DBNull.Value) { payment.TotalPayment = Convert.ToDecimal(dRow["TotalPayment"].ToString()); }
                            lstpaymentmade.Add(payment);
                        }
                        paymentobj.PaymentMade = lstpaymentmade;
                    }
                    if (dsPayment.Tables.Count > 1)
                    {
                        DataTable tPayment = dsPayment.Tables[1];

                        foreach (DataRow dRow in tPayment.Rows)
                        {
                            Payment payment = new Payment();
                            if (dRow["ID"] != DBNull.Value) { payment.ID = Int32.Parse(dRow["ID"].ToString()); }
                            if (dRow["ProblemID"] != DBNull.Value) { payment.ProblemID = Int32.Parse(dRow["ProblemID"].ToString()); }
                            if (dRow["ProblemHeading"] != DBNull.Value) { payment.ProblemHeading = dRow["ProblemHeading"].ToString(); }
                            if (dRow["ProfilePicPath"] != DBNull.Value) { payment.ProfilePicPath = dRow["ProfilePicPath"].ToString(); }
                            if (dRow["DisplayName"] != DBNull.Value) { payment.DisplayName = dRow["DisplayName"].ToString(); }
                            if (dRow["Amount"] != DBNull.Value) { payment.Amount = Convert.ToDecimal(dRow["Amount"].ToString()); }
                            if (dRow["PaymentDate"] != DBNull.Value) { payment.PaymentDate = Convert.ToDateTime(dRow["PaymentDate"].ToString()); }
                            if (dRow["PaymentStatus"] != DBNull.Value) { payment.PaymentStatus = dRow["PaymentStatus"].ToString(); }
                            if (dRow["PaymentCount"] != DBNull.Value) { payment.PaymentCount = Int32.Parse(dRow["PaymentCount"].ToString()); }
                            if (dRow["TotalPayment"] != DBNull.Value) { payment.TotalPayment = Convert.ToDecimal(dRow["TotalPayment"].ToString()); }
                            lstpaymentreceived.Add(payment);
                        }
                        paymentobj.PaymentReceived = lstpaymentreceived;
                    }
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(paymentobj);
                    if (responseObject.ResultObjectRecordCount <= 0) { responseObject.ResultMessage = "No payment details found."; }
                }
                catch (Exception ex)
                {
                    responseObject.ResultCode = "ERROR";
                    responseObject.ResultMessage = ex.Message;
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetPaymentHistory", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            return (responseObject);
        }
Beispiel #22
0
        /// <summary>
        /// This method gets all user details by QB ID.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="qbUserName">string</param>
        /// <returns>SessionResponseObject</returns>
        public SessionResponseObject GetUserDetailsByQBID(string sessionKey, string qbUserName)
        {
            SessionResponseObject responseObject = new SessionResponseObject();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            User user = new User();

            DataSet dsProfile = new DataSet();

            bool isValid = authEngine.IsValidSession(sessionKey);

            if(isValid)
            {
                try
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetProfilebyQBID");
                    db.AddInParameter(dbCommand, "QBUserName", DbType.String, qbUserName);
                    dsProfile = db.ExecuteDataSet(dbCommand);

                    if(dsProfile.Tables.Count > 0)
                    {
                        DataTable tUser = dsProfile.Tables[0];
                        foreach(DataRow tRow in tUser.Rows)
                        {
                            if (tRow["UserID"] != DBNull.Value) { user.UserID = Int32.Parse(tRow["UserID"].ToString()); }
                            if (tRow["FirstName"] != DBNull.Value) { user.FirstName = tRow["FirstName"].ToString(); }
                            if (tRow["LastName"] != DBNull.Value) { user.LastName = tRow["LastName"].ToString(); }
                            if (tRow["DisplayName"] != DBNull.Value) { user.DisplayName = tRow["DisplayName"].ToString(); }
                            if (tRow["EmailID"] != DBNull.Value) { user.EmailID = tRow["EmailID"].ToString(); }
                            if (tRow["PinCode"] != DBNull.Value) { user.EmailID = tRow["PinCode"].ToString(); }
                            if (tRow["Address1"] != DBNull.Value) { user.Address1 = tRow["Address1"].ToString(); }
                            if (tRow["Address2"] != DBNull.Value) { user.Address2 = tRow["Address2"].ToString(); }
                            if (tRow["Address3"] != DBNull.Value) { user.Address3 = tRow["Address3"].ToString(); }
                            if (tRow["City"] != DBNull.Value) { user.City = tRow["City"].ToString(); }
                            if (tRow["CountryCode"] != DBNull.Value) { user.CountryCode = tRow["CountryCode"].ToString(); }
                            if (tRow["PhoneNumber"] != DBNull.Value) { user.PhoneNumber = tRow["PhoneNumber"].ToString(); }
                            if (tRow["ProfilePicPath"] != DBNull.Value) { user.ProfilePicPath = tRow["ProfilePicPath"].ToString(); }
                        }
                        responseObject.ResultCode = "SUCCESS";
                        responseObject.ResultObjectRecordCount = tUser.Rows.Count;
                        if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No quickblox user information found for this user."; }
                    }
                }
                catch (Exception ex)
                {
                    responseObject.ResultCode = "ERROR";
                    responseObject.ResultMessage = ex.Message;
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "CreateUser", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            return (responseObject);
        }
        /// <summary>
        /// This method calls master list stored proc with a
        /// master list ID = 3 (as used in stored proc) to get 
        /// list of countries from system. It also selects 
        /// the defaulted country.
        /// </summary>
        /// <returns>List<Country></returns>
        public ResponseObjectForAnything GetCountryList()
        {
            List<Country> countrylist = new List<Country>();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            int count = 0;
            try
            {
                Database db = DatabaseFactory.CreateDatabase();
                DbCommand dbCommand = db.GetStoredProcCommand("usp_GetCountries");

                using (IDataReader dr = db.ExecuteReader(dbCommand))
                {
                    while (dr.Read())
                    {
                        Country country = new Country();
                        if (dr["ID"] != DBNull.Value) { country.CountryID = Convert.ToInt32(dr["ID"]); }
                        if (dr["Name"] != DBNull.Value) { country.CountryName = dr["Name"].ToString(); }
                        if (dr["IsDefaulted"] != DBNull.Value) { country.IsDefaulted = Convert.ToBoolean(dr["IsDefaulted"].ToString()); }
                        countrylist.Add(country);
                        count++;
                    }
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(countrylist);
                    responseObject.ResultObjectRecordCount = count;
                    if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No countries found."; }
                }
            }
            catch (Exception ex)
            {
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetCountries", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            return (responseObject);
        }
Beispiel #24
0
        /// <summary>
        /// This method saves the profile image for logged in user.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="imageFileName">string</param>
        /// <returns>string</returns>
        public string SaveUserProfileImage(string sessionKey, string imageFileName)
        {
            string retValue = "";
            ResponseObjectForAnything obj = new ResponseObjectForAnything();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            Int32 pId = -1;
            bool isValid = authEngine.IsValidSession(sessionKey);
            if (isValid)
            {
                try
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_UpdateProfileImage");

                    db.AddInParameter(dbCommand, "@Sessionkey", DbType.String, sessionKey);
                    db.AddInParameter(dbCommand, "@ProfileImage", DbType.String, imageFileName);

                    db.ExecuteNonQuery(dbCommand);

                    obj.ResultCode = "SUCCESS";
                }
                catch (Exception ex)
                {
                    obj.ResultCode = "ERROR";
                    obj.ResultMessage = ex.Message.ToString();
                    CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SavePersonProfileImage", System.DateTime.Now);
                    ExceptionManager.PublishException(exc);
                }
            }
            //Serialize the object into a response...
            retValue = Serializer.ObjectToJSON(obj);

            return retValue;
        }
        /// <summary>
        /// This method gets the currencies supported
        /// in the system.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <returns>ResponseObjectForAnything</returns>
        public ResponseObjectForAnything GetCurrencies(string sessionKey)
        {
            List<Currency> currencylist = new List<Currency>();
            AuthenticationEngine authEngine = new AuthenticationEngine();
            ResponseObjectForAnything responseObject = new ResponseObjectForAnything();
            bool isValid = authEngine.IsValidSession(sessionKey);
            int count = 0;

            try
            {
                if (isValid)
                {
                    Database db = DatabaseFactory.CreateDatabase();
                    DbCommand dbCommand = db.GetStoredProcCommand("usp_GetCurrencies");

                    using (IDataReader dr = db.ExecuteReader(dbCommand))
                    {
                        while (dr.Read())
                        {
                            Currency currency = new Currency();
                            if (dr["CurrencyID"] != DBNull.Value) { currency.CurrencyID = Convert.ToInt32(dr["CurrencyID"]); }
                            if (dr["CurrencyName"] != DBNull.Value) { currency.CurrencyName = dr["CurrencyName"].ToString(); }
                            if (dr["CurrencyDisplayText"] != DBNull.Value) { currency.CurrencyDisplayText = dr["CurrencyDisplayText"].ToString(); }
                            if (dr["IsDefaulted"] != DBNull.Value) { currency.IsDefaulted = Convert.ToBoolean(dr["IsDefaulted"].ToString()); }
                            currencylist.Add(currency);
                            count++;
                        }
                    }
                    responseObject.ResultCode = "SUCCESS";
                    responseObject.ResultObjectJSON = Serializer.ObjectToJSON(currencylist);
                    responseObject.ResultObjectRecordCount = count;
                    if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No currencies configured."; }
                }
            }
            catch (Exception ex)
            {
                responseObject.ResultCode = "ERROR";
                responseObject.ResultMessage = ex.Message;
                CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetProducts", System.DateTime.Now);
                ExceptionManager.PublishException(exc);
            }
            return (responseObject);
        }
Beispiel #26
0
        /// <summary>
        /// Update contact info for a user ID.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="address1">string</param>
        /// <param name="address2">string</param>
        /// <param name="address3">string</param>
        /// <param name="state">string</param>
        /// <param name="city">string</param>
        /// <param name="pincode">string</param>
        /// <returns>SessionResponseObject</returns>
        public ResponseObjectForAnything UpdateCardDetailsByUserId(string sessionKey, string cardtype, string cardnumber)
        {
            AuthenticationEngine authEngine = new AuthenticationEngine();
            User user = new User();
            bool isValid = authEngine.IsValidSession(sessionKey);
            ResponseObjectForAnything obj = new ResponseObjectForAnything();
            if (isValid)
            {
                if (!string.IsNullOrEmpty(sessionKey))
                {
                    obj = authEngine.GetUserFromSession(sessionKey);
                    user = (User)Serializer.JSONStringToObject<User>(obj.ResultObjectJSON);
                }

                if (user != null)
                {
                    try
                    {
                        Database db = DatabaseFactory.CreateDatabase();
                        DbCommand dbCommand = db.GetStoredProcCommand("usp_UpdateCardsByUserID");

                        db.AddInParameter(dbCommand, "UserID", DbType.Int32, user.UserID);
                        db.AddInParameter(dbCommand, "CardType", DbType.Xml, cardtype);
                        db.AddInParameter(dbCommand, "CardNumber", DbType.Xml, cardnumber);

                        dbCommand.ExecuteNonQuery();

                        obj.ResultCode = "SUCCESS";
                        obj.ResultMessage = "Card details information updated successfully.";
                    }
                    catch (Exception ex)
                    {
                        obj.ResultCode = "ERROR";
                        obj.ResultMessage = ex.Message;
                        CustomException exc = new CustomException(ex.ToString(), this.ToString(), "UpdateContactInfoByUserId", System.DateTime.Now);
                        ExceptionManager.PublishException(exc);
                    }
                }
            }
            return (obj);
        }
        /// <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);
        }
Beispiel #28
0
        /// <summary>
        /// Update personal profile from app screens.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="firstName">string</param>
        /// <param name="lastName">string</param>
        /// <param name="displayName">string</param>
        /// <param name="isUser">string</param>
        /// <param name="isExpert">string</param>
        /// <param name="catsubcat">string</param>
        /// <param name="description">string</param>
        /// <param name="countrycode">string</param>
        /// <param name="mobileNumber">string</param>
        /// <returns>SessionResponseObject</returns>
        public SessionResponseObject UpdatePersonalInfoByUserId(string sessionKey, string firstName, string lastName, string displayName, string isUser, string isExpert, string catsubcat,
                                                string description, string mobileNumber)
        {
            AuthenticationEngine authEngine = new AuthenticationEngine();
            User user = new User();
            bool isValid = authEngine.IsValidSession(sessionKey);
            SessionResponseObject responseObject = new SessionResponseObject();
            ResponseObjectForAnything obj = new ResponseObjectForAnything();
            if (isValid)
            {
                if (!string.IsNullOrEmpty(sessionKey))
                {
                    obj = authEngine.GetUserFromSession(sessionKey);
                    user = (User)Serializer.JSONStringToObject<User>(obj.ResultObjectJSON);
                }

                if(user != null)
                {
                    try
                    {
                        Database db = DatabaseFactory.CreateDatabase();
                        DbCommand dbCommand = db.GetStoredProcCommand("usp_UpdateProfileByUserID");

                        db.AddInParameter(dbCommand, "UserID", DbType.Int32, user.UserID);
                        db.AddInParameter(dbCommand, "FirstName", DbType.String, firstName);
                        db.AddInParameter(dbCommand, "LastName", DbType.String, lastName);
                        db.AddInParameter(dbCommand, "DisplayName", DbType.String, displayName);
                        db.AddInParameter(dbCommand, "IsUser", DbType.Boolean, Convert.ToBoolean(isUser));
                        db.AddInParameter(dbCommand, "IsExpert", DbType.Boolean, Convert.ToBoolean(isExpert));

                        string[] lstcatsubcat = catsubcat.Split(";".ToCharArray());
                        DataSet dataSet = new DataSet();
                        DataTable dataTable = dataSet.Tables.Add();
                        dataTable.Columns.Add("CategoryID");
                        dataTable.Columns.Add("SubCategoryID");
                        for (int count = 0; count < lstcatsubcat.Length - 1; count++)
                        {
                            string category = lstcatsubcat[count].Split(",".ToCharArray())[0];
                            string subcategory = lstcatsubcat[count].Split(",".ToCharArray())[1];
                            dataTable.Rows.Add(new object[] { category, subcategory });
                        }
                        db.AddInParameter(dbCommand, "CatSubCat", DbType.String, dataSet.GetXml());
                        db.AddInParameter(dbCommand, "BriefDescription", DbType.String, description);
                        db.AddInParameter(dbCommand, "MobileNumber", DbType.String, mobileNumber);

                        dbCommand.ExecuteNonQuery();

                        responseObject.ResultCode = "SUCCESS";
                        responseObject.ResultMessage = "Profile information updated successfully.";
                    }
                    catch(Exception ex)
                    {
                        responseObject.ResultCode = "ERROR";
                        responseObject.ResultMessage = ex.Message;
                        CustomException exc = new CustomException(ex.ToString(), this.ToString(), "UpdatePersonalInfoByUserId", System.DateTime.Now);
                        ExceptionManager.PublishException(exc);
                    }
                }
            }
            return (responseObject);
        }
Beispiel #29
0
        /// <summary>
        /// This method creates/updates a problem into the system.
        /// </summary>
        /// <param name="sessionKey">string</param>
        /// <param name="problemId">string</param>
        /// <param name="companyRelated">string</param>
        /// <param name="companyId">string</param>
        /// <param name="problemHeading">string</param>
        /// <param name="hastags">string</param>
        /// <param name="categoryId">string</param>
        /// <param name="subcategoryId">string</param>
        /// <param name="productId">string</param>
        /// <param name="modelNo">string</param>
        /// <param name="description">string</param>
        /// <param name="purchaseMonth">string</param>
        /// <param name="purchaseYear">string</param>
        /// <param name="productStatus">string</param>
        /// <param name="resolutionneededby">string</param>
        /// <param name="thumbnailmedia">string</param>
        /// <param name="hashtags">string</param>
        /// <param name="imagesupload">string</param>
        /// <param name="videosupload">string</param>
        /// <param name="isVirtual">string</param>
        /// <param name="isRegisteredAddress">string</param>
        /// <param name="address1">string</param>
        /// <param name="address2">string</param>
        /// <param name="address3">string</param>
        /// <param name="city">string</param>
        /// <param name="stateId">string</param>
        /// <param name="countryId">string</param>
        /// <param name="pinCode">string</param>
        /// <param name="isEdit">string</param>
        /// <returns>string</returns>
        public string SaveProblem(string sessionKey, string problemId, string companyRelated, string companyId, string problemHeading, string categoryId, string subcategoryId, string productId, string modelNo,
                                  string description, string purchaseMonth, string purchaseYear, string productStatus, string resolutionneededby, string hashtags, string isVirtual,
                                  string isRegisteredAddress, string address1, string address2, string address3, string city, string stateId, string countryId, string pinCode)
        {
            string retVal = string.Empty;
            Int32 probId = -1;
            AuthenticationEngine authEngine = new AuthenticationEngine();
            MyProfileObject user = new MyProfileObject();
            bool isValid = authEngine.IsValidSession(sessionKey);

            ResponseObjectForAnything responseobject = new ResponseObjectForAnything();

            if(isValid)
            {
                responseobject = authEngine.GetUserFromSession(sessionKey);
                user = (MyProfileObject)Serializer.JSONStringToObject<MyProfileObject>(responseobject.ResultObjectJSON);

                if (user != null)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(problemId)) { probId = Int32.Parse(problemId); }

                        Database db = DatabaseFactory.CreateDatabase();
                        DbCommand dbCommand = db.GetStoredProcCommand("usp_UpsertProblem");
                        if (!string.IsNullOrEmpty(problemId)) { db.AddInParameter(dbCommand, "ProblemId", DbType.Int32, Int32.Parse(problemId)); }
                        else { db.AddInParameter(dbCommand, "ProblemId", DbType.Int32, null); }

                        db.AddInParameter(dbCommand, "UserId", DbType.Int32, user.UserObject.UserID);
                        db.AddInParameter(dbCommand, "CompanyRelated", DbType.Boolean, Convert.ToBoolean(companyRelated));
                        if (!string.IsNullOrEmpty(companyId)) { db.AddInParameter(dbCommand, "CompanyID", DbType.Int32, Int32.Parse(companyId)); }
                        db.AddInParameter(dbCommand, "ProblemHeading", DbType.String, problemHeading);
                        db.AddInParameter(dbCommand, "CategoryID", DbType.Int32, Int32.Parse(categoryId));
                        db.AddInParameter(dbCommand, "SubCategoryID", DbType.Int32, Int32.Parse(subcategoryId));
                        if (!string.IsNullOrEmpty(productId)) { db.AddInParameter(dbCommand, "ProductID", DbType.Int32, Int32.Parse(productId)); }
                        db.AddInParameter(dbCommand, "ModelNo", DbType.String, modelNo);
                        db.AddInParameter(dbCommand, "Description", DbType.String, description);
                        db.AddInParameter(dbCommand, "PurchaseMonth", DbType.String, purchaseMonth);
                        db.AddInParameter(dbCommand, "PurchaseYear", DbType.String, purchaseYear);
                        db.AddInParameter(dbCommand, "ProductStatusID", DbType.String, Int32.Parse(productStatus));
                        if (!string.IsNullOrEmpty(resolutionneededby)) { db.AddInParameter(dbCommand, "ResolutionNeededBy", DbType.DateTime, Convert.ToDateTime(resolutionneededby)); }
                        else { db.AddInParameter(dbCommand, "ResolutionNeededBy", DbType.DateTime, null); }
                        string[] problemhashtags = hashtags.Split(",".ToCharArray());
                        DataSet dsHashTags = ToDataSet(problemhashtags, "Name");
                        db.AddInParameter(dbCommand, "ProblemHashTags", DbType.Xml, dsHashTags.GetXml());

                        db.AddInParameter(dbCommand, "IsVirtual", DbType.Boolean, Convert.ToBoolean(isVirtual));
                        db.AddInParameter(dbCommand, "IsRegisteredAddress", DbType.Boolean, Convert.ToBoolean(isRegisteredAddress));
                        db.AddInParameter(dbCommand, "Address1", DbType.String, address1);
                        db.AddInParameter(dbCommand, "Address2", DbType.String, address2);
                        db.AddInParameter(dbCommand, "Address3", DbType.String, address3);
                        db.AddInParameter(dbCommand, "City", DbType.String, city);
                        if (!string.IsNullOrEmpty(stateId)) { db.AddInParameter(dbCommand, "StateID", DbType.Int32, Convert.ToInt32(stateId)); }
                        else { db.AddInParameter(dbCommand, "StateID", DbType.Int32, null); }
                        if (!string.IsNullOrEmpty(countryId)) { db.AddInParameter(dbCommand, "CountryID", DbType.Int32, countryId); }
                        { db.AddInParameter(dbCommand, "CountryID", DbType.Int32, null); }
                        db.AddInParameter(dbCommand, "PinCode", DbType.String, pinCode);
                        float latitude, longitude;
                        GeoHelper geoHelper = new GeoHelper();
                        geoHelper.GetGeoLocationByPinCode(pinCode, out latitude, out longitude);
                        db.AddInParameter(dbCommand, "Latitude", DbType.Decimal, latitude);
                        db.AddInParameter(dbCommand, "Longitude", DbType.Decimal, longitude);

                        if (string.IsNullOrEmpty(problemId))
                        {
                            probId = Int32.Parse(db.ExecuteScalar(dbCommand).ToString());
                            if(probId > 0)
                                responseobject.ResultCode = "SUCCESS";
                            else
                                responseobject.ResultCode = "ERROR";
                            responseobject.ResultMessage = "Problem created successfully.";
                            responseobject.ResultObjectID = probId;
                        }
                        else
                        {
                            db.ExecuteNonQuery(dbCommand);
                            responseobject.ResultCode = "SUCCESS";
                            responseobject.ResultMessage = "Problem saved successfully.";
                        }
                    }
                    catch (Exception ex)
                    {
                        responseobject.ResultCode = "ERROR";
                        responseobject.ResultMessage = ex.Message;
                        CustomException exc = new CustomException(ex.ToString(), this.ToString(), "SaveProblem", System.DateTime.Now);
                        ExceptionManager.PublishException(exc);
                    }
                }
            }
            retVal = Serializer.ObjectToJSON(responseobject);
            return retVal;
        }