public ActionResult Index() { List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("selectBy", "profile")); parameters.Add(new KeyValuePair <string, string>("param1", _objHelper.GetTokenData(HttpContext.User.Identity as ClaimsIdentity, "id_user"))); parameters.Add(new KeyValuePair <string, string>("param2", "")); DataTable _dtResp = _objDataHelper.ExecuteProcedure("entity_master_select", parameters); ProfileModel profileModel = new ProfileModel(); if (this._objHelper.checkDBNullResponse(_dtResp)) { profileModel.name = Convert.ToString(_dtResp.Rows[0]["name"]); profileModel.email = Convert.ToString(_dtResp.Rows[0]["email"]); profileModel.phone = Convert.ToString(_dtResp.Rows[0]["phone"]); profileModel.country = Convert.ToString(_dtResp.Rows[0]["country"]); profileModel.dob = Convert.ToString(_dtResp.Rows[0]["dob"]); profileModel.city = Convert.ToString(_dtResp.Rows[0]["city"]); profileModel.province = Convert.ToString(_dtResp.Rows[0]["state"]); profileModel.pin = Convert.ToString(_dtResp.Rows[0]["pin"]); } else { ViewData["ErrorMessage"] = "Unable to fetch data. Try again later."; } ViewData["CountryList"] = GetCountryList(); return(View("~/Views/Panel/Profile/Index.cshtml", profileModel)); }
public IActionResult Index() { List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("selectBy", "business")); parameters.Add(new KeyValuePair <string, string>("param1", _objHelper.GetTokenData(HttpContext.User.Identity as ClaimsIdentity, "id_user"))); parameters.Add(new KeyValuePair <string, string>("param2", "")); DataTable _dtResp = _objDataHelper.ExecuteProcedure("entity_master_select", parameters); ViewData["BusinessList"] = null; if (this._objHelper.checkDBNullResponse(_dtResp)) { ViewData["BusinessList"] = _dtResp; } else { ViewData["ErrorMessage"] = "Unable to fetch data. Try again later."; } ViewData["CountryList"] = GetCountryList(); return(View("~/Views/Panel/Business/Index.cshtml")); }
public async Task <IActionResult> Login(LoginModel loginModel) { if (!ModelState.IsValid) { return(View()); } List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("user_name", loginModel.username)); parameters.Add(new KeyValuePair <string, string>("pass_word", loginModel.password)); parameters.Add(new KeyValuePair <string, string>("ip_addr", Request.HttpContext.Connection.RemoteIpAddress.ToString())); DataTable _dtResp = _objDataHelper.ExecuteProcedure("login_user", parameters); if (this._objHelper.checkDBResponse(_dtResp)) { if (_dtResp.Rows[0]["response"].ToString() == "0") { ViewData["ErrorMessage"] = _dtResp.Rows[0]["message"].ToString(); } else { var claims = new List <Claim> { new Claim("name", _dtResp.Rows[0]["name"].ToString()), new Claim("id_user", _dtResp.Rows[0]["id_user_master"].ToString()), new Claim("id_organization", _dtResp.Rows[0]["id_organization_master"].ToString()), new Claim("organization_name", _dtResp.Rows[0]["organization_name"].ToString()), new Claim("profile_img", _dtResp.Rows[0]["profile_img"].ToString()), new Claim("pid", _dtResp.Rows[0]["pid"].ToString()), }; var userIdentity = new ClaimsIdentity(claims, "Cookie"); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); await HttpContext.SignInAsync( scheme : CookieAuthenticationDefaults.AuthenticationScheme, principal : principal ); if (string.IsNullOrEmpty(loginModel.ReturnUrl)) { return(RedirectToAction("Index", "Home")); } else { return(Redirect(loginModel.ReturnUrl)); } } } else { ViewData["ErrorMessage"] = "Login service unavailable"; } return(View()); }
public IActionResult Index(CustomerModel customerModel) { if (!ModelState.IsValid) { return(View("~/Views/Panel/Customer/Index.cshtml")); } List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("i_id_organization_master", _objHelper.GetTokenData(HttpContext.User.Identity as ClaimsIdentity, "id_organization"))); parameters.Add(new KeyValuePair <string, string>("i_name", customerModel.name)); parameters.Add(new KeyValuePair <string, string>("i_address", customerModel.address)); parameters.Add(new KeyValuePair <string, string>("i_country", customerModel.country.ToString())); parameters.Add(new KeyValuePair <string, string>("i_state", customerModel.state)); parameters.Add(new KeyValuePair <string, string>("i_city", customerModel.city)); parameters.Add(new KeyValuePair <string, string>("i_pin", customerModel.pin)); parameters.Add(new KeyValuePair <string, string>("i_phone", customerModel.phone)); parameters.Add(new KeyValuePair <string, string>("i_fax", customerModel.fax)); parameters.Add(new KeyValuePair <string, string>("i_mobile", customerModel.mobile)); parameters.Add(new KeyValuePair <string, string>("i_email", customerModel.email)); DataTable _dtResp = _objDataHelper.ExecuteProcedure("insert_customer", parameters); if (this._objHelper.checkDBResponse(_dtResp)) { if (_dtResp.Rows[0]["response"].ToString() == "0") { ViewData["ErrorMessage"] = _dtResp.Rows[0]["message"].ToString(); } else { ViewData["SuccessMessage"] = "Customer registered successfuly."; } } else { ViewData["ErrorMessage"] = "Customer service unavailable"; } ViewData["CustomerList"] = null; DataTable _dtResp2 = GetCustomerList(); if (this._objHelper.checkDBNullResponse(_dtResp2)) { ViewData["CustomerList"] = _dtResp2; } else { ViewData["ListErrorMessage"] = "Unable to fetch data. Try again later."; } ViewData["CountryList"] = GetCountryList(); return(View("~/Views/Panel/Customer/Index.cshtml")); }
public ActionResult Index(ProductModel productModel) { List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("i_id_organization", _objHelper.GetTokenData(HttpContext.User.Identity as ClaimsIdentity, "id_organization"))); parameters.Add(new KeyValuePair <string, string>("i_product_type", productModel.type)); parameters.Add(new KeyValuePair <string, string>("i_title", productModel.title)); parameters.Add(new KeyValuePair <string, string>("i_description", productModel.description)); parameters.Add(new KeyValuePair <string, string>("i_price", productModel.price)); parameters.Add(new KeyValuePair <string, string>("i_is_sold", productModel.is_sold)); parameters.Add(new KeyValuePair <string, string>("i_is_purchased", productModel.is_purchased)); DataTable _dtResp = _objDataHelper.ExecuteProcedure("insert_product", parameters); if (this._objHelper.checkDBResponse(_dtResp)) { if (_dtResp.Rows[0]["response"].ToString() == "0") { ViewData["ErrorMessage"] = _dtResp.Rows[0]["message"].ToString(); } else { ViewData["SuccessMessage"] = "Product/Service registered successfuly."; } } else { ViewData["ErrorMessage"] = "Product service unavailable"; } ViewData["ProductList"] = null; DataTable _dtResp2 = GetProductList(); if (this._objHelper.checkDBNullResponse(_dtResp2)) { ViewData["ProductList"] = _dtResp2; } else { ViewData["ListErrorMessage"] = "Unable to fetch data. Try again later."; } if (!ModelState.IsValid) { return(View("~/Views/Panel/ProductService/Index.cshtml")); } return(View("~/Views/Panel/ProductService/Index.cshtml")); }
public ActionResult Index(TaxModel taxModel) { if (!ModelState.IsValid) { return(View("~/Views/Panel/Tax/Index.cshtml")); } List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("i_id_organization", _objHelper.GetTokenData(HttpContext.User.Identity as ClaimsIdentity, "id_organization"))); parameters.Add(new KeyValuePair <string, string>("i_tax_header", taxModel.header)); parameters.Add(new KeyValuePair <string, string>("i_type", taxModel.type)); parameters.Add(new KeyValuePair <string, string>("i_value", taxModel.value.ToString())); parameters.Add(new KeyValuePair <string, string>("i_applicability", taxModel.applicability)); DataTable _dtResp = _objDataHelper.ExecuteProcedure("insert_tax", parameters); if (this._objHelper.checkDBResponse(_dtResp)) { if (_dtResp.Rows[0]["response"].ToString() == "0") { ViewData["ErrorMessage"] = _dtResp.Rows[0]["message"].ToString(); } else { ViewData["SuccessMessage"] = "Tax registered successfuly."; } } else { ViewData["ErrorMessage"] = "Business service unavailable"; } ViewData["TaxList"] = null; DataTable _dtResp2 = GetTaxList(); if (this._objHelper.checkDBNullResponse(_dtResp2)) { ViewData["TaxList"] = _dtResp2; } else { ViewData["ListErrorMessage"] = "Unable to fetch data. Try again later."; } return(View("~/Views/Panel/Tax/Index.cshtml")); }
public IActionResult Index() { List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("selectBy", "users")); parameters.Add(new KeyValuePair <string, string>("param1", "")); parameters.Add(new KeyValuePair <string, string>("param2", "")); DataTable _dtResp = _objDataHelper.ExecuteProcedure("entity_master_select", parameters); List <Dictionary <string, string> > resp = new List <Dictionary <string, string> >(); if (this._objHelper.checkDBNullResponse(_dtResp)) { ViewData["UsersList"] = _dtResp; } return(View("~/Views/Admin/Users/Index.cshtml")); }
public JsonResult BusinessList() { List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("selectBy", "user_business")); parameters.Add(new KeyValuePair <string, string>("param1", _objHelper.GetTokenData(HttpContext.User.Identity as ClaimsIdentity, "id_user"))); parameters.Add(new KeyValuePair <string, string>("param2", "")); DataTable _dtResp = _objDataHelper.ExecuteProcedure("entity_master_select", parameters); List <Dictionary <string, string> > resp = new List <Dictionary <string, string> >(); if (this._objHelper.checkDBNullResponse(_dtResp)) { resp = _objHelper.ConvertTableToDictionary(_dtResp); } return(new JsonResult(resp)); }
public async Task <IActionResult> Index(RecieptModel recieptModel) { if (!ModelState.IsValid) { ViewData["CountryList"] = GetCountryList(); return(View("~/Views/Panel/Reciepts/Index.cshtml")); } if (!(recieptModel.image.ContentType == "image/png" || recieptModel.image.ContentType == "image/jpg" || recieptModel.image.ContentType == "image/jpeg")) { TempData["ImageUploadError"] = "Unsupported image type. Kindly re-upload a JPG/JPEG/PNG only."; return(RedirectToAction("Index", "Profile")); } string dbPath = "/uploads/profile_picure"; string path = _env.WebRootPath + dbPath; string localFileName = Guid.NewGuid().ToString() + "." + recieptModel.image.ContentType.Split("/")[recieptModel.image.ContentType.Split("/").Length - 1]; byte[] imageStream; using (var memoryStream = new MemoryStream()) { await recieptModel.image.CopyToAsync(memoryStream); imageStream = memoryStream.ToArray(); } using (var fs = new FileStream($"{path}/{localFileName}", FileMode.Create, FileAccess.Write)) { await fs.WriteAsync(imageStream, 0, imageStream.Length); } List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("i_id_organization", _objHelper.GetTokenData(HttpContext.User.Identity as ClaimsIdentity, "id_organization"))); parameters.Add(new KeyValuePair <string, string>("i_image", $"{dbPath}/{localFileName}")); parameters.Add(new KeyValuePair <string, string>("i_dated", recieptModel.dated)); parameters.Add(new KeyValuePair <string, string>("i_notes", recieptModel.notes)); parameters.Add(new KeyValuePair <string, string>("i_category", recieptModel.category)); parameters.Add(new KeyValuePair <string, string>("i_payment_account", recieptModel.payment_account)); parameters.Add(new KeyValuePair <string, string>("i_subtotal", recieptModel.subtotal)); parameters.Add(new KeyValuePair <string, string>("i_currency", recieptModel.currency)); parameters.Add(new KeyValuePair <string, string>("i_total", recieptModel.total)); parameters.Add(new KeyValuePair <string, string>("i_added_by", _objHelper.GetTokenData(HttpContext.User.Identity as ClaimsIdentity, "id_user"))); DataTable _dtResp = _objDataHelper.ExecuteProcedure("insert_reciept", parameters); if (this._objHelper.checkDBResponse(_dtResp)) { if (_dtResp.Rows[0]["response"].ToString() == "0") { ViewData["ErrorMessage"] = _dtResp.Rows[0]["message"].ToString(); } else { ViewData["SuccessMessage"] = "Reciept registered successfuly."; } } else { ViewData["ErrorMessage"] = "Reciept service unavailable"; } ViewData["RecieptList"] = null; DataTable _dtResp2 = GetRecieptList(); if (this._objHelper.checkDBNullResponse(_dtResp2)) { ViewData["RecieptList"] = _dtResp2; } else { ViewData["ListErrorMessage"] = "Unable to fetch data. Try again later."; } ViewData["CountryList"] = GetCountryList(); return(View("~/Views/Panel/Reciepts/Index.cshtml")); }
public Task Invoke(HttpContext httpContext) { if (httpContext.User.Identity.IsAuthenticated) { List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("user_id", _helper.GetTokenData(httpContext.User.Identity as ClaimsIdentity, "id_user"))); parameters.Add(new KeyValuePair <string, string>("org_id", _helper.GetTokenData(httpContext.User.Identity as ClaimsIdentity, "id_organization"))); if (httpContext.Request.Path.ToString().StartsWith("/Customer")) { parameters.Add(new KeyValuePair <string, string>("url", "CUSTOMER")); parameters.Add(new KeyValuePair <string, string>("method", httpContext.Request.Method)); DataTable _dtResp = _dB.ExecuteProcedure("access_control", parameters); if (_dtResp.Rows[0]["response"].ToString() != "1") { httpContext.Response.Redirect("/Error/Forbidden"); } } else if (httpContext.Request.Path.ToString().StartsWith("/Business")) { parameters.Add(new KeyValuePair <string, string>("url", "BUSINESS")); parameters.Add(new KeyValuePair <string, string>("method", httpContext.Request.Method)); DataTable _dtResp = _dB.ExecuteProcedure("access_control", parameters); if (_dtResp.Rows[0]["response"].ToString() != "1") { httpContext.Response.Redirect("/Error/Forbidden"); } } else if (httpContext.Request.Path.ToString().StartsWith("/ProductService")) { parameters.Add(new KeyValuePair <string, string>("url", "PRODUCTSERVICE")); parameters.Add(new KeyValuePair <string, string>("method", httpContext.Request.Method)); DataTable _dtResp = _dB.ExecuteProcedure("access_control", parameters); if (_dtResp.Rows[0]["response"].ToString() != "1") { httpContext.Response.Redirect("/Error/Forbidden"); } } else if (httpContext.Request.Path.ToString().StartsWith("/Tax")) { parameters.Add(new KeyValuePair <string, string>("url", "TAX")); parameters.Add(new KeyValuePair <string, string>("method", httpContext.Request.Method)); DataTable _dtResp = _dB.ExecuteProcedure("access_control", parameters); if (_dtResp.Rows[0]["response"].ToString() != "1") { httpContext.Response.Redirect("/Error/Forbidden"); } } else if (httpContext.Request.Path.ToString().StartsWith("/Vendor")) { parameters.Add(new KeyValuePair <string, string>("url", "VENDOR")); parameters.Add(new KeyValuePair <string, string>("method", httpContext.Request.Method)); DataTable _dtResp = _dB.ExecuteProcedure("access_control", parameters); if (_dtResp.Rows[0]["response"].ToString() != "1") { httpContext.Response.Redirect("/Error/Forbidden"); } } } return(_next(httpContext)); }