private void InitCountryGrid() { BOMarket mktBo = (BOMarket)m_bo; if (base.FormMode == NanCrm.FormMode.Add) { mktBo.Init(); } UpdateData(false); objList.DataSourceType = typeof(CountryMD); //this.olvcName.AspectGetter = delegate(object row) //{ // return "cfl"; //}; //this.olvcName.Renderer = new MappedImageRenderer(new Object[] { "cfl", Resources.ButtonChoose }); objList.SmallImageList = imageList; this.olvcName.ImageGetter = delegate(object row) { return(0); }; MarketMD mkt = (MarketMD)mktBo.GetBOTable(); foreach (int id in mkt.CountryIds) { BOCountry ctyBo = new BOCountry(); ctyBo.GetById(id); m_ctyList.Add((CountryMD)ctyBo.GetBOTable()); } CountryMD cty = new CountryMD(); cty.ID = -1; m_ctyList.Add(cty); objList.SetObjects(m_ctyList); }
public void MapModelToBO() { var mapper = new BOLCountryMapper(); ApiCountryRequestModel model = new ApiCountryRequestModel(); model.SetProperties("A"); BOCountry response = mapper.MapModelToBO(1, model); response.Name.Should().Be("A"); }
public void MapBOToModel() { var mapper = new BOLCountryMapper(); BOCountry bo = new BOCountry(); bo.SetProperties(1, "A"); ApiCountryResponseModel response = mapper.MapBOToModel(bo); response.Id.Should().Be(1); response.Name.Should().Be("A"); }
public void MapEFToBO() { var mapper = new DALCountryMapper(); Country entity = new Country(); entity.SetProperties(1, "A"); BOCountry response = mapper.MapEFToBO(entity); response.Id.Should().Be(1); response.Name.Should().Be("A"); }
public void MapBOToEF() { var mapper = new DALCountryMapper(); var bo = new BOCountry(); bo.SetProperties(1, "A"); Country response = mapper.MapBOToEF(bo); response.Id.Should().Be(1); response.Name.Should().Be("A"); }
private bool btnOk_Clicking(object sender, EventArgs e) { if (this.FormMode == FormMode.Ok) { return(true); } IList obj = (IList)objList.Objects; BOCountry objCty = (BOCountry)m_bo; objCty.SetDataList(obj.Cast <CountryMD>().Where(x => x.ID > 0 && !string.IsNullOrWhiteSpace(x.Name)).ToList(), objList.RemovedObjects); return(objCty.UpdateBatch()); }
public void MapBOToModelList() { var mapper = new BOLCountryMapper(); BOCountry bo = new BOCountry(); bo.SetProperties(1, "A"); List <ApiCountryResponseModel> response = mapper.MapBOToModel(new List <BOCountry>() { { bo } }); response.Count.Should().Be(1); }
private bool IsValidCountryName(string name) { BOCountry ctyBo = new BOCountry(); IList list = ctyBo.GetDataList(); var find = list.Cast <JObject>().ToList().Find(x => x.ConvertToTarget <CountryMD>().Name == name); if (find == null) { return(false); } return(true); }
private void objList_CellEditFinishing(object sender, CellEditEventArgs e) { if (e.ListViewItem.Index == objList.Items.Count - 1) { if (e.Cancel || string.IsNullOrWhiteSpace(e.NewValue.ToString())) { return; } BOCountry bo = new BOCountry(); bo.GetByName(e.NewValue.ToString()); //objList.GetItem(e.ListViewItem.Index).RowObject = bo.GetBOTable(); //e.ListViewItem.RowObject = (CountryMD)bo.GetBOTable(); CountryMD old = (CountryMD)e.ListViewItem.RowObject; old.CopyFrom(bo.GetBOTable()); //objList.RefreshItem(e.ListViewItem); CountryMD obj = (CountryMD)objList.AddEmptyRow(); int maxIdInDb = BusinessObject.GetBONextID(BOIDEnum.Country); int maxIdOfUi = objList.Objects.Cast <CountryMD>().ToList().Max(x => x.ID); obj.ID = Math.Max(maxIdInDb, maxIdOfUi) + 1; } }
public static BusinessObject GetBO(BOIDEnum boid) { BusinessObject bo = null; switch (boid) { case BOIDEnum.BOSequence: bo = new BOSequence(); break; case BOIDEnum.Country: bo = new BOCountry(); break; case BOIDEnum.ProductGroup: bo = new BOProductGroup(); break; case BOIDEnum.Market: bo = new BOMarket(); break; case BOIDEnum.MarketDetail: bo = new BOMarketDetail(); break; case BOIDEnum.SearchPlantf: bo = new BOBPSearchPlan(); break; case BOIDEnum.Texture: bo = new BOTexture(); break; case BOIDEnum.KeyWord: bo = new BOKeyWord(); break; case BOIDEnum.KeyWordList: bo = new BOKWList(); break; case BOIDEnum.Product: bo = new BOProduct(); break; case BOIDEnum.PSearchPlan: bo = new BOProductSearchPlan(); break; case BOIDEnum.PSearchResult: bo = new BOBPSearchResult(); break; case BOIDEnum.BP: bo = new BOBP(); break; default: break; } bo.Init(); return(bo); }