public async Task <IActionResult> GetAllWithDividers(string companyID, int listCount = -1, int pageNumber = 0, string orderBy = "name asc") { List <EDeliveryProduct> list = SDeliveryProducts.GetAll(companyID, listCount, pageNumber, orderBy); List <EDeliveryProduct> returnList = new List <EDeliveryProduct>(); list = list.OrderBy(x => x.categoryID).ToList(); for (int i = 0; i < list.Count; i++) { var eProduct = list.ElementAt(i); string categoryName = ""; if (!string.IsNullOrEmpty(eProduct.categoryID)) { var eCategory = await SDeliveryProductsCategories.GetByID(eProduct.categoryID); categoryName = eCategory.name; } if (!returnList.Any()) { returnList.Add(new EDeliveryProduct { categoryID = eProduct.categoryID, isCategory = true, categoryName = categoryName }); } else if (returnList.Last().categoryID != eProduct.categoryID) { returnList.Add(new EDeliveryProduct { categoryID = eProduct.categoryID, isCategory = true, categoryName = categoryName }); } returnList.Add(eProduct); } return(Ok(returnList)); }
//todo recolocar [RestXInPeaceGet(1, "List<List<EDeliveryProduct>> GetAllDividedByCategory(segment string companyID, optional int listCount=-1, optional int pageNumber=0,optional string orderBy='name asc')")] public IActionResult GetAllDividedByCategory(string companyID, int listCount = -1, int pageNumber = 0, string orderBy = "name asc") { List <EDeliveryProduct> list = SDeliveryProducts.GetAll(companyID, listCount, pageNumber, orderBy); List <List <EDeliveryProduct> > returnList = new List <List <EDeliveryProduct> >(); list = list.OrderBy(x => x.categoryID).ToList(); returnList = list.GroupBy(item => item.categoryID) .Select(group => group.ToList()) .ToList(); return(Ok(returnList)); }
public async Task <IActionResult> GetAll(string companyID, int listCount = -1, int pageNumber = 0, string orderBy = "name asc") { var list = SDeliveryProducts.GetAll(companyID, listCount, pageNumber, orderBy); foreach (EDeliveryProduct eDeliveryProduct in list) { if (string.IsNullOrEmpty(eDeliveryProduct.categoryID)) { continue; } var eCategory = await SDeliveryProductsCategories.GetByID(eDeliveryProduct.categoryID); eDeliveryProduct.categoryName = eCategory.name; } return(Ok(list)); }
public IActionResult GetCount(string companyID) { return(Ok(SDeliveryProducts.GetCount(companyID))); }
public async Task <IActionResult> Save([FromBody] EDeliveryProduct eDeliveryProduct) { string id = await SDeliveryProducts.Save(eDeliveryProduct); return(Ok(id)); }
public async Task <IActionResult> Remove(string id) { var ok = await SDeliveryProducts.Remove(id); return(Ok(ok)); }
public async Task <IActionResult> GetByID(string id) { EDeliveryProduct eDeliveryProduct = await SDeliveryProducts.GetByID(id); return(Ok(eDeliveryProduct)); }