public List <ProductCategoryResponse.InsertData> InsertProductCategory(ProductCategoryTable objProductCategoryTable) { List <ProductCategoryResponse.InsertData> getProductCategoryList = new List <ProductCategoryResponse.InsertData>(); try { var values = new { CategoryName = objProductCategoryTable.CategoryName, Action = "1" }; using (IDbConnection con = new SqlConnection(ConString.GetConnectionString)) { if (con.State == ConnectionState.Closed) { con.Open(); } getProductCategoryList = con.Query <ProductCategoryResponse.InsertData>("[dbo].[InsertOrUpdateOrDeleteProductCategory]", values, commandType: CommandType.StoredProcedure).ToList(); } return(getProductCategoryList); } catch (Exception) { return(getProductCategoryList); } }
public ActionResult Put(ProductCategoryUpdateParam objProductCategoryUpdateParam) { try { if (objAutorized.ValidateTokenResult == null) { return(Ok(new CommonResponse() { error_code = Convert.ToInt32(ErrorCode.Failure), message = "Invalid access." })); } if (objAutorized.ValidateTokenResult.isValid == false) { return(Ok(new CommonResponse() { error_code = Convert.ToInt32(ErrorCode.Failure), message = objAutorized.ValidateTokenResult.error_message })); } ProductCategoryTable objProductCategory = new ProductCategoryTable(); objProductCategory.ProdCatId = objProductCategoryUpdateParam.ProdCatId; objProductCategory.CategoryName = objProductCategoryUpdateParam.CategoryName; ValidationContext vc = new ValidationContext(objProductCategory); var validationsResults = new List <ValidationResult>(); bool correct = Validator.TryValidateObject(objProductCategory, vc, validationsResults, true); if (!correct) { string errorMessage = ""; foreach (var item in validationsResults.Select(ov => ov.ErrorMessage)) { errorMessage = string.Concat(errorMessage, item); } return(Ok(new CommonResponse() { error_code = Convert.ToInt32(ErrorCode.Failure), message = errorMessage })); } ProductCategoryDBAccess obj = ProductCategoryDBAccess.getInstance; List <ProductCategoryResponse.UpdateData> objListData = obj.UpdateProductCategory(objProductCategory); if (objListData.Count == 0) { return(Ok(new CommonResponse() { error_code = Convert.ToInt32(ErrorCode.Failure), message = "No data update." })); } if (objListData[0].RowEffect == 0) { return(Ok(new CommonResponse() { error_code = Convert.ToInt32(ErrorCode.Failure), message = objListData[0].message })); } return(Ok(new ProductCategoryResponse.UpdateData() { error_code = Convert.ToInt32(ErrorCode.Success), message = objListData[0].message, RowEffect = objListData[0].RowEffect })); } catch (Exception ex) { return(Ok(new CommonResponse() { error_code = Convert.ToInt32(ErrorCode.Failure), message = ex.Message })); } }
public IQueryable <CarpetIndexViewModel> GetCarpetListForIndex(bool sample) { //return (from p in db.Products // join t in db.ProductCategory on p.ProductCategoryId equals t.ProductCategoryId into table // from tab in table.DefaultIfEmpty() // join t1 in db.ProductTypes on tab.ProductTypeId equals t1.ProductTypeId into table1 // from tab1 in table1.DefaultIfEmpty() // where tab1.IsCustomUI != null // orderby p.ProductName, p.ProductGroup.ProductGroupName // select new CarpetIndexViewModel // { // ProductId = p.ProductId, // ProductName = p.ProductName, // ProductGroupName = p.ProductGroup.ProductGroupName, // ProductCategoryId = tab.ProductCategoryId, // ProductCategoryName = tab.ProductCategoryName, // ProductGroupId = p.ProductGroupId, // ProductDesignName=p.ProductDesign.ProductDesignName, // } // ); //return (from p in db.ProductGroups // join t in db.FinishedProduct on p.ProductGroupId equals t.ProductGroupId into FinishedProductTable // from FinishedProductTab in FinishedProductTable // join t1 in db.ProductCategory on FinishedProductTable.FirstOrDefault().ProductCategoryId equals t1.ProductCategoryId into table1 // from tab1 in table1 // join t2 in db.ProductTypes on tab1.ProductTypeId equals t2.ProductTypeId into table2 // from tab2 in table2 // where tab2.ProductTypeName==ProductTypeConstants.Rug // orderby p.ProductGroupName // select new CarpetIndexViewModel // { // ProductId = FinishedProductTab.ProductId, // ProductName = FinishedProductTab.ProductName, // ProductGroupName = p.ProductGroupName, // ProductCategoryId = tab1.ProductCategoryId, // ProductCategoryName = tab1.ProductCategoryName, // ProductGroupId = p.ProductGroupId, // ProductDesignName = FinishedProductTab.ProductDesign.ProductDesignName, // } // ); int typeid = new ProductTypeService(_unitOfWork).GetProductTypeByName(ProductTypeConstants.Rug).ProductTypeId; //return (from p in db.ProductGroups // join t in db.FinishedProduct on p.ProductGroupId equals t.ProductGroupId // where p.ProductTypeId == typeid // group t by new { t.ProductGroupId, t.ProductGroup.ProductGroupName } into table // orderby table.Key.ProductGroupName // select new CarpetIndexViewModel // { // ProductGroupId = table.Key.ProductGroupId ?? 0, // ProductGroupName = table.Key.ProductGroupName, // ProductCategoryName = table.FirstOrDefault().ProductCategory.ProductCategoryName, // ProductDesignName = table.FirstOrDefault().ProductDesign.ProductDesignName, // ProductCollectionName = table.FirstOrDefault().ProductCollection.ProductCollectionName // } // ); var DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; var SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; var temp = from Pg in db.ProductGroups join Fp in db.FinishedProduct on Pg.ProductGroupId equals Fp.ProductGroupId into FinishedProductTable from FinishedProductTab in FinishedProductTable.DefaultIfEmpty() join Pc in db.ProductCategory on FinishedProductTab.ProductCategoryId equals Pc.ProductCategoryId into ProductCategoryTable from ProductCategoryTab in ProductCategoryTable.DefaultIfEmpty() join Pd in db.ProductDesigns on FinishedProductTab.ProductDesignId equals Pd.ProductDesignId into ProductDesignTable from ProductDesignTab in ProductDesignTable.DefaultIfEmpty() join PCol in db.ProductCollections on FinishedProductTab.ProductCollectionId equals PCol.ProductCollectionId into ProductCollectionTable from ProductCollectionTab in ProductCollectionTable.DefaultIfEmpty() where Pg.ProductTypeId == typeid && (FinishedProductTab.IsSample == sample || FinishedProductTab == null) && (FinishedProductTab == null || FinishedProductTab.DivisionId == DivisionId) group new { Pg, ProductCategoryTab, ProductDesignTab, ProductCollectionTab } by new { Pg.ProductGroupId, Pg.ProductGroupName } into table orderby table.Key.ProductGroupName select new CarpetIndexViewModel { ProductGroupId = table.Key.ProductGroupId, ProductGroupName = table.Key.ProductGroupName, ProductCategoryName = table.Max(m => m.ProductCategoryTab.ProductCategoryName), ProductDesignName = table.Max(m => m.ProductDesignTab.ProductDesignName), ProductCollectionName = table.Max(m => m.ProductCollectionTab.ProductCollectionName) }; return(temp); }