public async Task <ActionResult <ModuleCategory> > PostModuleCategory(ModuleCategory moduleCategory) { _context.ModuleCategory.Add(moduleCategory); await _context.SaveChangesAsync(); return(CreatedAtAction("GetModuleCategory", new { id = moduleCategory.ModuleCategoryId }, moduleCategory)); }
public async Task <IActionResult> PutModuleCategory(int id, ModuleCategory moduleCategory) { if (id != moduleCategory.ModuleCategoryId) { return(BadRequest()); } _context.Entry(moduleCategory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ModuleCategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void AddCategoryNode(ModuleCategory category) { if (nodes.ContainsKey(category.Id)) { return; } FeedCategoryTreeNode node = new FeedCategoryTreeNode(category, this); nodes.Add(category.Id, node); if (category.ParentCategory <= 0) { if (TreeView.InvokeRequired) { TreeView.Invoke((MethodInvoker) delegate { Nodes.Add(node); }); } else { Nodes.Add(node); } } else { if (TreeView.InvokeRequired) { TreeView.Invoke((MethodInvoker) delegate { nodes[category.ParentCategory].Nodes.Add(node); }); } else { nodes[category.ParentCategory].Nodes.Add(node); } } categories.Add(category); }
private void AddButton(ModuleCategory category) { CategoryButton button = Instantiate(menuButtonPrefab, contentPanel).GetComponent <CategoryButton>(); button.GetComponent <RectTransform>().localScale = Vector3.one; button.SetUpButton(category, OnCategoryButton); }
public void ClickWeaponsCategory() { if (Category != ModuleCategory.Weapons) { Category = ModuleCategory.Weapons; BuildModuleSetButtons(WeaponModuleSets); } }
public void ClickDefenseCategory() { if (Category != ModuleCategory.Defenses) { Category = ModuleCategory.Defenses; BuildModuleSetButtons(DefenseModuleSets); } }
public void ClickSystemsCategory() { if (Category != ModuleCategory.Systems) { Category = ModuleCategory.Systems; BuildModuleSetButtons(SystemModuleSets); } }
/// <summary> /// Method to build a root node /// </summary> /// <param name="title">the title</param> /// <param name="category">the category</param> private void BuildCategoryNode(string title, ModuleCategory category) { TreeNode node = this.treeNavigation.Nodes.Add(title); node.Tag = category; node.ImageIndex = (Int32)category; node.SelectedImageIndex = node.ImageIndex; }
public HttpResponseMessage UpdateModuleCategory(HttpRequestMessage request, [FromBody] ModuleCategory moduleCategoryModel) { return(GetHttpResponse(request, () => { var moduleCategory = _CoreService.UpdateModuleCategory(moduleCategoryModel); return request.CreateResponse <ModuleCategory>(HttpStatusCode.OK, moduleCategory); })); }
public HttpResponseMessage GetModuleCategory(HttpRequestMessage request, int moduleCategoryId) { return(GetHttpResponse(request, () => { HttpResponseMessage response = null; ModuleCategory moduleCategory = _CoreService.GetModuleCategory(moduleCategoryId); // notice no need to create a seperate model object since ModuleCategory entity will do just fine response = request.CreateResponse <ModuleCategory>(HttpStatusCode.OK, moduleCategory); return response; })); }
/// <summary> /// Initializes a new instance of the <see cref="FeedCategoryTreeNode"/> class. /// </summary> /// <param name="category">The category.</param> /// <remarks>Documented by Dev05, 2009-06-26</remarks> public FeedCategoryTreeNode(ModuleCategory category, FeedTreeNode mainNode) : base() { OwnModules = new List<ListViewItem>(); OwnSubCategoryModules = new List<ListViewItem>(); this.mainNode = mainNode; Category = category; Group = new ListViewGroup(category.Title); Text = category.Title; ImageIndex = 1; SelectedImageIndex = 1; }
/// <summary> /// Initializes a new instance of the <see cref="FeedCategoryTreeNode"/> class. /// </summary> /// <param name="category">The category.</param> /// <remarks>Documented by Dev05, 2009-06-26</remarks> public FeedCategoryTreeNode(ModuleCategory category, FeedTreeNode mainNode) : base() { OwnModules = new List <ListViewItem>(); OwnSubCategoryModules = new List <ListViewItem>(); this.mainNode = mainNode; Category = category; Group = new ListViewGroup(category.Title); Text = category.Title; ImageIndex = 1; SelectedImageIndex = 1; }
protected bool CheckHullModuleAllow(ModuleLimitType limit, ModuleCategory category) { if (category == ModuleCategory.Systems) { return(true); } if (category == ModuleCategory.Engines) { if (limit == ModuleLimitType.NoEngines || limit == ModuleLimitType.NoWeaponsOrEngines) { return(false); } } if (category == ModuleCategory.Weapons) { if (limit == ModuleLimitType.NoWeapons || limit == ModuleLimitType.NoWeaponsOrEngines) { return(false); } } return(true); }
private void RefreshList(ModuleCategory newCategory, bool isBack = false) { if (!isBack) { order.Push(currentCategory); } backButton.gameObject.SetActive(order.Count > 1); foreach (Transform child in contentPanel) { Destroy(child.gameObject); } switch (newCategory) { case null: foreach (var category in mainCategories) { AddButton(category); } break; case MainCategory mainCategory: foreach (var subCategory in mainCategory.SubCategories) { AddButton(subCategory); } break; case SubCategory subCategory: foreach (var module in subCategory.Modules) { AddButton(module); } break; } currentCategory = newCategory; }
public HttpResponseMessage DeleteModuleCategory(HttpRequestMessage request, [FromBody] int moduleCategoryId) { return(GetHttpResponse(request, () => { HttpResponseMessage response = null; // not that calling the WCF service here will authenticate access to the data ModuleCategory moduleCategory = _CoreService.GetModuleCategory(moduleCategoryId); if (moduleCategory != null) { _CoreService.DeleteModuleCategory(moduleCategoryId); response = request.CreateResponse(HttpStatusCode.OK); } else { response = request.CreateErrorResponse(HttpStatusCode.NotFound, "No moduleCategory found under that ID."); } return response; })); }
public void CreateTestMethod() { var repo = new ModuleCategoryRepository(); var entity = new ModuleCategory() { Code = "Test1", Name = "Test 1", Alias = "Test 1", Active = true, Deleted = false, CreatedBy = "Test", CreatedOn = DateTime.Now, UpdatedBy = "Test", UpdatedOn = DateTime.Now }; var newEntity = repo.Add(entity); entity = new ModuleCategory() { Code = "Test2", Name = "Test 2", Alias = "Test 2", Active = true, Deleted = false, CreatedBy = "Test", CreatedOn = DateTime.Now, UpdatedBy = "Test", UpdatedOn = DateTime.Now }; repo.Add(entity); Assert.AreEqual(newEntity.EntityId, 1); }
private void OnBackButton() { ModuleCategory category = order.Pop(); RefreshList(category, true); }
public ModuleCategoryAttribute(ModuleCategory category) { Category = category; }
private void OnCategoryButton(ModuleCategory category) { RefreshList(category); }
public CategoryController(AuctionDBContext context) { this._context = context; catefunction = new ModuleCategory(this._context); errorResquest = new ErrorResquest(); }
public ModuleCategory UpdateModuleCategory(ModuleCategory moduleCategory) { return(Channel.UpdateModuleCategory(moduleCategory)); }
public void SetUpButton(ModuleCategory item, Action <ModuleCategory> onButtonClicked) { icon.overrideSprite = item.Icon; nameText.gameObject.SetActive(false); OnButtonClicked = () => onButtonClicked?.Invoke(item); }
/// <summary> /// Gets the modules document. /// </summary> /// <returns></returns> /// <remarks>Documented by Dev05, 2012-02-07</remarks> private XmlDocument GetModulesDocument() { SyndicationFeed feed = new SyndicationFeed(); feed.Id = Settings.Default.ModuleFeedId.ToString(); feed.Title = new TextSyndicationContent("MemoryLifter Modules", TextSyndicationContentKind.Plaintext); feed.Description = new TextSyndicationContent("Lists all modules available.", TextSyndicationContentKind.Plaintext); feed.LastUpdatedTime = new DateTimeOffset(DateTime.Now); feed.Authors.Add(new SyndicationPerson("*****@*****.**", "OMICRON", "http://www.memorylifter.com")); List <SyndicationItem> items = new List <SyndicationItem>(); feed.Items = items; foreach (string file in Directory.GetFiles(Server.MapPath(Settings.Default.ModulesFolder), "*.mlm", SearchOption.AllDirectories)) { SyndicationItem item = new SyndicationItem(); items.Add(item); string filename = Path.GetFileNameWithoutExtension(file); string xmlFile = Path.Combine(Server.MapPath(Settings.Default.InfoFolder), filename + ".xml"); long size = 0; if (File.Exists(xmlFile)) //if there is a xml-info-file use the information from it { Stream fStream = File.OpenRead(xmlFile); ModuleInfo info = (ModuleInfo)infoSerializer.Deserialize(fStream); fStream.Close(); item.Id = info.Id; item.Title = new TextSyndicationContent(info.Title, TextSyndicationContentKind.Plaintext); item.Content = new TextSyndicationContent(info.Description, TextSyndicationContentKind.Plaintext); //This is also shown in feed readers as text //As the summary we use a struct which can be deserialized to a ModuleInfo-struct item.Summary = new TextSyndicationContent("<ModuleInfo><Cards>" + info.Cards + "</Cards></ModuleInfo>", TextSyndicationContentKind.XHtml); foreach (string category in info.Categories) { ModuleCategory cat = (from c in categories where c.Id.ToString() == category select c).FirstOrDefault(); if (cat.Id > 0) //if the stored category is actually an Id to a category { item.Categories.Add(new SyndicationCategory(cat.Title) { Label = category }); } else { item.Categories.Add(new SyndicationCategory(category)); } } item.Contributors.Add(new SyndicationPerson(info.AuthorMail, info.Author, info.AuthorUrl)); DateTime time; if (DateTime.TryParse(info.EditDate, out time)) { item.LastUpdatedTime = new DateTimeOffset(time); } else { item.LastUpdatedTime = new DateTimeOffset((new FileInfo(file)).LastWriteTime); } size = info.Size; } else // use the information you can get from the file - no SQL CE access on Mono --> if running on IIS/.net you could read it form the file { item.Id = file.GetHashCode().ToString(); item.Title = new TextSyndicationContent(filename, TextSyndicationContentKind.Plaintext); item.LastUpdatedTime = new DateTimeOffset((new FileInfo(file)).LastWriteTime); } if (size <= 0) { size = (new FileInfo(file)).Length; } item.Links.Add(new SyndicationLink(new Uri(BaseAddress + Settings.Default.ModulesFolder + '/' + Uri.EscapeDataString(Path.GetFileName(file)))) { MediaType = "application/x-mlm", RelationshipType = AtomLinkRelationshipType.Module.ToString(), Length = size }); item.Links.Add(new SyndicationLink(new Uri(BaseAddress + "GetImage.ashx?size=150&module=" + HttpUtility.UrlEncode(filename))) { MediaType = "image/png", RelationshipType = AtomLinkRelationshipType.Preview.ToString() }); item.Links.Add(new SyndicationLink(new Uri(BaseAddress + "GetImage.ashx?size=32&module=" + HttpUtility.UrlEncode(filename))) { MediaType = "image/png", RelationshipType = AtomLinkRelationshipType.IconBig.ToString() }); item.Links.Add(new SyndicationLink(new Uri(BaseAddress + "GetImage.ashx?size=16&module=" + HttpUtility.UrlEncode(filename))) { MediaType = "image/png", RelationshipType = AtomLinkRelationshipType.IconSmall.ToString() }); } StringBuilder result = new StringBuilder(); XmlWriter writer = XmlWriter.Create(result); feed.GetAtom10Formatter().WriteTo(writer); writer.Flush(); XmlDocument doc = new XmlDocument(); doc.LoadXml(result.ToString()); return(doc); }
private void AddCategoryNode(ModuleCategory category) { if (nodes.ContainsKey(category.Id)) return; FeedCategoryTreeNode node = new FeedCategoryTreeNode(category, this); nodes.Add(category.Id, node); if (category.ParentCategory <= 0) { if (TreeView.InvokeRequired) TreeView.Invoke((MethodInvoker)delegate { Nodes.Add(node); }); else { Nodes.Add(node); } } else { if (TreeView.InvokeRequired) TreeView.Invoke((MethodInvoker)delegate { nodes[category.ParentCategory].Nodes.Add(node); }); else nodes[category.ParentCategory].Nodes.Add(node); } categories.Add(category); }
/// <summary> /// Loads the content of the web. /// </summary> /// <remarks>Documented by Dev05, 2009-06-26</remarks> public void LoadWebContent(object path) { IsListLoaded = false; IsLoaded = false; string configPath = path as string; nodes = new Dictionary<int, FeedCategoryTreeNode>(); if (TreeView.InvokeRequired) TreeView.Invoke((MethodInvoker)delegate { Nodes.Clear(); }); else Nodes.Clear(); try { if (TreeView.InvokeRequired) TreeView.Invoke((MethodInvoker)delegate { Text = String.IsNullOrWhiteSpace(Feed.Name) ? Resources.FeedTreeNode_Name : Feed.Name; }); else Text = String.IsNullOrWhiteSpace(Feed.Name) ? Resources.FeedTreeNode_Name : Feed.Name; #region read categories XmlReader categoryFeedReader = XmlReader.Create(Feed.CategoriesUri); SyndicationFeed categoryFeed = SyndicationFeed.Load(categoryFeedReader); List<ModuleCategory> categoriesToAdd = new List<ModuleCategory>(); foreach (SyndicationItem item in categoryFeed.Items) { ModuleCategory category = new ModuleCategory() { Id = Convert.ToInt32(item.Id), Title = item.Title.Text, ParentCategory = Convert.ToInt32(item.Links[0].Title) }; categoriesToAdd.Add(category); } categoriesToAdd.Sort((a, b) => a.Id.CompareTo(b.Id)); categoriesToAdd.ForEach(c => AddCategoryNode(c)); #endregion #region read modules XmlReader moduleFeedReader = XmlReader.Create(Feed.ModulesUri); SyndicationFeed moduleFeed = SyndicationFeed.Load(moduleFeedReader); List<ModuleInfo> modules = new List<ModuleInfo>(); XmlSerializer infoSerializer = new XmlSerializer(typeof(ModuleInfo)); Dictionary<string, SyndicationItem> items = new Dictionary<string, SyndicationItem>(); foreach (SyndicationItem item in moduleFeed.Items) { ModuleInfo info; if (item.Summary != null) info = (ModuleInfo)infoSerializer.Deserialize(XmlReader.Create(new StringReader(WebUtility.HtmlDecode(item.Summary.Text)))); else info = new ModuleInfo(); info.Id = item.Id; info.Title = item.Title.Text; info.EditDate = item.LastUpdatedTime.ToString(); if (item.Contributors.Count > 0) { info.Author = item.Contributors[0].Name; info.AuthorMail = item.Contributors[0].Email; info.AuthorUrl = item.Contributors[0].Uri; } if (item.Content is TextSyndicationContent) info.Description = (item.Content as TextSyndicationContent).Text; info.Categories = new SerializableList<string>(); foreach (SyndicationCategory cat in item.Categories) info.Categories.Add(cat.Label); foreach (SyndicationLink link in item.Links) { if (link.RelationshipType == AtomLinkRelationshipType.Module.ToString()) { info.Size = link.Length; info.DownloadUrl = link.Uri.AbsoluteUri; } } modules.Add(info); items.Add(info.Id, item); } categories.ForEach(c => nodes[c.Id].SetModuleList(modules.FindAll(p => p.Categories.Contains(c.Id.ToString())))); #endregion if (TreeView.InvokeRequired) TreeView.Invoke((MethodInvoker)delegate { Expand(); }); else Expand(); IsListLoaded = true; OnContentLoaded(EventArgs.Empty); #region read images using (PersistentMemoryCache<ModuleInfoCacheItem> cache = new PersistentMemoryCache<ModuleInfoCacheItem>("Feed_" + moduleFeed.Id)) { WebClient webClient = new WebClient(); foreach (ModuleInfo basicInfo in modules) { try { ModuleInfo info = basicInfo; SyndicationItem item = items[basicInfo.Id]; string cacheKey = String.Format("{0}##{1}##{2}", moduleFeed.Id, item.Id, item.LastUpdatedTime); if (cache.Contains(cacheKey)) { ModuleInfoCacheItem cacheItem = (ModuleInfoCacheItem)cache[cacheKey]; info.IconSmall = Convert.FromBase64String(cacheItem.IconSmall); info.IconBig = Convert.FromBase64String(cacheItem.IconBig); info.Preview = Convert.FromBase64String(cacheItem.Preview); } else { ModuleInfoCacheItem cacheItem = new ModuleInfoCacheItem(info.Id); foreach (SyndicationLink link in item.Links) { if (link.RelationshipType == AtomLinkRelationshipType.IconSmall.ToString()) cacheItem.IconSmall = Convert.ToBase64String(info.IconSmall = webClient.DownloadData(link.Uri)); if (link.RelationshipType == AtomLinkRelationshipType.IconBig.ToString()) cacheItem.IconBig = Convert.ToBase64String(info.IconBig = webClient.DownloadData(link.Uri)); if (link.RelationshipType == AtomLinkRelationshipType.Preview.ToString()) cacheItem.Preview = Convert.ToBase64String(info.Preview = webClient.DownloadData(link.Uri)); } cache.Set(cacheKey, cacheItem, DateTime.Now.AddYears(1)); } if (TreeView.InvokeRequired) TreeView.Invoke((MethodInvoker)delegate { LoadDetails(info); }); else LoadDetails(info); } catch (Exception exp) { Trace.WriteLine(exp.ToString()); } } cache.Dispose(); } #endregion IsLoaded = true; } catch (Exception) { try { if (TreeView.InvokeRequired) TreeView.Invoke((MethodInvoker)delegate { Text = Resources.FeedTreeNode_Text_Offline; }); else Text = Resources.FeedTreeNode_Text_Offline; } catch (ObjectDisposedException) { } } }
/// <summary> /// Loads the content of the web. /// </summary> /// <remarks>Documented by Dev05, 2009-06-26</remarks> public void LoadWebContent(object path) { IsListLoaded = false; IsLoaded = false; string configPath = path as string; nodes = new Dictionary <int, FeedCategoryTreeNode>(); if (TreeView.InvokeRequired) { TreeView.Invoke((MethodInvoker) delegate { Nodes.Clear(); }); } else { Nodes.Clear(); } try { if (TreeView.InvokeRequired) { TreeView.Invoke((MethodInvoker) delegate { Text = String.IsNullOrWhiteSpace(Feed.Name) ? Resources.FeedTreeNode_Name : Feed.Name; }); } else { Text = String.IsNullOrWhiteSpace(Feed.Name) ? Resources.FeedTreeNode_Name : Feed.Name; } #region read categories XmlReader categoryFeedReader = XmlReader.Create(Feed.CategoriesUri); SyndicationFeed categoryFeed = SyndicationFeed.Load(categoryFeedReader); List <ModuleCategory> categoriesToAdd = new List <ModuleCategory>(); foreach (SyndicationItem item in categoryFeed.Items) { ModuleCategory category = new ModuleCategory() { Id = Convert.ToInt32(item.Id), Title = item.Title.Text, ParentCategory = Convert.ToInt32(item.Links[0].Title) }; categoriesToAdd.Add(category); } categoriesToAdd.Sort((a, b) => a.Id.CompareTo(b.Id)); categoriesToAdd.ForEach(c => AddCategoryNode(c)); #endregion #region read modules XmlReader moduleFeedReader = XmlReader.Create(Feed.ModulesUri); SyndicationFeed moduleFeed = SyndicationFeed.Load(moduleFeedReader); List <ModuleInfo> modules = new List <ModuleInfo>(); XmlSerializer infoSerializer = new XmlSerializer(typeof(ModuleInfo)); Dictionary <string, SyndicationItem> items = new Dictionary <string, SyndicationItem>(); foreach (SyndicationItem item in moduleFeed.Items) { ModuleInfo info; if (item.Summary != null) { info = (ModuleInfo)infoSerializer.Deserialize(XmlReader.Create(new StringReader(WebUtility.HtmlDecode(item.Summary.Text)))); } else { info = new ModuleInfo(); } info.Id = item.Id; info.Title = item.Title.Text; info.EditDate = item.LastUpdatedTime.ToString(); if (item.Contributors.Count > 0) { info.Author = item.Contributors[0].Name; info.AuthorMail = item.Contributors[0].Email; info.AuthorUrl = item.Contributors[0].Uri; } if (item.Content is TextSyndicationContent) { info.Description = (item.Content as TextSyndicationContent).Text; } info.Categories = new SerializableList <string>(); foreach (SyndicationCategory cat in item.Categories) { info.Categories.Add(cat.Label); } foreach (SyndicationLink link in item.Links) { if (link.RelationshipType == AtomLinkRelationshipType.Module.ToString()) { info.Size = link.Length; info.DownloadUrl = link.Uri.AbsoluteUri; } } modules.Add(info); items.Add(info.Id, item); } categories.ForEach(c => nodes[c.Id].SetModuleList(modules.FindAll(p => p.Categories.Contains(c.Id.ToString())))); #endregion if (TreeView.InvokeRequired) { TreeView.Invoke((MethodInvoker) delegate { Expand(); }); } else { Expand(); } IsListLoaded = true; OnContentLoaded(EventArgs.Empty); #region read images using (PersistentMemoryCache <ModuleInfoCacheItem> cache = new PersistentMemoryCache <ModuleInfoCacheItem>("Feed_" + moduleFeed.Id)) { WebClient webClient = new WebClient(); foreach (ModuleInfo basicInfo in modules) { try { ModuleInfo info = basicInfo; SyndicationItem item = items[basicInfo.Id]; string cacheKey = String.Format("{0}##{1}##{2}", moduleFeed.Id, item.Id, item.LastUpdatedTime); if (cache.Contains(cacheKey)) { ModuleInfoCacheItem cacheItem = (ModuleInfoCacheItem)cache[cacheKey]; info.IconSmall = Convert.FromBase64String(cacheItem.IconSmall); info.IconBig = Convert.FromBase64String(cacheItem.IconBig); info.Preview = Convert.FromBase64String(cacheItem.Preview); } else { ModuleInfoCacheItem cacheItem = new ModuleInfoCacheItem(info.Id); foreach (SyndicationLink link in item.Links) { if (link.RelationshipType == AtomLinkRelationshipType.IconSmall.ToString()) { cacheItem.IconSmall = Convert.ToBase64String(info.IconSmall = webClient.DownloadData(link.Uri)); } if (link.RelationshipType == AtomLinkRelationshipType.IconBig.ToString()) { cacheItem.IconBig = Convert.ToBase64String(info.IconBig = webClient.DownloadData(link.Uri)); } if (link.RelationshipType == AtomLinkRelationshipType.Preview.ToString()) { cacheItem.Preview = Convert.ToBase64String(info.Preview = webClient.DownloadData(link.Uri)); } } cache.Set(cacheKey, cacheItem, DateTime.Now.AddYears(1)); } if (TreeView.InvokeRequired) { TreeView.Invoke((MethodInvoker) delegate { LoadDetails(info); }); } else { LoadDetails(info); } } catch (Exception exp) { Trace.WriteLine(exp.ToString()); } } cache.Dispose(); } #endregion IsLoaded = true; } catch (Exception) { try { if (TreeView.InvokeRequired) { TreeView.Invoke((MethodInvoker) delegate { Text = Resources.FeedTreeNode_Text_Offline; }); } else { Text = Resources.FeedTreeNode_Text_Offline; } } catch (ObjectDisposedException) { } } }
public void Setup() { function = new ModuleCategory(new AuctionDBContext(new Microsoft.EntityFrameworkCore.DbContextOptions <AuctionDBContext>())); list = null; }
internal List <Module> GetModulesOfCategory(ModuleCategory moduleCategory) { return(prefabs.moduleCategoryMap[moduleCategory]); }
protected override void Seed(MyContext context) { var products = new List <Product> { new Product { Name = "p1", Description = "desc1" }, new Product { Name = "p2", Description = "desc2" } }; products.ForEach(s => context.Products.Add(s)); //module set records ModuleCategory moduleCategory1 = new ModuleCategory { Name = ModuleCategoryName.Home, IsPublic = true }; ModuleCategory moduleCategory2 = new ModuleCategory { Name = ModuleCategoryName.Home, IsPublic = false }; ModuleCategory moduleCategory3 = new ModuleCategory { Name = ModuleCategoryName.Staff, IsPublic = false }; Module cat1_module1 = new Module { Title = "Useful Links", ColumnIndex = 1, RowIndex = 1 }; Module cat1_module2 = new Module { Title = "Canvas News", ColumnIndex = 1, RowIndex = 2 }; Module cat2_module1 = new Module { Title = "My Bookmarks", ColumnIndex = 2, RowIndex = 1 }; Module cat2_module2 = new Module { Title = "University Policies", ColumnIndex = 2, RowIndex = 2 }; Module cat3_module1 = new Module { Title = "Human Resources Office (HRO)", ColumnIndex = 3, RowIndex = 2 }; Module cat3_module2 = new Module { Title = "Computer Services Centre (CSC)", ColumnIndex = 3, RowIndex = 3 }; ModuleItem item1 = new ModuleItem { Title = "Canvas", Url = "https://canvas.cityu.edu.hk/login" }; ModuleItem item2 = new ModuleItem { Title = "AIMS", Url = "https://banweb.cityu.edu.hk/" }; ModuleItem item3 = new ModuleItem { Title = "News Centre", Url = "#" }; ModuleItem item4 = new ModuleItem { Title = "City TV", Url = "#" }; ModuleItem item5 = new ModuleItem { Title = "My link 1", Url = "#" }; ModuleItem item6 = new ModuleItem { Title = "My link 2", Url = "#" }; ModuleItem item7 = new ModuleItem { Title = "Popular link 1", Url = "#" }; ModuleItem item8 = new ModuleItem { Title = "Services from HRO", Url = "#" }; ModuleItem item9 = new ModuleItem { Title = "IT Services", Url = "#" }; moduleCategory1.Modules.Add(cat1_module1); moduleCategory1.Modules.Add(cat1_module2); moduleCategory2.Modules.Add(cat2_module1); moduleCategory2.Modules.Add(cat2_module2); moduleCategory3.Modules.Add(cat3_module1); moduleCategory3.Modules.Add(cat3_module2); context.ModuleCategorys.Add(moduleCategory1); context.ModuleCategorys.Add(moduleCategory2); context.ModuleCategorys.Add(moduleCategory3); context.ModuleItems.Add(item1); context.ModuleItems.Add(item2); context.ModuleItems.Add(item3); context.ModuleItems.Add(item4); context.ModuleItems.Add(item5); context.ModuleItems.Add(item6); context.ModuleItems.Add(item7); context.ModuleItems.Add(item8); context.ModuleItems.Add(item9); context.SaveChanges(); context.ModuleAndItemRelationships.Add(new ModuleAndItemRelationship { ModuleId = cat1_module1.ModuleId, ModuleItemId = item1.ModuleItemId, ItemIndex = 1 }); context.ModuleAndItemRelationships.Add(new ModuleAndItemRelationship { ModuleId = cat1_module1.ModuleId, ModuleItemId = item2.ModuleItemId, ItemIndex = 2 }); context.ModuleAndItemRelationships.Add(new ModuleAndItemRelationship { ModuleId = cat1_module2.ModuleId, ModuleItemId = item3.ModuleItemId, ItemIndex = 1 }); context.ModuleAndItemRelationships.Add(new ModuleAndItemRelationship { ModuleId = cat1_module2.ModuleId, ModuleItemId = item4.ModuleItemId, ItemIndex = 2 }); context.ModuleAndItemRelationships.Add(new ModuleAndItemRelationship { ModuleId = cat2_module1.ModuleId, ModuleItemId = item5.ModuleItemId, ItemIndex = 1 }); context.ModuleAndItemRelationships.Add(new ModuleAndItemRelationship { ModuleId = cat2_module1.ModuleId, ModuleItemId = item6.ModuleItemId, ItemIndex = 2 }); context.ModuleAndItemRelationships.Add(new ModuleAndItemRelationship { ModuleId = cat2_module2.ModuleId, ModuleItemId = item7.ModuleItemId, ItemIndex = 1 }); context.ModuleAndItemRelationships.Add(new ModuleAndItemRelationship { ModuleId = cat3_module1.ModuleId, ModuleItemId = item8.ModuleItemId, ItemIndex = 1 }); context.ModuleAndItemRelationships.Add(new ModuleAndItemRelationship { ModuleId = cat3_module2.ModuleId, ModuleItemId = item9.ModuleItemId, ItemIndex = 1 }); context.SaveChanges(); base.Seed(context); }