private void saveFeature(MenuFeatureModel menuFeatureModel) { menuFeatureModel.SelfCheck(); MenuPath1 menuPath1 = Find(menuFeatureModel.ParentId); menuPath1.IsNullThrowException("menuPath1"); MenuFeature menuFeature = MenuFeatureBiz.Find(menuFeatureModel.FeatureId); menuFeature.IsNullThrowException("menuFeature"); if (menuFeature.MenuPath1s.IsNull()) { menuFeature.MenuPath1s = new List <MenuPath1>(); } if (menuPath1.MenuFeatures.IsNull()) { menuPath1.MenuFeatures = new List <MenuFeature>(); } menuFeature.MenuPath1s.Add(menuPath1); menuPath1.MenuFeatures.Add(menuFeature); SaveChanges(); addFeatureToEveryProductWithMenuPath1(menuPath1, menuFeature); }
private List <string> picturesForMenuPath(MenuPath1 mp1, MenuPath2 mp2) { //get all menupaths with mp1 and mp2 mp1.IsNullThrowException(); mp2.IsNullThrowException(); List <MenuPathMain> mpmList = MenuPathMainBiz.FindAll().Where(x => x.MenuPath1Id == mp1.Id && x.MenuPath2Id == mp2.Id).ToList(); if (mpmList.IsNullOrEmpty()) { return(null); } List <string> picList = new List <string>(); foreach (MenuPathMain mpm in mpmList) { List <string> picListFromMpm = picturesForMenuPath(mpm); if (!picListFromMpm.IsNullOrEmpty()) { picList = picList.Concat(picListFromMpm).ToList(); } } return(picList); }
private void fixall(GlobalComment gc) { if (gc.Comment.IsNullOrWhiteSpace()) { return; } gc.UserId.IsNullOrWhiteSpaceThrowException("User is not logged in"); if (!gc.UserId.IsNullOrWhiteSpace()) { ApplicationUser user = _userBiz.Find(gc.UserId); user.IsNullThrowException(); //user.GlobalComments.Add(gc); gc.Name = UserName; } if (!gc.MenuPath1Id.IsNullOrWhiteSpace()) { MenuPath1 m1 = _menuPathMainBiz.MenuPath1Biz.Find(gc.MenuPath1Id); m1.IsNullThrowException(); m1.GlobalComments.Add(gc); return; } if (!gc.MenuPath2Id.IsNullOrWhiteSpace()) { MenuPath2 m2 = _menuPathMainBiz.MenuPath2Biz.Find(gc.MenuPath2Id); m2.IsNullThrowException(); m2.GlobalComments.Add(gc); return; } if (!gc.MenuPath3Id.IsNullOrWhiteSpace()) { MenuPath3 m3 = _menuPathMainBiz.MenuPath3Biz.Find(gc.MenuPath3Id); m3.IsNullThrowException(); m3.GlobalComments.Add(gc); } if (!gc.ProductId.IsNullOrWhiteSpace()) { Product p = _productBiz.Find(gc.ProductId); p.IsNullThrowException(); p.GlobalComments.Add(gc); } if (!gc.ProductChildId.IsNullOrWhiteSpace()) { ProductChild pc = _productBiz.ProductChildBiz.Find(gc.ProductChildId); pc.IsNullThrowException(); pc.GlobalComments.Add(gc); } }
public override void Event_ModifyIndexItem(IndexListVM indexListVM, IndexItemVM indexItem, ICommonWithId icommonWithId) { base.Event_ModifyIndexItem(indexListVM, indexItem, icommonWithId); MenuPath1 mp1 = icommonWithId as MenuPath1; mp1.IsNullThrowException("Unable to unbox"); //send in a MenuPathMain that is a part of this MenuPath1 MenuPathMain mpm = mp1.MenuPathMains.FirstOrDefault(); //mpm.IsNullThrowException("mpm"); indexItem.MenuManager = new MenuManager(mpm, null, null, MenuENUM.EditMenuPath1, BreadCrumbManager, null, UserId, indexListVM.MenuManager.ReturnUrl, UserName); indexItem.MenuManager.PictureAddresses = GetCurrItemsPictureList(mp1); }
public void DeleteFeature(MenuFeatureDeleteModel menuFeatureDeleteModel) { menuFeatureDeleteModel.SelfCheckIdsAndReturnOnly(); MenuFeature menuFeature = MenuFeatureBiz.Find(menuFeatureDeleteModel.MenuFeatureId); menuFeature.IsNullThrowException("menuFeature"); MenuPath1 menuPath1 = Find(menuFeatureDeleteModel.MenuPathId); menuPath1.IsNullThrowException("menuPath1"); menuFeature.MenuPath1s.Remove(menuPath1); menuPath1.MenuFeatures.Remove(menuFeature); SaveChanges(); }
public void CreateNewFeature(CreateNewFeatureModel model) { model.SelfCheck(); MenuFeature menuFeature = MenuFeatureBiz.FindByName(model.FeatureName); if (menuFeature.IsNull()) { menuFeature = MenuFeatureBiz.Factory() as MenuFeature; menuFeature.IsNullThrowException("menuFeature"); menuFeature.Name = model.FeatureName; MenuFeatureBiz.CreateAndSave(menuFeature); } //create the new feature. MenuPath1 menupath1 = Find(model.ParentId); menupath1.IsNullThrowException("menupath1"); //taking a short cut. MenuFeatureModel menuFeatureModel = new MenuFeatureModel(model.ParentId, "", menuFeature.Id, model.ReturnUrl); AddFeature(menuFeatureModel); }
public bool AddAndSaveComment(GlobalComment gc) { if (gc.Comment.IsNullOrWhiteSpace()) { return(false); } gc.UserId.IsNullOrWhiteSpaceThrowException("No user is logged in!"); if (!gc.MenuPath1Id.IsNullOrWhiteSpace()) { MenuPath1 m1 = _menuPathMainBiz.MenuPath1Biz.Find(gc.MenuPath1Id); m1.IsNullThrowException(); m1.GlobalComments.Add(gc); } if (!gc.MenuPath2Id.IsNullOrWhiteSpace()) { MenuPath2 m2 = _menuPathMainBiz.MenuPath2Biz.Find(gc.MenuPath2Id); m2.IsNullThrowException(); m2.GlobalComments.Add(gc); } if (!gc.MenuPath3Id.IsNullOrWhiteSpace()) { MenuPath3 m3 = _menuPathMainBiz.MenuPath3Biz.Find(gc.MenuPath3Id); m3.IsNullThrowException(); m3.GlobalComments.Add(gc); } if (!gc.ProductId.IsNullOrWhiteSpace()) { Product p = _productBiz.Find(gc.ProductId); p.IsNullThrowException(); p.GlobalComments.Add(gc); } if (!gc.ProductChildId.IsNullOrWhiteSpace()) { ProductChild pc = _productBiz.ProductChildBiz.Find(gc.ProductChildId); pc.IsNullThrowException(); pc.GlobalComments.Add(gc); } if (!gc.UserId.IsNullOrWhiteSpace()) { ApplicationUser user = _userBiz.Find(gc.UserId); user.IsNullThrowException(); //user.GlobalComments.Add(gc); } gc.Name = UserName; ControllerCreateEditParameter parm = new ControllerCreateEditParameter(); parm.Entity = gc as ICommonWithId; CreateAndSave(parm); return(true); }
public LikeUnlikeParameters AddLikeAndReturnCount(string menuPath1Id, string menuPath2Id, string menuPath3Id, string productId, string productChildId, string userId, bool isLike, string comment) { userId.IsNullOrWhiteSpaceThrowException("No user is logged in!"); Person person = UserBiz.GetPersonFor(userId); person.IsNullThrowException("Person"); string personId = person.Id; personId.IsNullOrWhiteSpaceThrowException("personId"); LikeUnlike likeUnlike = Factory() as LikeUnlike; likeUnlike.Initialize(menuPath1Id, menuPath2Id, menuPath3Id, productId, productChildId, personId, isLike, comment); if (!menuPath1Id.IsNullOrWhiteSpace()) { likeUnlike.MenuPath1Id = menuPath1Id; MenuPath1 m1 = _menuPathMainBiz.MenuPath1Biz.Find(menuPath1Id); m1.IsNullThrowException(); m1.LikeUnlikes.Add(likeUnlike); } if (!menuPath2Id.IsNullOrWhiteSpace()) { likeUnlike.MenuPath2Id = menuPath2Id; MenuPath2 m2 = _menuPathMainBiz.MenuPath2Biz.Find(menuPath2Id); m2.IsNullThrowException(); m2.LikeUnlikes.Add(likeUnlike); } if (!menuPath3Id.IsNullOrWhiteSpace()) { likeUnlike.MenuPath3Id = menuPath3Id; MenuPath3 m3 = _menuPathMainBiz.MenuPath3Biz.Find(menuPath3Id); m3.IsNullThrowException(); m3.LikeUnlikes.Add(likeUnlike); } if (!productId.IsNullOrWhiteSpace()) { likeUnlike.ProductId = productId; } else { productId = null; } if (!productChildId.IsNullOrWhiteSpace()) { likeUnlike.ProductChildId = productChildId; } else { productChildId = null; } if (!personId.IsNullOrWhiteSpace()) { likeUnlike.PersonId = personId; person.IsNullThrowException(); person.LikeUnlikes.Add(likeUnlike); } //if it is a like delete the similar dislike. If it is a dislike delete the similar like bool relatedOppoisteDeleted = deleteTheRelatedLikeUnlike(menuPath1Id, menuPath2Id, menuPath3Id, productId, productChildId, personId, isLike); CreateAndSave(CreateControllerCreateEditParameter(likeUnlike as ICommonWithId)); return(Count( menuPath1Id, menuPath2Id, menuPath3Id, productId, productChildId, userId, relatedOppoisteDeleted)); }