public static bool AddCategory(CategoryBO categoryBO) { EarningAndDeductionsDAS earningAndDeductionsDAS = new EarningAndDeductionsDAS(); int result = earningAndDeductionsDAS.AddNewCategory(categoryBO); return(result > 0); }
private void ProcessForm(int categoryId, bool isDelete) { try { using (TransactionScope ts = new TransactionScope()) { CategoryBO objCategory = new CategoryBO(this.ObjContext); if (categoryId > 0) { objCategory.ID = categoryId; objCategory.GetObject(); objCategory.Name = this.txtCategoryName.Text; objCategory.Description = this.txtDescription.Text; if (isDelete) { objCategory.Delete(); } } else { objCategory.Name = this.txtCategoryName.Text; objCategory.Description = this.txtDescription.Text; objCategory.Add(); } this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { //throw ex; } }
/// <summary> /// To GetCategory details from database /// </summary> /// <returns></returns> public CategoryList GetCategory() { OracleConnection cnn = new OracleConnection(AppConfiguration.ConnectionString); OracleCommand cmd; string proc = "USP_MST_SEL_CATEGORY"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("Sp_recordset", Oracle.DataAccess.Client.OracleDbType.RefCursor).Direction = ParameterDirection.Output; cmd.Connection.Open(); OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); CategoryBO CategoryBOobj = null; CategoryList CategoryListobj = new CategoryList(); while (dr.Read()) { CategoryBOobj = new CategoryBO(); CategoryBOobj.BGT_CATEGORYID = Convert.ToInt32(dr.GetValue(dr.GetOrdinal("BGT_CATEGORYID"))); CategoryBOobj.BGT_CATEGORYNAME = dr.GetString(dr.GetOrdinal("BGT_CATEGORYNAME")); CategoryBOobj.ISDELETED = dr.GetString(dr.GetOrdinal("ISDELETED")); CategoryListobj.Add(CategoryBOobj); } dr.Close(); return(CategoryListobj); }
/// <summary> /// To get category details based on ID from database /// </summary> /// <param name="CATEGORYID"></param> /// <returns></returns> public CategoryBO GetCategoryById(int CATEGORYID) { OracleConnection cnn = new OracleConnection(AppConfiguration.ConnectionString); OracleCommand cmd; string proc = "USP_MST_GET_CATEGORY"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("BGT_CATEGORYID_", CATEGORYID); cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output; cmd.Connection.Open(); OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); CategoryBO CategoryBOobj = null; CategoryList CategoryListobj = new CategoryList(); CategoryBOobj = new CategoryBO(); while (dr.Read()) { if (ColumnExists(dr, "BGT_CATEGORYNAME") && !dr.IsDBNull(dr.GetOrdinal("BGT_CATEGORYNAME"))) { CategoryBOobj.BGT_CATEGORYNAME = dr.GetString(dr.GetOrdinal("BGT_CATEGORYNAME")); } if (ColumnExists(dr, "BGT_CATEGORYID") && !dr.IsDBNull(dr.GetOrdinal("BGT_CATEGORYID"))) { CategoryBOobj.BGT_CATEGORYID = Convert.ToInt32(dr.GetValue(dr.GetOrdinal("BGT_CATEGORYID"))); } } dr.Close(); return(CategoryBOobj); }
private void ToolStripMenuItem_Click(object sender, EventArgs e) { var msi = sender as ToolStripMenuItem; foreach (var item in menuToolStripMenuItem.DropDownItems) { var myItem = item as ToolStripMenuItem; myItem.Checked = false; } msi.Checked = true; if (msi.Text == "Shippers") { ShipperBO sb = new ShipperBO(); dgvMain.DataSource = null; dgvMain.DataSource = sb.GetList(); CurrentPoco = CurrentPoco.Shipper; } else if (msi.Text == "Categories") { CategoryBO cb = new CategoryBO(); dgvMain.DataSource = null; dgvMain.DataSource = cb.GetList(); CurrentPoco = CurrentPoco.Category; } }
private void textBox1_TextChanged(object sender, EventArgs e) { var searchText = textBox1.Text.ToLower(); switch (CurrentPoco) { case CurrentPoco.Shipper: ShipperBO sb = new ShipperBO(); var list = sb.GetList(); var newList = list.Where(x => x.CompanyName.ToLower().Contains(searchText)).ToList(); dgvMain.DataSource = null; dgvMain.DataSource = newList; break; case CurrentPoco.Category: CategoryBO cb = new CategoryBO(); var list2 = cb.GetList(); var newList2 = list2.Where(x => x.CategoryName.ToLower().Contains(searchText)).ToList(); dgvMain.DataSource = null; dgvMain.DataSource = newList2; break; case CurrentPoco.ApplicationUser: ApplicationUserBO ub = new ApplicationUserBO(); var list3 = ub.GetList(); var newList3 = list3.Where(x => x.UserName.ToLower().Contains(searchText)).ToList(); dgvMain.DataSource = null; dgvMain.DataSource = newList3; break; default: break; } }
public int AddNewCategory(CategoryBO categoryBO)//arguments are required. Fill them later when BO is created. { SQLHelper helper = SQLHelper.GetInstance(this.connectionString); int numberOfRowImpacted = 0; try { helper.OpenConnection(); //query to add new category query = $@"INSERT INTO [dbo].[Category] ( [category_code] ,[category_name] ) VALUES ( {categoryBO.CategoryID.Trim()} ,{categoryBO.CategoryName.Trim().ToUpper()}) GO"; numberOfRowImpacted = helper.ExecuteNonQuery(query); } catch (Exception ex) { numberOfRowImpacted = -1; Console.WriteLine(ex.Message); dbErrMsg = ex.Message; } finally { helper.CloseConnection(); } return(numberOfRowImpacted); }
public int UpdateCategory(CategoryBO categoryBO) { SQLHelper helper = SQLHelper.GetInstance(this.connectionString); int numberOfRowImpacted = 0; try { helper.OpenConnection(); //query to add new category query = $@"UPDATE [dbo].[Category] SET [category_code] = '{categoryBO.CategoryID.Trim()}' ,[category_name] = '{categoryBO.CategoryName.Trim().ToUpper()}'"; numberOfRowImpacted = helper.ExecuteNonQuery(query); } catch (Exception ex) { numberOfRowImpacted = -1; Console.WriteLine(ex.Message); dbErrMsg = ex.Message; } finally { helper.CloseConnection(); } return(numberOfRowImpacted); }
public IActionResult Get(int id) { CategoryBO categoryBO; Category category; ObjectResult response; try { _log.LogInformation($"Starting Get( {id} )"); categoryBO = new CategoryBO(_loggerFactory, _config); category = categoryBO.Get(id); if (category != null) { response = Ok(category); } else { response = NotFound(string.Empty); } _log.LogInformation($"Finishing Get( {id} )"); } catch (Exception ex) { _log.LogError(ex.Message); response = StatusCode(500, ex.Message); } return(response); }
// GET: Category public ActionResult Index() { CategoryBO cbo = new CategoryBO(); var result = cbo.GetList(); return(View(result)); }
public IActionResult Get(string name = null) { CategoryBO categoryBO; List <Category> categorys; ObjectResult response; try { _log.LogInformation("Starting Get()"); categoryBO = new CategoryBO(_loggerFactory, _config); categorys = categoryBO.Get(name); response = Ok(categorys); _log.LogInformation($"Finishing Get() with '{categorys.Count}' results"); } catch (Exception ex) { _log.LogError(ex.Message); response = StatusCode(500, ex.Message); } return(response); }
public IActionResult Put(int id, Category category) { CategoryBO categoryBO; ObjectResult response; try { _log.LogInformation($"Starting Put( {id}, '{JsonConvert.SerializeObject(category, Formatting.None)}')"); categoryBO = new CategoryBO(_loggerFactory, _config); category.ID = id; category = categoryBO.Update(category); response = Ok(category); _log.LogInformation($"Finishing Put( {id} )"); } catch (Exception ex) { _log.LogError(ex.Message); response = StatusCode(500, ex.Message); } return(response); }
public IActionResult Post([FromBody] Category category) { CategoryBO categoryBO; ObjectResult response; try { _log.LogInformation($"Starting Post('{JsonConvert.SerializeObject(category, Formatting.None)}')"); categoryBO = new CategoryBO(_loggerFactory, _config); category = categoryBO.Insert(category); response = Ok(category); _log.LogInformation($"Finishing Post"); } catch (Exception ex) { _log.LogError(ex.Message); response = StatusCode(500, ex.Message); } return(response); }
public List <CategoryBO> GetBestCategories() { List <CategoryBO> list = new List <CategoryBO>(); sqlCommand = new SqlCommand() { Connection = connectionHelper.connection, CommandType = CommandType.StoredProcedure, CommandText = "GetBestCategoriesSP", }; connectionHelper.connection.Open(); SqlDataReader sqlReader = sqlCommand.ExecuteReader(); if (sqlReader.HasRows) { while (sqlReader.Read()) { var model = new CategoryBO() { Category = sqlReader["Category"] as string, Size = Convert.ToInt32(sqlReader["Size"]) }; list.Add(model); } } connectionHelper.connection.Close(); return(list); }
private void btnSave_Click(object sender, EventArgs e) { CategoryBO bo = new CategoryBO(); if (Mode == FormMode.Add) { Category cat = new Category(); cat.CategoryName = txtCatName.Text; cat.Description = txtDescription.Text; cat.Picture = openFileDialog1.FileName; if (bo.Insert(cat)) { MessageBox.Show("Success"); } else { MessageBox.Show("Error"); } } else { SelectedCategory.CategoryName = txtCatName.Text; SelectedCategory.Description = txtDescription.Text; SelectedCategory.Picture = openFileDialog1.FileName; if (bo.Update(SelectedCategory)) { MessageBox.Show("Successfully updated"); } else { MessageBox.Show("There is an error during update operation"); } } }
public CategoryBO Put(Int64 id, [FromBody] CategoryBO category) { if (id != category.Id) { return(null); } return(_category.Update(category)); }
public ActionResult <CategoryBO> Post([FromBody] CategoryBO category) { if (category == null) { return(BadRequest()); } return(Ok(_categoryService.Create(category))); }
// POST api/<controller> public void Post([FromBody] string value) { var categoryBO = new CategoryBO(); categoryBO.AddCategory(new Category { Id = 0, Name = "Test", IsActive = true }); }
public CategoryBO Update(CategoryBO cat) { Category category = converter.Convert(cat); _context.Entry(category).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); return(converter.Convert(category)); }
public static bool UpdateCategory(CategoryBO categoryBO) { EarningAndDeductionsDAS earningAndDeductionsDAS = new EarningAndDeductionsDAS(); int numberOfRowImpacted = 0; numberOfRowImpacted = earningAndDeductionsDAS.UpdateCategory(categoryBO); return(numberOfRowImpacted > 0); }
public CategoryBO Create(CategoryBO cat) { var category = converter.Convert(cat); _context.Categories.Add(category); _context.SaveChanges(); return(converter.Convert(category)); }
/// <summary> /// used to fetch details /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GetCategoryName() { CategoryBO objCategory = (new CategoryBLL()).GetCategoryById(Convert.ToInt32(ViewState["BGT_CATEGORYID"])); if (objCategory != null) { Master.PageHeader = "Subcategories for " + objCategory.BGT_CATEGORYNAME; } }
public CategoryBO Create(CategoryBO category) { using (var uow = _facade.UnitOfWork) { // TODO check if entity is valid, and throw errors if not var categoryCreated = uow.CategoryRepo.Create(_categoryConv.Convert(category)); uow.Complete(); return(_categoryConv.Convert(categoryCreated)); } }
private List <KeyValuePair <int, string> > PopulateCategories(string MenuItem) { List <KeyValuePair <int, string> > lstCategoryItems = new List <KeyValuePair <int, string> >(); PatternBO objPattern = new PatternBO(); objPattern.IsActiveWS = true; List <int> lstCategoryIDs = new List <int>(); //1 MENS //2 LADIES //3 UNISEX //4 N/A //5 //1 ADULT //2 YOUTH NULL //3 INFANTS NULL //4 N/A NULL //5 FULL RANGE NULL //7 BESPOKE switch (MenuItem) { case "Mens": lstCategoryIDs = PatternCategorySource.Where(m => m.Gender == 1 && m.AgeGroup == 1).Select(m => m.CoreCategory).Distinct().ToList(); break; case "Ladies": lstCategoryIDs = PatternCategorySource.Where(m => m.Gender == 2 && m.AgeGroup == 1).Select(m => m.CoreCategory).Distinct().ToList(); break; case "Unisex": lstCategoryIDs = PatternCategorySource.Where(m => m.Gender == 3).Select(m => m.CoreCategory).Distinct().ToList(); break; case "Youth": lstCategoryIDs = PatternCategorySource.Where(m => m.AgeGroup == 2).Select(m => m.CoreCategory).Distinct().ToList(); break; case "Other": lstCategoryIDs = PatternCategorySource.Where(m => m.Gender > 3 || m.AgeGroup > 2).Select(m => m.CoreCategory).Distinct().ToList(); break; default: break; } foreach (int CatID in lstCategoryIDs) { CategoryBO objCat = this.CategorySource.Where(m => m.ID == CatID).SingleOrDefault(); lstCategoryItems.Add(new KeyValuePair <int, string>(CatID, objCat.Name)); } return(lstCategoryItems.OrderBy(m => m.Value).ToList()); }
// GET: Tables public ActionResult Index() { ShipperBO sbo = new ShipperBO(); CategoryBO cbo = new CategoryBO(); var shippers = sbo.GetList(); var categories = cbo.GetList(); TablesViewModel tb = new TablesViewModel(); tb.Shippers = shippers; tb.Categories = categories; return(View(tb)); }
public List <Category> GetCategoryById(int SuperCategoryId) { try { CategoryBO categoryBO = new CategoryBO(); return(categoryBO.GetCategoryById(SuperCategoryId)); } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "CampaignMod"); throw; } }
private void PopulateDataGrid() { // Hide Controls this.dvEmptyContent.Visible = false; this.dvDataContent.Visible = false; this.dvNoSearchResult.Visible = false; // Search text string searchText = this.txtSearch.Text.ToLower().Trim(); // Populate Category CategoryBO objCategory = new CategoryBO(); List <CategoryBO> lstCategory = new List <CategoryBO>(); if ((searchText != string.Empty) && (searchText != "search")) { lstCategory = (from o in objCategory.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList() where o.Name.ToLower().Contains(searchText) || (o.Description != null ? o.Description.ToLower().Contains(searchText) : false) select o).ToList(); } else { lstCategory = objCategory.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList(); } if (lstCategory.Count > 0) { this.RadGridCategories.AllowPaging = (lstCategory.Count > this.RadGridCategories.PageSize); this.RadGridCategories.DataSource = lstCategory; this.RadGridCategories.DataBind(); Session["CategoriesDetails"] = lstCategory; this.dvDataContent.Visible = true; } else if ((searchText != string.Empty && searchText != "search")) { this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty); this.dvDataContent.Visible = true; this.dvNoSearchResult.Visible = true; } else { this.dvEmptyContent.Visible = true; this.btnAddCategories.Visible = false; } this.RadGridCategories.Visible = (lstCategory.Count > 0); }
public CategoryBO Update(CategoryBO category) { using (var uow = _facade.UnitOfWork) { var categoryFromDb = uow.CategoryRepo.Get(category.Id); if (categoryFromDb == null) { return(null); } categoryFromDb.Name = category.Name; uow.Complete(); return(_categoryConv.Convert(categoryFromDb)); } }
// GET: Categories/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Category category = new CategoryBO().Get(id); if (category == null) { return(HttpNotFound()); } return(View(category)); }
//get all category lists public List <CategoryBO> getCategoryList() { var qry = (from x in context.Categories select new { x.CategoryName, x.CategoryID }).ToList(); List <CategoryBO> lst = new List <CategoryBO>(); foreach (var q in qry) { CategoryBO c = new CategoryBO(); c.CategoryID = q.CategoryID; c.CategoryName = q.CategoryName; lst.Add(c); } return(lst); }