protected void btnSubmit_Click(object sender, EventArgs e) { if (cmbService.SelectedValue == "CreateUser") { UserEngine user = new UserEngine(); txtResult.Text = user.CreateUserJSON(txtFirstName.Text, txtLastName.Text, txtDisplayName.Text, txtEmail.Text, txtArea.Text, txtCity.Text, txtPinCode.Text, Convert.ToString(chkUser.Checked), Convert.ToString(chkExpert.Checked), txtCatSubCat.Text, txtPassword.Text, txtDevice.Text); } if (cmbService.SelectedValue == "GetCountries") { string url = baseURL + "?fc=getcountries"; using (WebClient client = new WebClient()) { //client.QueryString.Add("ID", "1040"); //add parameters //client.Credentials = CredentialCache.DefaultCredentials; //I tried to add credentials like this //client.Credentials = new NetworkCredential("*****@*****.**", "Sparky@123#"); txtResult.Text = client.DownloadString(url); } //MasterlistEngine master = new MasterlistEngine(); } if (cmbService.SelectedValue == "GetStates") { string url = baseURL + "?fc=getstates&countryid=3"; using (WebClient client = new WebClient()) { //client.QueryString.Add("ID", "1040"); //add parameters //client.Credentials = CredentialCache.DefaultCredentials; //I tried to add credentials like this //client.Credentials = new NetworkCredential("*****@*****.**", "Sparky@123#"); txtResult.Text = client.DownloadString(url); } //MasterlistEngine master = new MasterlistEngine(); } if (cmbService.SelectedValue == "GetCompanies") { string url = baseURL + "?fc=getcompanies"; using (WebClient client = new WebClient()) { //client.QueryString.Add("ID", "1040"); //add parameters //client.Credentials = CredentialCache.DefaultCredentials; //I tried to add credentials like this //client.Credentials = new NetworkCredential("*****@*****.**", "Sparky@123#"); txtResult.Text = client.DownloadString(url); } //MasterlistEngine master = new MasterlistEngine(); } if (cmbService.SelectedValue == "GetProblems") { string url = baseURL + "?fc=getproblems&sessionkey="+txtSessionKey.Text+"&startindex="+txtStartIndex.Text+"&pagesize="+txtPageSize.Text+"&latitude="+txtLatitude.Text+ "&longitude=" + txtLongitude.Text + "&distance=" + txtDistance.Text + "&categoryid=" + txtCategory.Text + "&subcategoryid=" + txtSubCategory.Text + "&modelno=" +txtModel.Text+"&heading="+txtHeading.Text+"&startdate="+txtStartDate.Text +"&enddate="+txtEndDate.Text; using (WebClient client = new WebClient()) { //client.QueryString.Add("ID", "1040"); //add parameters //client.Credentials = CredentialCache.DefaultCredentials; //I tried to add credentials like this //client.Credentials = new NetworkCredential("*****@*****.**", "Sparky@123#"); txtResult.Text = client.DownloadString(url); } //MasterlistEngine master = new MasterlistEngine(); } if (cmbService.SelectedValue == "GetCategories") { string url = baseURL + "?fc=getcategories"; using (WebClient client = new WebClient()) { txtResult.Text = client.DownloadString(url); } } if (cmbService.SelectedValue == "GetProblemStatus") { string url = baseURL + "?fc=getproblemstatus&sessionkey="+txtSessionKey.Text; using (WebClient client = new WebClient()) { txtResult.Text = client.DownloadString(url); } } if (cmbService.SelectedValue == "GetProductStatus") { string url = baseURL + "?fc=getproductstatus&sessionkey=" + txtSessionKey.Text; using (WebClient client = new WebClient()) { txtResult.Text = client.DownloadString(url); } } if (cmbService.SelectedValue == "GetResolutionMethods") { string url = baseURL + "?fc=getresolutionmethod&sessionkey=" + txtSessionKey.Text; using (WebClient client = new WebClient()) { txtResult.Text = client.DownloadString(url); } } if (cmbService.SelectedValue == "GetCurrencies") { string url = baseURL + "?fc=getcurrencies&sessionkey=" + txtSessionKey.Text; using (WebClient client = new WebClient()) { txtResult.Text = client.DownloadString(url); } } if (cmbService.SelectedValue == "GetSubCategories") { string url = baseURL + "?fc=getsubcategories&categoryid="+txtCategory.Text; using (WebClient client = new WebClient()) { txtResult.Text = client.DownloadString(url); } } if (cmbService.SelectedValue == "GetProducts") { string url = baseURL + "?fc=getproducts&sessionkey="+txtSessionKey.Text +"&categoryid=" + txtCategory.Text+"&subcategoryid="+txtSubCategory.Text; using (WebClient client = new WebClient()) { txtResult.Text = client.DownloadString(url); } } if (cmbService.SelectedValue == "CreateSession") { string url = baseURL + "?fc=createsession&emailid="+txtEmail.Text+"&password="******"&devicetoken="+txtDevice.Text; using (WebClient client = new WebClient()) { txtResult.Text = client.DownloadString(url); } } if(cmbService.SelectedValue =="Logout") { string url = baseURL + "?fc=logout&sessionkey=" + txtSessionKey.Text + "&devicetoken=" + txtDevice.Text; using (WebClient client = new WebClient()) { txtResult.Text = client.DownloadString(url); } } if (cmbService.SelectedValue == "GetUserFromSession") { string url = baseURL + "?fc=getuserfromsession&sessionkey=" + txtSessionKey.Text; using (WebClient client = new WebClient()) { txtResult.Text = client.DownloadString(url); } } if (cmbService.SelectedValue == "PostProblem") { ProblemEngine probEngine = new ProblemEngine(); txtResult.Text = probEngine.SaveProblem(txtSessionKey.Text, txtProblemId.Text, "true", txtCompanyId.Text, txtHeading.Text, txtCategory.Text, txtSubCategory.Text, txtProduct.Text, txtModel.Text, txtDescription.Text, txtPurchaseMonth.Text, txtPurchaseYear.Text, txtProductStatus.Text, txtResolutionNeeded.Text, txtHashTags.Text, "false", "true", "","","","","","",""); //string url = baseURL + "?fc=saveproblem&sessionkey=" + txtSessionKey.Text + "&problemid="+txtProblemId.Text+"&companyrelated=true&companyid="+txtCompanyId.Text+"&heading="+txtHeading.Text+ // "&categoryid="+txtCategory.Text+"&subcategoryid="+txtSubCategory.Text+"&productid="+txtProduct.Text+"&modelno="+txtModel.Text+"&description="+txtDescription.Text+ // "&purchasemonth="+txtPurchaseMonth.Text+"&purchaseyear="+txtPurchaseYear.Text+"&productstatus="+txtProductStatus.Text+"&resolutionneededby="+txtResolutionNeeded.Text+ // "&hashtags=" + txtHashTags.Text + "&isvirtual=false&isregisteredaddr=true&address1=&address2=&address3=&city=&countryid=&stateid=&pincode="; //string url = "probfox.azurewebsites.net/webservices/probfox.ashx?fc=saveproblem&sessionkey=A1C95E9E-1FE1-4315-B5DB-CE5983A9DF09&problemid=null&companyrelated=true&companyid=1&problemheading=test&categoryid=1&subcategoryid=1&productid=1&modelno=abc123&description=test%20desc&purchasemonth=01&purchaseyear=2015&productstatus=1&resolutionneededby=null&hashtags=test,test1;&isvirtual=false&isregisteredaddress=true&address1=&address2&address3=&city=&stateid=&countryid=&pincode="; //using (WebClient client = new WebClient()) //{ // txtResult.Text = client.DownloadString(url); //} } if (cmbService.SelectedValue == "UploadFiles") { string fileName = FileUpload1.FileName; string url = fileUploadBaseURL + "?fc=uploadfile&sessionkey=" + txtSessionKey.Text + "&filename=" + fileName + "&filetype=" + txtFileType.Text; WebClient client = new WebClient(); txtResult.Text = client.DownloadString(url); } if (cmbService.SelectedValue == "EditBid") { BidEngine bid = new BidEngine(); //txtResult.Text = bid.SaveBids(txtSessionKey.Text, txtProblemId.Text, null, txtDescription.Text, "1", txtLink1.Text, txtTitle1.Text, txtLink2.Text, txtTitle2.Text, "1", "500", null, "20/09/2015,10:00,11:00;21/09/2015,17:00,19:00", "false"); } }
public ActionResult GetSuggestedExpert(string pPinCode, double pRadius, int pCategoryId, int pSubCategoryId, int pPageIndex = 1) { List<User> lstUser = new List<Common.DTO.User>(); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); UserEngine userEngine = new UserEngine(); string response = userEngine.GetExpertsByCatSubCatJSON(Request.Cookies["sessionkey"].Value, pPinCode, pRadius.ToString(), pCategoryId.ToString(), pSubCategoryId.ToString()); responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response); lstUser = (List<User>)Serializer.JSONStringToObject<List<User>>(responseObject.ResultObjectJSON); int totalRecords = responseObject.ResultObjectRecordCount; int totalPagesCount = 0; totalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)_PageSize); ViewBag.TotalPagesCount = totalPagesCount; ViewBag.TotalRecords = totalRecords; ViewBag.PageNumber = pPageIndex; return PartialView("_ExpertSuggestionList", lstUser); //List<UserViewModel> modelList = new List<UserViewModel>(); //UserViewModel model = new UserViewModel(); //model.UserID = 1; //model.FirstName = "Charles"; //model.LastName = "Brown"; //model.EmailID = "*****@*****.**"; //model.ProfilePicPath = ServerSettings.WebApplicationURL + "/upload/profilepic/profile.jpg"; //model.Distance = "25.45 miles"; //modelList.Add(model); //model = new UserViewModel(); //model.UserID = 2; //model.FirstName = "Brendon"; //model.LastName = "Taylor"; //model.EmailID = "*****@*****.**"; //model.ProfilePicPath = ServerSettings.WebApplicationURL + "/upload/profilepic/images.jpg"; //model.Distance = "189.75 miles"; //modelList.Add(model); //model = new UserViewModel(); //model.UserID = 3; //model.FirstName = "Nathen"; //model.LastName = "Astle"; //model.EmailID = "*****@*****.**"; //model.ProfilePicPath = ServerSettings.WebApplicationURL + "/upload/profilepic/chris_palmer_profile_11.jpg"; //model.Distance = "356.79 miles"; //modelList.Add(model); //int totalRecords = modelList.Count; //int totalPagesCount = 0; //totalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)_PageSize); //ViewBag.TotalPagesCount = totalPagesCount; //ViewBag.TotalRecords = totalRecords; //ViewBag.PageNumber = pPageIndex; //return PartialView("_ExpertSuggestionList", modelList); }
/// <summary> /// Action which is used for delete a card /// </summary> /// <param name="pCardID">id of a card that needs to be deleted</param> /// <returns></returns> public ActionResult DeleteCard(int pCardID) { UserEngine userEngine = new UserEngine(); //string response = userEngine.UpdateCardDetailsByUserIdJSON(Request.Cookies["sessionkey"].Value, pCardID.ToString()); //ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); //responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response); //if (responseObject.ResultCode == "SUCCESS") //{ // ProbFox.Common.DTO.Alert alert = new Common.DTO.Alert(); // alert.AlertType = Common.DTO.Alert.ALERTTYPE.Success; // alert.MessageType = Common.DTO.Alert.ALERTMESSAGETYPE.TextWithClose; // alert.Message = response; // ViewBag.Alert = alert; //} return View(); }
/// <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; }
public ActionResult SaveCard(UserCard model) { UserEngine userEngine = new UserEngine(); string response = userEngine.UpdateCardDetailsByUserIdJSON(Request.Cookies["sessionkey"].Value, model.CardType, model.CardNumber); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response); if (responseObject.ResultCode == "SUCCESS") { ProbFox.Common.DTO.Alert alert = new Common.DTO.Alert(); alert.AlertType = Common.DTO.Alert.ALERTTYPE.Success; alert.MessageType = Common.DTO.Alert.ALERTMESSAGETYPE.TextWithClose; alert.Message = response; ViewBag.Alert = alert; } return View(); }
/// <summary> /// Save contact detail /// </summary> /// <returns></returns> public ActionResult SaveContactDetail(FormCollection form) { MyProfileObject model = new MyProfileObject(); UserEngine userEngine = new UserEngine(); string response = userEngine.UpdateContactInfoByUserIdJSON(Request.Cookies["sessionkey"].Value, form["Address1"], form["Address2"], form["Address3"], form["City"], form["StateID"], form["CountryID"], form["PinCode"]); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response); if (responseObject.ResultCode == "SUCCESS") { ProbFox.Common.DTO.Alert alert = new Common.DTO.Alert(); alert.AlertType = Common.DTO.Alert.ALERTTYPE.Success; alert.MessageType = Common.DTO.Alert.ALERTMESSAGETYPE.TextWithClose; alert.Message = response; ViewBag.Alert = alert; } return View(); }
public ActionResult MyProfile(FormCollection form) { MyProfileObject model = new MyProfileObject(); if(form["IsUser"] == "Yes") { form["IsUser"] = "******"; form["IsExpert"] = "false"; } UserEngine userEngine = new UserEngine(); string response = userEngine.UpdatePersonalInfoByUserIdJSON(Request.Cookies["sessionkey"].Value, form["FirstName"], form["LastName"], form["DisplayName"], form["IsUser"], form["isExpert"], form["hdfCategoryJSON"], form["BriefDescription"], form["PhoneNumber"]); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response); if(responseObject.ResultCode == "SUCCESS") { ProbFox.Common.DTO.Alert alert = new Common.DTO.Alert(); alert.AlertType = Common.DTO.Alert.ALERTTYPE.Success; alert.MessageType = Common.DTO.Alert.ALERTMESSAGETYPE.TextWithClose; alert.Message = response; ViewBag.Alert = alert; return View(model); } //List<UserCard_XREF> cardModelList = new List<UserCard_XREF>(); //UserCard_XREF cardModel = new UserCard_XREF(); //cardModel.ID = 1; //cardModel.UserID = UserSession.LoginUserID; //cardModel.CardNumber = "123455"; //cardModel.CardType = "Visa"; //cardModelList.Add(cardModel); //cardModel = new UserCard_XREF(); //cardModel.ID = 2; //cardModel.UserID = UserSession.LoginUserID; //cardModel.CardNumber = "XXX458"; //cardModel.CardType = "Credit"; //cardModelList.Add(cardModel); //cardModel = new UserCard_XREF(); //cardModel.ID = 3; //cardModel.UserID = UserSession.LoginUserID; //cardModel.CardNumber = "123"; //cardModel.CardType = "Debit"; //cardModelList.Add(cardModel); //model.UserCardModelList = cardModelList; //GetInitialDropDownComplexModel(model); //model.UserViewModel.FirstName = "John"; //model.UserViewModel.LastName = "Smith"; //model.UserViewModel.DisplayName = "John Smith"; //model.UserViewModel.EmailID = "*****@*****.**"; //model.UserViewModel.ProfilePicPath = ServerSettings.WebApplicationURL + "/upload/profilepic/profile.jpg"; //model.UserViewModel.BriefDescription = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat."; //model.UserViewModel.PhoneNumber = "1234567890"; //model.UserViewModel.PinCode = "395009"; //model.UserViewModel.Address1 = "b-123/tulsikunj soc"; //model.UserViewModel.Address2 = "Bh. Viabhav Hall,Ghodasar"; //model.UserViewModel.Address3 = "Maninagar"; //model.UserViewModel.City = "Ahmedabad"; //if (UserSession.LoginUserType == USERTYPE.Expert.ToString()) //{ // SelectedCategoriesViewModel selectedCategoryModel = null; // List<SubCategory> subcategoryList = new List<SubCategory>(); // subcategoryList.Add(new SubCategory { Name = "Tv", ID = 1 }); // subcategoryList.Add(new SubCategory { Name = "Freez", ID = 2 }); // subcategoryList.Add(new SubCategory { Name = "AC", ID = 3 }); // selectedCategoryModel = new SelectedCategoriesViewModel(); // selectedCategoryModel.CategoryID = 1; // selectedCategoryModel.SubCategoryList = subcategoryList; // selectedCategoryModel.SelectedSubCategories = "1,3"; // model.SelectedCategoriesViewModelList.Add(selectedCategoryModel); // selectedCategoryModel = new SelectedCategoriesViewModel(); // selectedCategoryModel.CategoryID = 2; // selectedCategoryModel.SubCategoryList = subcategoryList; // selectedCategoryModel.SelectedSubCategories = "3"; // model.SelectedCategoriesViewModelList.Add(selectedCategoryModel); //} return View(model); }
/// <summary> /// Action for display the profile page of a current login user /// </summary> /// <returns></returns> public ActionResult MyProfile() { MyProfileObject profileobj = new MyProfileObject(); List<UserCard> usercards = new List<UserCard>(); UserEngine userEngine = new UserEngine(); AuthenticationEngine authEngine = new AuthenticationEngine(); string response = authEngine.GetUserFromSessionJSON(Request.Cookies["sessionkey"].Value); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response); profileobj = (MyProfileObject)Serializer.JSONStringToObject<MyProfileObject>(responseObject.ResultObjectJSON); GetInitialDropDownComplexModel(profileobj); return View(profileobj); }
public ActionResult SignUp(FormCollection form) { string categoryJson = form["hdfSelectedCategoryJson"]; UserEngine userEngine = new UserEngine(); MasterlistEngine masterEngine = new MasterlistEngine(); if(form["hdnIsUser"] == "" && form["hdnIsExpert"] == "") { form["hdnIsUser"] = "******"; form["hdnIsExpert"] = "false"; } string response = userEngine.CreateUserJSON(form["FirstName"], form["LastName"], form["DisplayName"], form["Email"], form["Address"], form["City"], form["PinCode"], form["hdnIsUser"], form["hdnIsExpert"], categoryJson, form["Password"], Request.ServerVariables["REMOTE_ADDR"]); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); if (!string.IsNullOrEmpty(response)) { responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response); } if(responseObject.ResultCode == "SUCCESS") { string role = CreateSession(form["Email"], form["Password"]); if(role == "Expert") return RedirectToAction("Problem", "Expert"); else return RedirectToAction("Problem", "User"); } else { ProbFox.Common.DTO.Alert alert = new Common.DTO.Alert(); alert.AlertType = Common.DTO.Alert.ALERTTYPE.Error; alert.MessageType = Common.DTO.Alert.ALERTMESSAGETYPE.TextWithClose; alert.Message = responseObject.ResultMessage; ViewBag.Alert = alert; response = masterEngine.GetCategoryListJSON(); responseObject = (ResponseObjectForAnything)Serializer.JSONStringToObject<ResponseObjectForAnything>(response); List<Common.DTO.Category> categories = new List<Common.DTO.Category>(); categories = (List<Common.DTO.Category>)Serializer.JSONStringToObject<List<Common.DTO.Category>>(responseObject.ResultObjectJSON); ViewBag.CategoryId = new SelectList(categories, "ID", "Name"); ; return View(); } }