public ActionResult Delete(int index, int id) { var model = new SupplierListModel(); model.GridIndex = index; try { var error = SupplierService.DeleteSupplier(id); model.Error.SetError(error.Message); } catch (Exception e1) { model.Error.SetError(e1); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public SupplierListControl(SupplierListModel model) { InitializeComponent(); _presenter = new SupplierListPresenter(this, model); gvSupplier.PopupMenuShowing += gvSupplier_PopupMenuShowing; gvSupplier.FocusedRowChanged += gvSupplier_FocusedRowChanged; // init editor control accessibility btnNewSupplier.Enabled = AllowInsert; cmsEditData.Enabled = AllowEdit; cmsDeleteData.Enabled = AllowDelete; this.Load += SupplierListControl_Load; }
public List <SupplierListModel> GetSupplierList(string criteria) { using (var uow = new UnitOfWork(new DataContext())) { var models = new List <SupplierListModel>(); var suppliers = uow.Suppliers.GetAll(criteria); foreach (var supplier in suppliers) { var model = new SupplierListModel(); model.SupplierID = supplier.SupplierID; model.Description = supplier.Description; model.Address = supplier.Address; models.Add(model); } return(models); } }
public SupplierListModel FindSuppliersListModel(CompanyModel company, int index = 0, int pageNo = 1, int pageSize = Int32.MaxValue, string search = "", int countryId = 0) { var model = new SupplierListModel(); // Do a case-insensitive search model.GridIndex = index; var allItems = db.FindSuppliers(company.Id, true) .Where(s => (string.IsNullOrEmpty(search) || (s.Name != null && s.Name.ToLower().Contains(search.ToLower())) || s.ContactName.ToLower().Contains(search.ToLower()) || s.Email.ToLower().Contains(search.ToLower())) && (countryId == 0 || s.SupplierAddresses.Where(sa => sa.CountryId == countryId).Count() > 0)); model.TotalRecords = allItems.Count(); foreach (var item in allItems.Skip((pageNo - 1) * pageSize) .Take(pageSize)) { var supplier = MapToModel(item); var address = FindSupplierAddressModel(supplier.Id); if (address != null) { supplier.Street = address.Street; supplier.City = address.City; supplier.State = address.State; supplier.Postcode = address.Postcode; supplier.CountryName = address.CountryName; } model.Items.Add(supplier); } return(model); }