public async Task <List <GoodsCategory> > LoadGoodsCategoryAsync(List <Company> lstCompanies, List <GoodsCategoryType> lstGoodsCategoryTypes) { var externalService = ExternalServices.GoodsCat; List <GoodsCategory> result = new List <GoodsCategory>(); List <GoodsCategory> lstGoodsCategory = new List <GoodsCategory>(); if (lstCompanies.Count != 0) // check exists company { foreach (var item in lstCompanies) { GoodsCat[] serviceDataInfos = null; try { if (item.GoodsCollection.Count != 0) // check exist company's goods { serviceDataInfos = await eliteClient.GetGoodsCategoryAsync(userName, password, item.RefId); } } catch (Exception ex) { logger.Error(externalService, ex); } lstGoodsCategory = mapper.Map <GoodsCat[], List <GoodsCategory> >(serviceDataInfos); lstGoodsCategory.ForEach(x => { Goods goods = item.GoodsCollection.FirstOrDefault(y => y.RefId == x.GoodsRefId); if (goods != null) { GoodsCategoryType goodsCategoryType = lstGoodsCategoryTypes.FirstOrDefault(y => y.RefId == x.GoodsCategoryTypeRefId); if (goodsCategoryType != null) { x.GoodsId = goods.Id; x.GoodsCatgeoryTypeId = goodsCategoryType.Id; result.Add(x); } else { logger.Warn(externalService, "there isn't any goodsCategoryType by id {0} .", x.GoodsCategoryTypeRefId); } } else { logger.Warn(externalService, "there isn't any goods by id {0}.", x.GoodsRefId); } }); } } else { logger.Warn(externalService, "There isn't any company"); } return(result); }
protected void Page_Load(object sender, EventArgs e) { string strCateId = Request.QueryString["id"]; if (!string.IsNullOrEmpty(strCateId) && int.TryParse(strCateId, out id)) { gc = GoodsCategoryType.findById(id); } if (!IsPostBack) { if (gc != null) { txtCategoryName.Value = gc.CategoryName; txtEName.Value = gc.CategoryEName; txtDesc.Value = gc.Description; } } }
protected void btnSubmit_Click(object sender, EventArgs e) { gc = new GoodsCategoryType(); string categoryName = Request.Form[txtCategoryName.ID].Trim(); if (string.IsNullOrEmpty(categoryName)) { return; } gc.CategoryName = categoryName; gc.CategoryEName = txtEName.Value; gc.Description = txtDesc.Value; if(id != 0) { gc.Id = id; gc.update(); } else { gc.insert(); } }