public string UpdateProdSubCategory(ProdSubcategory orduser, List<int> prodID) { TransactionManager transaction = null; try { ProdCategoryMapping objprodctgmapping = new ProdCategoryMapping(); ProdCategoryMapping objprodctgmapping1 = new ProdCategoryMapping(); TList<ProdCategoryMapping> objprodctgmappinglist = new TList<ProdCategoryMapping>(); TList<ProdCategoryMapping> objprodctgmappinglist1 = new TList<ProdCategoryMapping>(); objprodctgmappinglist1 = GetAllProdCategoriesmapping(orduser.Id); transaction = DataRepository.Provider.CreateTransaction(); transaction.BeginTransaction(); if (DataRepository.ProdSubcategoryProvider.Update(orduser)) { foreach (var q in objprodctgmappinglist1) { objprodctgmapping1 = null; objprodctgmapping1 = GetProdmappcategoryByID(Convert.ToInt32(q.Id)); if (DataRepository.ProdCategoryMappingProvider.Delete(objprodctgmapping1)) { // Show proper message } else { return "Information could not be Delete."; } } foreach (int id in prodID) { objprodctgmapping.IsActive = true; objprodctgmapping.CategoryId = id; objprodctgmapping.SubCategoryId = orduser.Id; objprodctgmapping.CreatedDate = DateTime.Now; if (DataRepository.ProdCategoryMappingProvider.Insert(objprodctgmapping)) { // Show proper message } else { return "Information could not be saved."; } } } else { return "Information could not be saved."; } transaction.Commit(); return "Information Update successfully."; } catch (Exception e) { transaction.Rollback(); return "Information could not be saved.Please contact Administrator."; } }
public ProdCategoryMapping GetProdmappcategoryByID(int id) { Objprodcategorymapp = null; Objprodcategorymapp = DataRepository.ProdCategoryMappingProvider.GetById(id); return Objprodcategorymapp; }
public string insertProdSubCategory(ProdSubcategory orduser, List<int> prodID) { TransactionManager transaction = null; try { ProdCategoryMapping objprodctgmapping = new ProdCategoryMapping(); transaction = DataRepository.Provider.CreateTransaction(); transaction.BeginTransaction(); orduser.IsActive = true; if (DataRepository.ProdSubcategoryProvider.Insert(orduser)) { foreach (int id in prodID) { objprodctgmapping.IsActive = true; objprodctgmapping.CategoryId = id; objprodctgmapping.SubCategoryId = orduser.Id; objprodctgmapping.CreatedDate = DateTime.Now; if (DataRepository.ProdCategoryMappingProvider.Insert(objprodctgmapping)) { // Show proper message } else { return "Information could not be saved."; } } } transaction.Commit(); return "Information Insert successfully."; } catch (Exception e) { transaction.Rollback(); return "Information could not be saved.Please contact Administrator."; } }