Exemplo n.º 1
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;
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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;
        }