public ChannelPackagingDTO Map(ChannelPackaging channelPackaging) { if (channelPackaging == null) return null; return Mapper.Map<ChannelPackaging, ChannelPackagingDTO>(channelPackaging); }
private void AddChannelPackagingPlaceholders() { int count = _productPackagingRepository.GetAll().Count() * _outletTypeRepository.GetAll().Count(); if (count != _channelPackagingRepository.GetAll().Count()) { List<ChannelPackaging> cpitemsdb = null; cpitemsdb = _channelPackagingRepository.GetAll().ToList(); var cpToDeactivate = cpitemsdb.Where(n => n.OutletType == null || n.Packaging == null); if (cpToDeactivate.Count() > 0) { foreach (var item in cpToDeactivate) { if (item.IsChecked) item.IsChecked = false; _channelPackagingRepository.SetInactive(item); } cpitemsdb.Clear(); cpitemsdb = _channelPackagingRepository.GetAll().ToList(); } List<CPItem> cpitems = new List<CPItem>(); foreach (var pp in _productPackagingRepository.GetAll()) { foreach (var outlet in _outletTypeRepository.GetAll()) { Guid ppid = pp.Id; Guid oid = outlet.Id; Guid dbid = Guid.Empty; bool ischecked = false; ChannelPackaging existing = null; try { existing = cpitemsdb.First(n => n.OutletType.Id == oid && n.Packaging.Id == ppid); } catch { //deactivate this ChChanh //if isChecked, unCheck } if (existing != null) { var dbitem = cpitemsdb.First(n => n.OutletType.Id == oid && n.Packaging.Id == ppid); dbid = dbitem.Id; ischecked = dbitem.IsChecked; } //if (cpitemsdb.Any(n => n.OutletType.Id == oid && n.Packaging.Id == ppid)) // { // var dbitem = cpitemsdb.First(n => n.OutletType.Id == oid && n.Packaging.Id == ppid); // dbid = dbitem.Id; // ischecked = dbitem.IsChecked; // } cpitems.Add(new CPItem {Id = dbid, Checked = ischecked, OutletTypeId = oid, PackagingId = ppid}); } } foreach (var itemtoadd in cpitems.Where(n => n.Id == Guid.Empty)) { ChannelPackaging cp = new ChannelPackaging(Guid.NewGuid()) { IsChecked = false, OutletType = _outletTypeRepository.GetById(itemtoadd.OutletTypeId), Packaging = _productPackagingRepository.GetById(itemtoadd.PackagingId) }; _channelPackagingRepository.Save(cp); } } }
protected Guid AddChannelPacks(Guid ProductPackaging, Guid OutletType, bool IsChecked) { ChannelPackaging channelPackaging = new ChannelPackaging(Guid.NewGuid()) { Packaging = _productPackagingRepository.GetById(ProductPackaging), OutletType = _outletTypeRepository.GetById(OutletType), IsChecked = IsChecked }; channelPackaging._SetStatus(EntityStatus.Active); return _channelPackagingRepository.Save(channelPackaging); }
public void Savex(ChannelPackagingViewModel cpvm) { ChannelPackaging cp = new ChannelPackaging(cpvm.ChannelPId) { OutletType = _outletTypeRepository.GetById(cpvm.OutletTypeId), Packaging = _productPackagingRepository.GetById(cpvm.PackageId), IsChecked = cpvm.IsChecked }; _channelPackagingRepository.Save(cp); }
private void AssertChannelPackaging(ChannelPackaging assetCategory, ChannelPackaging savedAsseCartegory) { Assert.AreEqual(assetCategory.OutletType.Code, savedAsseCartegory.OutletType.Code); Assert.AreEqual(assetCategory.Packaging.Code, savedAsseCartegory.Packaging.Code); Assert.AreEqual(assetCategory.IsChecked, savedAsseCartegory.IsChecked); Assert.AreEqual(assetCategory._Status, EntityStatus.Active); }