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 void AddFeature(MenuFeatureModel menuFeatureModel) { //first get the parent menuFeatureModel.SelfCheck(); MenuPath3 menuPath3 = Find(menuFeatureModel.ParentId); menuPath3.IsNullThrowException("menuPath3"); MenuFeature menuFeature = MenuFeatureBiz.Find(menuFeatureModel.FeatureId); menuFeature.IsNullThrowException("menuFeature"); if (menuFeature.MenuPath3s.IsNull()) { menuFeature.MenuPath3s = new List <MenuPath3>(); } if (menuPath3.MenuFeatures.IsNull()) { menuPath3.MenuFeatures = new List <MenuFeature>(); } menuFeature.MenuPath3s.Add(menuPath3); menuPath3.MenuFeatures.Add(menuFeature); SaveChanges(); }
public override void Event_ModifyIndexItem(IndexListVM indexListVM, IndexItemVM indexItem, InterfacesLibrary.SharedNS.ICommonWithId icommonWithId) { base.Event_ModifyIndexItem(indexListVM, indexItem, icommonWithId); MenuPath3 mp3 = icommonWithId as MenuPath3; mp3.IsNullThrowException("Unable to unbox"); //send in a MenuPathMain that is a part of this MenuPath3 MenuPathMain mpm = mp3.MenuPathMains.FirstOrDefault(); indexItem.MenuManager = new MenuManager(mpm, null, null, MenuENUM.EditMenuPath3, BreadCrumbManager, null, UserId, indexListVM.MenuManager.ReturnUrl, UserName); indexItem.MenuManager.PictureAddresses = GetCurrItemsPictureList(mp3); }
public override void FixChildEntityForCreate(MenuPath3Feature mp3f) { mp3f.MenuPath3Id.IsNullOrWhiteSpaceThrowArgumentException("The MenuPath3Id is null in MenuPath3FeatureBiz.FixChildEntityForCreate"); //get the parent MenuPath3 MenuPath3 mp3 = MenuPath3Biz.Find(mp3f.MenuPath3Id); //Add the feauture to it. if (mp3.MenuPath3Features.IsNull()) { mp3.MenuPath3Features = new List <MenuPath3Feature>(); } mp3.MenuPath3Features.Add(mp3f); base.FixChildEntityForCreate(mp3f); }
public void DeleteFeature(MenuFeatureDeleteModel menuFeatureDeleteModel) { menuFeatureDeleteModel.SelfCheckIdsAndReturnOnly(); MenuFeature menuFeature = MenuFeatureBiz.Find(menuFeatureDeleteModel.MenuFeatureId); menuFeature.IsNullThrowException("menuFeature"); MenuPath3 menuPath3 = Find(menuFeatureDeleteModel.MenuPathId); menuPath3.IsNullThrowException("menuPath3"); menuFeature.MenuPath3s.Remove(menuPath3); menuPath3.MenuFeatures.Remove(menuFeature); SaveChanges(); }
private void addFeatureToEveryProductWithMenuPath3(MenuPath3 menuPath3, MenuFeature menuFeature) { //Now add the feature to every product that has menu3 as its path. //first find all the menuMains that contain MenuPath3 if (menuPath3.MenuPathMains.IsNullOrEmpty()) { return; } List <MenuPathMain> menuPathMainList = menuPath3.MenuPathMains.ToList(); //Now get all the products that have theseMenuPaths as their path. HashSet <Product> productHashList = new HashSet <Product>(); foreach (var menuPathMain in menuPathMainList) { if (!menuPathMain.Products_Fixed.IsNullOrEmpty()) { List <Product> menuPathMainProductList = menuPathMain.Products_Fixed.ToList(); foreach (var prod in menuPathMainProductList) { productHashList.Add(prod); } } } if (productHashList.IsNullOrEmpty()) { return; } foreach (var prod2 in productHashList) { ProductFeature pf = new ProductFeature(); pf.ProductId = prod2.Id; pf.Product = prod2; pf.MenuFeatureId = menuFeature.Id; pf.MenuFeature = menuFeature; pf.Name = menuFeature.Name; ProductFeatureBiz.CreateAndSave(pf); } SaveChanges(); }
//this would be same as the MenuPathMain private void getPeopleFromMp3Etc(MenuPathMain mpm) { mpm.IsNullThrowExceptionArgument("mpm"); mpm.MenuPath3Id.IsNullOrWhiteSpaceThrowException("MenuPath3 is null"); if (mpm.Products_Fixed.IsNullOrEmpty()) { return; } foreach (var product in mpm.Products_Fixed) { getPeopleFromProductEtc(product); } //get the likes MenuPath1 mp1 = mpm.MenuPath1; if (!mp1.LikeUnlikes.IsNullOrEmpty()) { AddLikes(mp1.LikeUnlikes); } MenuPath2 mp2 = mpm.MenuPath2; if (!mp2.LikeUnlikes.IsNullOrEmpty()) { AddLikes(mp2.LikeUnlikes); } MenuPath3 mp3 = mpm.MenuPath3; if (!mp3.LikeUnlikes.IsNullOrEmpty()) { AddLikes(mp3.LikeUnlikes); } }
private async Task <List <ICommonWithId> > indexProduct_DataListAsync(ControllerIndexParams parms) { //get the menupathMain MenuPathMain mpm = await FindAsync(parms.MenuPathMainId); mpm.IsNullThrowException("Menu Path does note exist. Something is wrong."); //Get all the products listed by it List <Product> listOfProducts = mpm.Products_Fixed_And_Approved; //update the count of Menu3Path MenuPath3 mp3 = MenuPathMainBiz.MenuPath3Biz.FindAll().FirstOrDefault(x => x.Id == mpm.MenuPath3Id); if (!mp3.IsNull()) { if (!UserId.IsNullOrWhiteSpace()) { mpm.NoOfVisits.AddOne(UserId, UserName); MenuPathMainBiz.Update(mpm); //these can be wrng if they also describe other paths //this is how many times this particular picture has been clicked mp3.NoOfVisits.AddOne(UserId, UserName); await MenuPathMainBiz.MenuPath3Biz.UpdateAndSaveAsync(mp3); } } if (listOfProducts.IsNullOrEmpty()) { return(null); } List <ICommonWithId> pclst = listOfProducts.Cast <ICommonWithId>().ToList(); return(pclst); }
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. MenuPath3 menupath3 = Find(model.ParentId); menupath3.IsNullThrowException("menupath3"); //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); }
//private readonly IRepositry<UploadedFile> _uploadFileDAL; /// <summary> /// This is where all the uploaded Files will be saved /// </summary> /// <returns></returns> //public override string Event_SaveLocationForUploadedFiles() //{ // return MyConstants.SAVE_LOCATION_PRODUCT_CATEGORY3; //} public override void AddEntityRecordIntoUpload(UploadedFile uploadFile, MenuPath3 entity, IUserHasUploadsTypeENUM iuserHasUploadsTypeEnum) { uploadFile.MenuPath3Id = entity.Id; uploadFile.MenuPath3 = entity; }
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)); }
//public override string[] GetDataForStringArrayFormat //{ // get // { // return ProductCategoryMainArray.DataArray(); // } //} public override void AddInitData() { //get the data List <MenuPathMainHelper> dataList = new DatastoreNS.MenuPathMainInitilizingDataList().DataList(); if (!dataList.IsNullOrEmpty()) { foreach (var item in dataList) { if (item.MenuPath1.IsNullOrWhiteSpace()) { ErrorsGlobal.Add(string.Format("Menu Path 1 '{0}' not found", item.MenuPath1), MethodBase.GetCurrentMethod()); throw new Exception(ErrorsGlobal.ToString()); } MenuPath1 menu1 = _menupath1Biz.FindByName(item.MenuPath1); MenuPath2 menu2 = _menupath2Biz.FindByName(item.MenuPath2); MenuPath3 menu3 = _menupath3Biz.FindByName(item.MenuPath3); MenuPathMain pcm = new MenuPathMain(); pcm.MenuPath1 = menu1; pcm.MenuPath1Id = menu1.Id; if (menu1.MenuPathMains.IsNull()) { menu1.MenuPathMains = new List <MenuPathMain>(); } menu1.MenuPathMains.Add(pcm); if (menu2.IsNull()) { continue; } pcm.MenuPath2 = menu2; pcm.MenuPath2Id = menu2.Id; if (menu2.MenuPathMains.IsNull()) { menu2.MenuPathMains = new List <MenuPathMain>(); } menu2.MenuPathMains.Add(pcm); if (menu3.IsNull()) { continue; } pcm.MenuPath3 = menu3; pcm.MenuPath3Id = menu3.Id; if (menu3.MenuPathMains.IsNull()) { menu3.MenuPathMains = new List <MenuPathMain>(); } menu3.MenuPathMains.Add(pcm); CreateSave_ForInitializeOnly(pcm); } } //SaveChanges(); }