public List<BRAND> Search(BRAND Brand, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection) { var result = Context.BRAND.AsQueryable(); if (Brand != null) { if (!String.IsNullOrEmpty(Brand.Name)) { result = result.Where(b => b.Name.Contains(Brand.Name)); } if (!String.IsNullOrEmpty(Brand.ShowName)) { result = result.Where(b => b.ShowName.Contains(Brand.ShowName)); } if (!String.IsNullOrEmpty(Brand.Description)) { result = result.Where(b => b.Description.Contains(Brand.Description)); } if (!String.IsNullOrEmpty(Brand.Email)) { result = result.Where(b => b.Email.Contains(Brand.Email)); } } TotalRecords = result.Count(); GenericSorterCaller<BRAND> sorter = new GenericSorterCaller<BRAND>(); result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? DEFAULT_ORDER_EXP : OrderExp, SortDirection); // pagination return result.Skip(PageIndex * PageSize).Take(PageSize).ToList(); }
protected void btnSave_Click(object sender, EventArgs e) { if (IsValid) { //Save Brand BRAND br = new BRAND(); br.Name = txtName.Text; br.ShowName = txtShowName.Text; br.Website = txt_web.Text; br.Telephone = txt_tel.Text; br.Email = txtEmail.Text; br.Description = txtDesc.Text; br.Contact = txt_contact.Text; br.Shop = chkShop.Checked; br.Address = txtAddress.Text; int id = 0; lblErrors.Visible = true; lblErrors.ForeColor = Color.Green; string operation = String.Empty; try { if (!String.IsNullOrWhiteSpace(ID.Value) && Int32.TryParse(ID.Value, out id) && id != 0) { br.ID = id; ApplicationContext.Current.Brands.Update(br); operation = "updated"; } else { ApplicationContext.Current.Brands.Insert(br); operation = "inserted"; ID.Value = br.ID.ToString(); } lblErrors.Text = "Brand " + operation + " correctly."; } catch (Exception ex) { // TODO log error lblErrors.ForeColor = Color.Red; lblErrors.Text = "Error occurred: " + ex.Message; } } }
private void FixupBRAND(BRAND previousValue) { if (previousValue != null && previousValue.CAMPAIGN.Contains(this)) { previousValue.CAMPAIGN.Remove(this); } if (BRAND != null) { if (!BRAND.CAMPAIGN.Contains(this)) { BRAND.CAMPAIGN.Add(this); } if (BrandID != BRAND.ID) { BrandID = BRAND.ID; } } }
public void Delete(BRAND delBrand) { Context.BRAND.Attach(delBrand); Context.DeleteObject(delBrand); //Context.SaveChanges(); }
public void DeleteById(int id) { BRAND obj = new BRAND() { ID = id }; Delete(obj); }
public void Insert(BRAND newBrand) { Context.BRAND.AddObject(newBrand); //Context.SaveChanges(); }
public void Update(BRAND upBrand) { Context.BRAND.Attach(upBrand); Context.ObjectStateManager.ChangeObjectState(upBrand, System.Data.EntityState.Modified); //int countRowUpdate = Context.SaveChanges(); }
public void Delete(BRAND Brand) { _brandDAO.Delete(Brand); Context.SaveChanges(); }
public void Update(BRAND Brand) { _brandDAO.Update(Brand); Context.SaveChanges(); }
public void Insert(BRAND Brand) { _brandDAO.Insert(Brand); Context.SaveChanges(); }
public List<BRAND> Search(BRAND Brand, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection) { return _brandDAO.Search(Brand, PageSize, PageIndex, out TotalRecords, OrderExp, SortDirection); }