public VendorList(int receiptID) { InitializeComponent(); VendorListViewModel _collection = new VendorListViewModel(receiptID); this.BindingContext = _collection; }
// azure link: http://productssample.azurewebsites.net/api/products //Product prodList; // GET: Products public ActionResult Index() { IEnumerable <Vendor> vendList; WebClient client = new WebClient(); string output = client.DownloadString(dashboardUrlBase); vendList = JsonConvert.DeserializeObject <List <Vendor> >(output); VendorListViewModel vendorList = new VendorListViewModel(); List <VendorViewModel> vendVMs = new List <VendorViewModel>(); foreach (Vendor v in vendList) { VendorViewModel vvm = new VendorViewModel(); vvm.VendorName = v.VendorName; vvm.VendorCode = v.VendorCode; vvm.ValidFrom = v.ValidFrom; vvm.ValidThru = v.ValidThru; vendVMs.Add(vvm); } ; vendorList.Vendors = vendVMs; return(View("Index", vendorList)); }
//[Route("VIndex")] public ActionResult Index() { if (Convert.ToInt32(Session["SectionID"]) != 13) { List <tbl_Master_Role> RoleList = (List <tbl_Master_Role>)Session["RoleList"]; bool isAccessible = false; foreach (var item in RoleList) { if (item.FormName.ToLower() == "Vendor Master".ToLower()) { // if (Convert.ToInt32(Session["SectionID"]) == 13 || Convert.ToInt32(Session["SectionID"]) == 8 || Convert.ToInt32(Session["SectionID"]) == 9 || Convert.ToInt32(Session["SectionID"]) == 10) { isAccessible = true; } } } if (!isAccessible) { return(RedirectToAction("Login", "Account")); } } var password = "******"; VendorListViewModel model = new VendorListViewModel(); List <VendorListViewModel> list = new List <VendorListViewModel>(); var vendorList = _entities.tbl_tblVendor.Where(x => x.IsDeleted == false).ToList(); foreach (var item in vendorList) { VendorListViewModel obj = new VendorListViewModel(); obj.VendorId = Cipher.Encrypt_Portal(item.VendorId.ToString()); obj.VendorName = Cipher.Decrypt(item.VendorName, password); //obj.VendorName = Encryption.Decrypt(item.VendorName); obj.VendorAddress = item.VendorAddress; obj.VendorContactName = item.VendorContactName; obj.VendorPhone = item.VendorPhone; obj.VendorEmail = item.VendorEmail; obj.CategoryName = item.tbl_tblVendorCategory.VendorCategoryName; list.Add(obj); } ViewBag.msg = ""; model.VendorList = list; if (TempData["ID"] != null) { ViewBag.msg = TempData["ID"].ToString(); } return(View(model)); }
public async Task <IActionResult> Index(VendorListViewModel model) { var currentPageNum = model.Page; var offset = (model.PageSize * currentPageNum) - model.PageSize; //This is an example of how to query for entities in the account context. Most entites that live in the accountcontext will have a foreign key to Account. //It's important that we filter by account FIRST before applying any other filters when building quries. var vendors = _accountCtx.Vendors.ForAccount(CommonAccount.Id).AsQueryable(); switch (model.SortOrder) { case "Name": if (model.SortDirection == "DESC") { vendors = vendors.OrderByDescending(x => x.Name); } else { vendors = vendors.OrderBy(x => x.Name); } break; case "Email": if (model.SortDirection == "DESC") { vendors = vendors.OrderByDescending(x => x.Email); } else { vendors = vendors.OrderBy(x => x.Email); } break; default: vendors = vendors.OrderByDescending(x => x.Name); break; } var totalQueryCount = await vendors.CountAsync(); model.VendorList = Mapper.Map <List <VendorListItem> >(vendors); return(View(model)); }
public IActionResult VendorList() { VendorListViewModel list = new VendorListViewModel(); list.List = new List <VendorDetailViewModel>(); var vendors = userManager.GetUsersInRoleAsync("Vendor").Result; foreach (var vendor in vendors) { VendorDetailViewModel model = new VendorDetailViewModel(); model = GetVendorDetail(vendor.Id); //model.CreatedDate = vendor.CreateDate.DateTime; list.List.Add(model); } return(View(list)); }
public List <VendorListViewModel> getVendorList() { List <VendorListViewModel> lstObj = new List <VendorListViewModel>(); try { using (SqlConnection connection = DataAccess.CreateConnection()) { SqlCommand command = DataAccess.CreateCommand(connection); DataAccess.CreateStoredprocedure(command, "GetVendorList_SP"); SqlDataReader reader = DataAccess.ExecuteReader(command); if (reader != null) { while (reader.Read()) { VendorListViewModel vendor = new VendorListViewModel(); vendor.Id = reader["Id"] is DBNull ? 0 : Convert.ToInt32(reader["Id"]); vendor.Name = reader["Name"] is DBNull ? string.Empty : Convert.ToString(reader["Name"]); vendor.Email = reader["Email"] is DBNull ? string.Empty : Convert.ToString(reader["Email"]); vendor.Address = reader["Address"] is DBNull ? string.Empty : Convert.ToString(reader["Address"]); vendor.Telephone = reader["Telephone"] is DBNull ? string.Empty : (String)reader["Telephone"]; vendor.FaxNo = reader["FaxNo"] is DBNull ? string.Empty : (String)reader["FaxNo"]; vendor.NetSafi = reader["NetSafi"] is DBNull ? 0 : Convert.ToDouble(reader["NetSafi"]); vendor.Balance = reader["Balance"] is DBNull ? 0 : Convert.ToDouble(reader["Balance"]); lstObj.Add(vendor); } } reader.Close(); return(lstObj); } } catch (Exception ex) { return(lstObj); } }
// GET: Vendors public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page) { IEnumerable <Vendor> vendList; WebClient client = new WebClient(); string output = client.DownloadString(dashboardUrlBase); vendList = JsonConvert.DeserializeObject <List <Vendor> >(output); if (String.IsNullOrEmpty(sortOrder)) { sortOrder = "name"; } ; string inSortOrder = sortOrder; if (Session != null) { if (Session["sort"] == null) { Session["sort"] = ""; } if (Session["sortDir"] == null) { Session["sortDir"] = "asc"; } } string sortDir = Session["sortDir"].ToString(); if (sortOrder == Session["sort"].ToString()) { sortDir = sortDir == "asc" ? "desc" : "asc"; } else { sortDir = "asc"; } Session["sortDir"] = sortDir; Session["sort"] = inSortOrder; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; var vendors = from v in vendList select v; if (!String.IsNullOrEmpty(searchString)) { vendors = vendors.Where(v => v.VendorName.ToLower().Contains(searchString.ToLower())); } switch (sortOrder + sortDir) { case "namedesc": vendors = vendors.OrderByDescending(v => v.VendorName); break; case "codedesc": vendors = vendors.OrderByDescending(v => v.VendorCode); break; case "codeasc": vendors = vendors.OrderBy(v => v.VendorCode); break; case "fromasc": vendors = vendors.OrderBy(v => v.ValidFrom); break; case "fromdesc": vendors = vendors.OrderByDescending(v => v.ValidFrom); break; case "thruasc": vendors = vendors.OrderBy(v => v.ValidThru); break; case "thrudesc": vendors = vendors.OrderByDescending(v => v.ValidThru); break; default: vendors = vendors.OrderBy(v => v.VendorName); break; } int pageSize = 30; int pageNumber = (page ?? 1); VendorListViewModel vendorList = new VendorListViewModel(); List <VendorViewModel> vendVMs = new List <VendorViewModel>(); foreach (Vendor v in vendors) { VendorViewModel vvm = new VendorViewModel(); vvm.VendorName = v.VendorName; vvm.VendorCode = v.VendorCode; vvm.ValidFrom = v.ValidFrom; vvm.ValidThru = v.ValidThru; vvm.Id = v.Id; vendVMs.Add(vvm); } ; vendorList.Vendors = vendVMs; return(View("Index", vendorList)); }