public JsonResult GetProductList(string bsGnd = "", string brand = "", string sidx = "ProductName", string sord = "asc", int rows = 3, int page = 1) { try { var currentShopId = BSSecurityEncryption.Decrypt(bsGnd, WebAppConfig.GetConfigValue("BSGnd")); var param = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("shopId", currentShopId), new KeyValuePair <string, string>("sortColumnName", sidx), new KeyValuePair <string, string>("sortOrder", sord), new KeyValuePair <string, string>("pageSize", Convert.ToString(rows)), new KeyValuePair <string, string>("currentPage", Convert.ToString(page)), new KeyValuePair <string, string>("brand", Convert.ToString(brand)) }; var data = new CommonAjaxCallToWebAPI().AjaxGet(@"/api/product/GetProductList", param, Convert.ToString(Session["BSWebApiToken"])); // return Json(data, JsonRequestBehavior.AllowGet); var jqGridData = new JqGridType() { Data = data, Page = "1", PageSize = "3", // u can change this ! SortColumn = "1", SortOrder = "asc" }; return(Json(jqGridData, JsonRequestBehavior.AllowGet)); } catch { return(null); } }
private ShopChangeStatus ValidateAndChangeShop(int shopId) { try { var currentUserId = CommonSafeConvert.ToInt(Session["CurrentUserID"]); var changeShopRequestobject = new ShopChangeRequest(); changeShopRequestobject.ShopId = shopId; changeShopRequestobject.Userid = currentUserId; var response = new CommonAjaxCallToWebAPI().AjaxPost("/api/common/ValidateAndChangeShop", changeShopRequestobject, Convert.ToString(Session["BSWebApiToken"])).Result; if (response.IsSuccessStatusCode) { var rslt = response.Content.ReadAsStringAsync().Result; var shopChangeStatus = new JavaScriptSerializer().Deserialize <ShopChangeStatus>(rslt); return(shopChangeStatus); } else { return(null); } } catch { return(null); } }
public async Task <ActionResult> SignUp(LoginViewModel model, string returnUrl) { // Lets first check if the Model is valid or not if (ModelState.IsValidField("signUpModel")) { var response = new CommonAjaxCallToWebAPI().AjaxPost("/api/Home/SignUp", model.signUpModel, "").Result; if (response.StatusCode == System.Net.HttpStatusCode.OK) { var rslt = await response.Content.ReadAsStringAsync(); var reslt = new JavaScriptSerializer().Deserialize <BSEntityFramework_ResultType>(rslt); if (reslt.Result == BSResult.FailForValidation) { foreach (var valerr in reslt.EntityValidationException) { ModelState.AddModelError("BS Errors", valerr); } } else if (reslt.Result == BSResult.Success) { ModelState.AddModelError("ServerError", reslt.ResultMsg); return(ValidateModel("FailedFromServer", null, "SignUp / Login")); } else { ModelState.AddModelError("BS Errors", reslt.ResultMsg); } var allErrors = ModelState.Values.SelectMany(v => v.Errors); return(Json(allErrors, JsonRequestBehavior.AllowGet)); } return(Json("Failed", JsonRequestBehavior.AllowGet)); } return(ValidateModel("", null, "SignUp / Login")); }
// GET: Shops/Edit/5 public ActionResult Edit() { var response = new CommonAjaxCallToWebAPI().AjaxPost("/api/shop/EditShopDetails", GetCurrentShopId(), Convert.ToString(Session["BSWebApiToken"])).Result; if (response.IsSuccessStatusCode) { var rslt = response.Content.ReadAsStringAsync().Result; var BSresult = new JavaScriptSerializer().Deserialize <BSEntityFramework_ResultType>(rslt); if (BSresult.Result == BSResult.Success) { return(View(BSresult.Entity)); } if (BSresult.Result == BSResult.FailForValidation) { foreach (var valerr in BSresult.EntityValidationException) { ModelState.AddModelError("BS Errors", valerr); } } else { ModelState.AddModelError("BS Errors", BSresult.ResultMsg); } return(View()); } ModelState.AddModelError("BS Errors", "Technical Error"); return(View()); }
public JsonResult GetProductList(string prodName = "", string brandName = "", string barCode = "", string productType = "", string isAvailable = "true", string availableQty = "", string isActive = "true", string prodCategory = "", string prodSubType = "", string prodMrp = "", string prodShopPrice = "", string bsGnd = "", string sidx = "ProductName", string sord = "asc", int rows = 3, int page = 1) { try { var currentShopId = BSSecurityEncryption.Decrypt(bsGnd, WebAppConfig.GetConfigValue("BSGnd")); var param = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("prodName", prodName), new KeyValuePair <string, string>("brandName", brandName), new KeyValuePair <string, string>("barCode", barCode), new KeyValuePair <string, string>("productType", productType), new KeyValuePair <string, string>("isAvailable", isAvailable), new KeyValuePair <string, string>("availableQty", availableQty), new KeyValuePair <string, string>("isActive", isActive), new KeyValuePair <string, string>("prodCategory", prodCategory), new KeyValuePair <string, string>("prodSubType", prodSubType), new KeyValuePair <string, string>("prodMrp", prodMrp), new KeyValuePair <string, string>("prodShopPrice", prodShopPrice), new KeyValuePair <string, string>("shopId", currentShopId), new KeyValuePair <string, string>("sortColumnName", sidx), new KeyValuePair <string, string>("sortOrder", sord), new KeyValuePair <string, string>("pageSize", Convert.ToString(rows)), new KeyValuePair <string, string>("currentPage", Convert.ToString(page)), }; var data = new CommonAjaxCallToWebAPI().AjaxGet(@"/api/product/GetProductListView", param , Convert.ToString(Session["BSWebApiToken"])); // return Json(data, JsonRequestBehavior.AllowGet); var jqGridData = new JqGridType() { Data = data, Page = "1", PageSize = "3", // u can change this ! SortColumn = "1", SortOrder = "asc" }; return(Json(jqGridData, JsonRequestBehavior.AllowGet)); } catch { return(null); } }
public string GetOfferImage(string id, string bsGnd) { var param = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("offerId", id), new KeyValuePair <string, string>("shopId", "0") }; var reslt = new CommonAjaxCallToWebAPI().AjaxGet(@"/api/shopoffers/GetOfferImage", param, Convert.ToString(Session["BSWebApiToken"])); var prodImageDtls = new JavaScriptSerializer().Deserialize <ImageDetails>(reslt); return("<img id= 'Offerid" + id + "img' name='" + prodImageDtls.ImgID + "' style='display: block; margin: 0 auto; height: 200px; width: 200px;' src = " + prodImageDtls.ImgData + " />"); }
private List <SelectListItem> GetShopTypes() { try { var reslt = new CommonAjaxCallToWebAPI().AjaxGet(@"/api/common/GetShopTypesDetails", null, Convert.ToString(Session["BSWebApiToken"])); return(new JavaScriptSerializer().Deserialize <List <SelectListItem> >(reslt)); } catch { return(null); } }
private string GetShopAddress() { try { var shopId = GetCurrentShopId(); var paramlist = new List <KeyValuePair <string, string> >(); var param = new KeyValuePair <string, string>("shopId", Convert.ToString(shopId)); paramlist.Add(param); var reslt = new CommonAjaxCallToWebAPI().AjaxGet(@"/api/shop/GetShopAddress", paramlist, Convert.ToString(Session["BSWebApiToken"])); return(new JavaScriptSerializer().Deserialize <string>(reslt)); } catch { return("India"); } }
public JsonResult GetInfrastureDetails(string postalCode) { try { var paramlist = new List <KeyValuePair <string, string> >(); var param = new KeyValuePair <string, string>("postalCode", postalCode); paramlist.Add(param); var reslt = new CommonAjaxCallToWebAPI().AjaxGet(@"/api/common/GetInfrastructureDetails", paramlist, Convert.ToString(Session["BSWebApiToken"])); return(Json(new JavaScriptSerializer().Deserialize <object>(reslt), JsonRequestBehavior.AllowGet)); } catch { return(null); } }
public async Task <ActionResult> ShopMapAddress(MapAddressViewModel model) { try { UserDetails currentUser = GetCurrentUserDetails(); model.shopMapDetails.CreateBy = currentUser.UserId; model.shopMapDetails.ShopId = GetCurrentShopId(); if (ModelState.IsValidField("shopMapDetails")) { using (var client = new HttpClient()) { var response = new CommonAjaxCallToWebAPI().AjaxPost("/api/shop/PostShopMapDetails", model.shopMapDetails, Convert.ToString(Session["BSWebApiToken"])).Result; if (response.StatusCode == System.Net.HttpStatusCode.OK) { var rslt = await response.Content.ReadAsStringAsync(); var reslt = new JavaScriptSerializer().Deserialize <BSEntityFramework_ResultType>(rslt); if (reslt.Result == BSResult.Success) { return(View("~/Views/Product/AddProduct.cshtml")); } else { foreach (var valerr in reslt.EntityValidationException) { ModelState.AddModelError("BS Errors", valerr); } return(View()); } } else { ModelState.AddModelError("BS Errors", "Internal server error"); return(View()); } } } return(View()); } catch (Exception ex) { // FillViewDatasForAddShop(); return(View()); } }
public JsonResult GetOffersList(string offerShortDetails = "", string offerStartDate = "", string offerEndDate = "", string offerOnBrand = "", string isOfferOnProduct = null, string isActive = null, string bsGnd = "", string sord = "asc", int rows = 3, int page = 1, string sidx = "OfferID") { try { var currentShopId = BSSecurityEncryption.Decrypt(bsGnd, WebAppConfig.GetConfigValue("BSGnd")); var param = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("offerShortDetails", offerShortDetails), new KeyValuePair <string, string>("offerStartDate", offerStartDate), new KeyValuePair <string, string>("offerEndDate", offerEndDate), new KeyValuePair <string, string>("offerOnBrand", offerOnBrand), new KeyValuePair <string, string>("isOfferOnProduct", isOfferOnProduct), new KeyValuePair <string, string>("isActive", isActive), new KeyValuePair <string, string>("shopId", currentShopId), new KeyValuePair <string, string>("sortColumnName", sidx), new KeyValuePair <string, string>("sortOrder", sord), new KeyValuePair <string, string>("pageSize", Convert.ToString(rows)), new KeyValuePair <string, string>("currentPage", Convert.ToString(page)), }; var data = new CommonAjaxCallToWebAPI().AjaxGet(@"api/shopoffers/GetShopOffersListView", param , Convert.ToString(Session["BSWebApiToken"])); // return Json(data, JsonRequestBehavior.AllowGet); var jqGridData = new JqGridType() { Data = data, Page = "1", PageSize = "3", // u can change this ! SortColumn = "1", SortOrder = "asc" }; return(Json(jqGridData, JsonRequestBehavior.AllowGet)); } catch { return(null); } }
private MapAddressViewModel GetShopMapAddress() { try { var shopId = GetCurrentShopId(); var paramlist = new List <KeyValuePair <string, string> >(); var param = new KeyValuePair <string, string>("shopId", Convert.ToString(shopId)); paramlist.Add(param); var reslt = new CommonAjaxCallToWebAPI().AjaxGet(@"/api/shop/GetShopMapDetails", paramlist, Convert.ToString(Session["BSWebApiToken"])); var finalresult = new JavaScriptSerializer().Deserialize <BSEntityFramework_ResultType>(reslt); return (new JavaScriptSerializer().Deserialize <MapAddressViewModel>( (new JavaScriptSerializer().Serialize(finalresult.Entity)))); } catch { return(new MapAddressViewModel() { Address = "India" }); } }
public ActionResult AddShop(AddShopViewModel model) { try { var currentUserId = CommonSafeConvert.ToInt(Session["CurrentUserID"]); if (!LoginResult.VerifyUserId(currentUserId)) { } if (ModelState.IsValid) { model.ShopDetails.CreatedBy = currentUserId; model.ShopPostalDetails.CreatedBy = currentUserId; model.ShopPostalDetails.IsActive = true; var response = new CommonAjaxCallToWebAPI().AjaxPost("/api/shop/PostNewShopes", model, Convert.ToString(Session["BSWebApiToken"])).Result; if (response.IsSuccessStatusCode) { var rslt = response.Content.ReadAsStringAsync().Result; return(Json(new JavaScriptSerializer().Deserialize <object>(rslt), JsonRequestBehavior.AllowGet)); } else { return(null); } } FillViewDatasForAddShop(); return(View("AddShop", model)); } catch { FillViewDatasForAddShop(); return(View()); } }
public async Task <ActionResult> EditOffer(ProductUpdateForm formDATA) { var ProductDetails = new JavaScriptSerializer().Deserialize <TBL_Products>(formDATA.ProductDetails); UserDetails currentUser = GetCurrentUserDetails(); AddProductViewModel model = new AddProductViewModel(); model.ProductDetails = ProductDetails; if (formDATA.file != null) { model.ProductImages = new List <TBL_ProductImages>(); model.ProductImages.Add(new TBL_ProductImages() { ImageID = CommonSafeConvert.ToInt(formDATA.imgId), ProductID = ProductDetails.ProductID, UpdatedBy = currentUser.UserId, UpdateDate = DateTime.Now, IsActive = true, ProductImage = CommonSafeConvert.ConvertToBytesFromFile(formDATA.file) }); } if (ModelState.IsValid) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(WebAppConfig.GetConfigValue("WebAPIUrl")); // Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var response = new CommonAjaxCallToWebAPI().AjaxPost("/api/product/PostEditProduct", model, Convert.ToString(Session["BSWebApiToken"])).Result; // var response = await client.PostAsJsonAsync("/api/product/PostEditProduct", model); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var rslt = await response.Content.ReadAsStringAsync(); var reslt = new JavaScriptSerializer().Deserialize <BSEntityFramework_ResultType>(rslt); if (reslt.Result == BSResult.FailForValidation) { foreach (var valerr in reslt.EntityValidationException) { ModelState.AddModelError("BS Errors", valerr); } } //return reslt; //FillViewDatasForAddShop(); var allErrors = ModelState.Values.SelectMany(v => v.Errors); return(Json(allErrors, JsonRequestBehavior.AllowGet)); } else { return(Json("Failed", JsonRequestBehavior.AllowGet)); } } } return(Json(new { Valid = ModelState.IsValid, UserID = currentUser.UserId, //Errors = GetErrorsFromModelState(), Status = "Validation Failed" })); }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { // Lets first check if the Model is valid or not if (ModelState.IsValidField("loginModel")) { // var response = new CommonAjaxCallToWebAPI().AjaxPost("/api/home/ValidateLogin", model.loginModel).Result; var responseToken = new CommonAjaxCallToWebAPI().AjaxPostToken(model.loginModel).Result; if (string.IsNullOrWhiteSpace(responseToken.Error)) { Session["BSWebApiToken"] = responseToken.AccessToken; model.loginModel.Password = null; var response = new CommonAjaxCallToWebAPI().AjaxPost("/api/home/ValidateLogin", model.loginModel, responseToken.AccessToken).Result; var rslt = await response.Content.ReadAsStringAsync(); var reslt = new JavaScriptSerializer().Deserialize <BSEntityFramework_ResultType>(rslt); bool userValid = false; var loginResult = new JavaScriptSerializer().Deserialize <LoginResult>( (new JavaScriptSerializer().Serialize(reslt.Entity))); if (loginResult != null && !(Convert.ToBoolean(loginResult.IsValid))) { if (reslt.Result == BSResult.FailForValidation) { foreach (var valerr in reslt.EntityValidationException) { ModelState.AddModelError("BS Errors", valerr); } } else { ModelState.AddModelError("BS Errors", reslt.ResultMsg); } } else { userValid = true; } // User found in the database if (userValid) { FormsAuthentication.SetAuthCookie(model.loginModel.UserName, false); var authTicket = new FormsAuthenticationTicket(1, model.loginModel.UserName, DateTime.Now, DateTime.Now.AddMinutes(20), false, Convert.ToString(loginResult.UserId)); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); HttpContext.Response.Cookies.Add(authCookie); ModelState.AddModelError("ServerSuccess", reslt.ResultMsg); if (loginResult?.MenuDetailList != null) { return(ValidateModel("ServerSuccess", loginResult, model.loginModel.UserName)); } return(ValidateModel("ServerSuccess", null, "SignUp / Login")); } ModelState.AddModelError("ServerError", "The user name or password provided is incorrect."); return(ValidateModel("FailedFromServer", null, "SignUp / Login")); } ModelState.AddModelError("ServerError", "The user name or password provided is incorrect."); return(ValidateModel("FailedFromServer", null, "SignUp / Login")); } return(ValidateModel("", null, "SignUp / Login")); }