protected void Page_Load(object sender, EventArgs e) { Category Cat = new Category(); SubCategory SubCat = new SubCategory(); CatId = Convert.ToString(Request.QueryString["CatId"]); string CatName = Cat.GetName(CatId); SubCatId = Convert.ToString(Request.QueryString["SubCatId"]); string SubCatName = SubCat.GetName(SubCatId); if (!IsPostBack) { DataSet dsSubCat = SubCat.GetList(CatId); ddlSubCategory.DataSource = dsSubCat; ddlSubCategory.DataTextField = "name"; ddlSubCategory.DataValueField = "subcategoryid"; ddlSubCategory.DataBind(); } lblCat.Text = CatName; lblCat.NavigateUrl = string.Format("ViewCat.aspx?CatId={0}&CatName={1}&SubCatId={2}", CatId, CatName, SubCatId); lblSubCat.Text = SubCatName; lblSubCat.NavigateUrl = string.Format("ViewSubCat.aspx?SubCatId={0}&SubCatName={1}&CatId={2}&CatName={3}", SubCatId, SubCatName, CatId, CatName); }
protected void uiButtonCancel_Click(object sender, EventArgs e) { uiPanelEdit.Visible = false; uiPanelViewCats.Visible = true; Clearfields(); CurrentSubCategory = null; }
/// <summary> /// The create sub char. /// </summary> /// <param name="key"> /// The key. /// </param> /// <param name="name"> /// The name. /// </param> public void CreateSubChar(SubCategory key, string name) { if (this.Subchars.Any(subCharacteristicse => subCharacteristicse.Key.Equals(key))) { return; } this.Subchars.Add(new SubCharacteristics(key, name)); }
protected void btnSubCategorySubmit_Click(object sender, EventArgs e) { DatabaseDataContext db = new DatabaseDataContext(); SubCategory tmpitem = new SubCategory(); tmpitem.categoryName = lstCategory.SelectedValue; tmpitem.subCategoryName = txtSubCategoryName.Text; db.SubCategories.InsertOnSubmit(tmpitem); db.SubmitChanges(); Response.Redirect(Util.UrlRewriting.encodeUrl("createCategory.aspx")); }
public SubCategoryTagsEditor(SubCategory template, List<string> templates) { this.Build (); Gdk.Color.Parse("red", ref templateExistsColor); this.templates = templates; tagsDict = new Dictionary<string, Widget>(); addtagbutton.Clicked += OnAddTag; tagentry.Activated += OnAddTag; nameentry.Changed += OnNameChanged; multicheckbutton.Toggled += OnMultiToggled; fastcheckbutton.Toggled += OnFastToggled; Template = template; }
public List<entry> GetEntrysBySubCategory(Category ec, SubCategory esubc) { int c = (int)ec; int subc =(int)esubc; if(bySubCategory.ContainsKey(c * 100 + subc)) return bySubCategory[c*100+subc]; List<entry> cs = GetEntrysByCategory(ec); List<entry> result = new List<entry>(); foreach (var item in cs) { if(item.ucSubCategory == subc) result.Add(item); } bySubCategory.Add(c*100+subc, result); return result; }
public ActionResult Create(CreateSubCategoryBindingModel model) { if(model != null && this.ModelState.IsValid) { var subCategory = new SubCategory { Title = model.Title, CategoryId = model.CategoryId }; this.Data.SubCategories.Add(subCategory); this.Data.SaveChanges(); return this.RedirectToAction("Index", "Home"); } model.Categories = this.populator.GetCategories(); return this.View(model); }
protected void uiButtonUpdate_Click(object sender, EventArgs e) { SubCategory cat = new SubCategory(); if (CurrentSubCategory != null) { cat = CurrentSubCategory; } else { cat.AddNew(); } cat.CategoryID = Convert.ToInt32(uiDropDownListCategory.SelectedValue); cat.Name = uiTextBoxName.Text; cat.Save(); uiPanelEdit.Visible = false; uiPanelViewCats.Visible = true; Clearfields(); BindData(); CurrentSubCategory = null; }
public void TestTagSubcategorySerialization() { string tag1="tag1", tag2="tag2"; List<string> elementsDesc; MemoryStream stream; SubCategory subcat, newsubcat; subcat = new SubCategory {Name="Test", AllowMultiple = true}; subcat.Options.Add (tag1); subcat.Options.Add (tag2); Utils.CheckSerialization (subcat); newsubcat = Utils.SerializeDeserialize (subcat); Assert.AreEqual (subcat.Name, newsubcat.Name); Assert.AreEqual (subcat.AllowMultiple, newsubcat.AllowMultiple); Assert.AreEqual (subcat.Options.Count, newsubcat.Options.Count); Assert.AreEqual (subcat.Options[0], newsubcat.Options[0]); Assert.AreEqual (subcat.Options[1], newsubcat.Options[1]); }
public int addSubCategory(ISubCategoriesDTO category) { int retVal = default(int); using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { SubCategory employee = new SubCategory(); EntityConverter.FillEntityFromDTO(category, employee); SubCategory addedEmployee = employeePortalEntities.SubCategories.Add(employee); employeePortalEntities.SaveChanges(); retVal = addedEmployee.SubCategotyId; } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return retVal; }
public void Insert(SubCategory subCat) { _db.SubCategory.Add(subCat); }
public List <Product> GetProducts(SubCategory subCategory) { return(service.GetProducts(subCategory)); }
public ActionResult Edit(SubCategory subCategory) { SubCategoryService.Update(subCategory); return(RedirectToAction("List")); }
public void AddTagSubcategory(SubCategory subcat, TagsStore tags) { /* the notebook starts invisible */ taggerwidget1.AddSubCategory(subcat, tags); subcategoryAdded = true; }
private void BindSubCats() { SubCategory subcats = new SubCategory(); subcats.GetSubCategoryByCatID(Convert.ToInt32(uiDropDownListCategory.SelectedValue)); uiDropDownListSubCat.DataSource = subcats.DefaultView; uiDropDownListSubCat.DataTextField = "Name"; uiDropDownListSubCat.DataValueField = "SubCategoryID"; uiDropDownListSubCat.DataBind(); }
internal static SubCategoryVm FromModel(SubCategory model) { var viewModel = new SubCategoryVm {Id = model.Id, Name = model.Name, Category = model.Category.Name}; return viewModel; }
static void CreateJsonFile() { int productQueue = 0; string[] paths = Directory.GetDirectories(Application.dataPath + "/Resources/Products/"); int pIndex = 1; List <Category> clist = new List <Category>(); for (int i = 0; i < paths.Length; i++) { DirectoryInfo dir = new DirectoryInfo(paths[i]); Debug.Log("dir = " + dir); Category mc = new Category(); mc.id = i; mc.name = dir.Name; Debug.Log("mc.name = " + mc.name); mc.SubCategorys = new List <SubCategory>(); mc.Products = new List <CategoryProduct>(); //the sub path (second layer) string[] subPaths = Directory.GetDirectories(paths[i]); Debug.Log("subPaths.Length = " + subPaths.Length); for (int j = 0; j < subPaths.Length; j++) { DirectoryInfo subDir = new DirectoryInfo(subPaths[j]); Debug.Log("subDir = " + subDir); SubCategory sc = new SubCategory(); sc.sub_id = mc.id * 100 + j; //the subCatagory id is made up from parent_id and its own current id sc.sub_name = subDir.Name; sc.parent_id = mc.id; sc.parent_name = mc.name; FileInfo[] subFiles = subDir.GetFiles(); foreach (FileInfo f in subFiles) { if (string.Equals(f.Extension, ".DS_Store")) { continue; } if (string.Equals(f.Extension, ".prefab")) { CategoryProduct cp = new CategoryProduct(); cp.category_id = sc.sub_id; cp.sku = f.Name.Substring(0, f.Name.Length - f.Extension.Length); Debug.Log("cp.sku = " + cp.sku); sc.Products.Add(cp); //product in sub category Product p = new Product(); p.sku = f.Name.Substring(0, f.Name.Length - f.Extension.Length); p.queue = productQueue++; p.category_id = sc.sub_id; p.category_name = sc.sub_name; string pstr = JsonConvert.SerializeObject(p); Debug.Log("out: " + pstr); // string filePath = Application.dataPath + "/Resources/Json/" + mc.id + "/sc/" + sc.sub_name; string filePath = Application.dataPath + "/Resources/Json/Products/"; if (!File.Exists(filePath)) { Directory.CreateDirectory(filePath); } // File.WriteAllText(Application.dataPath + "/Resources/Json/" + mc.id + "/sc/" + sc.sub_name + "/" + p.sku + ".json", pstr); File.WriteAllText(Application.dataPath + "/Resources/Json/Products/" + p.sku + ".json", pstr); } } mc.SubCategorys.Add(sc); string scstr = JsonConvert.SerializeObject(sc); Debug.Log("out: " + scstr); // string filePath1 = Application.dataPath + "/Resources/Json/" + mc.id + "/sc"; string filePath1 = Application.dataPath + "/Resources/Json/sc"; if (!File.Exists(filePath1)) { Directory.CreateDirectory(filePath1); } // File.WriteAllText(Application.dataPath + "/Resources/Json/" + mc.id + "/sc/" + sc.sub_name + ".json", scstr); File.WriteAllText(Application.dataPath + "/Resources/Json/sc/" + sc.sub_name + ".json", scstr); } //the products inside the current path, not including the folder FileInfo[] files = dir.GetFiles(); foreach (FileInfo f in files) { if (string.Equals(f.Extension, ".DS_Store")) { continue; } if (string.Equals(f.Extension, ".prefab")) { //product in main category CategoryProduct cp = new CategoryProduct(); cp.category_id = mc.id; cp.sku = f.Name.Substring(0, f.Name.Length - f.Extension.Length); Debug.Log("cp.sku = " + cp.sku); mc.Products.Add(cp); //product in main category Product p = new Product(); p.sku = f.Name.Substring(0, f.Name.Length - f.Extension.Length); p.queue = productQueue++; p.category_id = mc.id; p.category_name = mc.name; string pstr = JsonConvert.SerializeObject(p); Debug.Log("out: " + pstr); // string filePath = Application.dataPath + "/Resources/Json/" + mc.id + "/mp"; string filePath = Application.dataPath + "/Resources/Json/Products/"; if (!File.Exists(filePath)) { Directory.CreateDirectory(filePath); } // File.WriteAllText(Application.dataPath + "/Resources/Json/" + mc.id + "/mp/" + p.sku + ".json", pstr); File.WriteAllText(Application.dataPath + "/Resources/Json/Products/" + p.sku + ".json", pstr); } } //mc string mcstr = JsonConvert.SerializeObject(mc); string mcfilePath = Application.dataPath + "/Resources/Json/mc/"; if (!File.Exists(mcfilePath)) { Directory.CreateDirectory(mcfilePath); } Debug.Log("mcout: " + mcstr); File.WriteAllText(Application.dataPath + "/Resources/Json/mc/" + mc.id + ".json", mcstr); clist.Add(mc); } string str = JsonConvert.SerializeObject(clist); Debug.Log("out: " + str); File.WriteAllText(Application.dataPath + "/Resources/Products/webproducts.json", str); }
//public void AddNewShareSkill() internal void AddNewSkill() { { #region Enter the deatils //Click on Share Skill button Thread.Sleep(1000); ShareSkills.Click(); Thread.Sleep(1000); //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkills"); // Enter Title Title.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title")); Base.test.Log(LogStatus.Info, "Title has been successfully entered"); //Enter description Description.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Description")); Base.test.Log(LogStatus.Info, "Description has been successfully entered"); //click on category dropdown menu Thread.Sleep(500); Category.Click(); Thread.Sleep(1000); //Select the category Thread.Sleep(500); ProgrammingandTech.Click(); Thread.Sleep(500); //Click on subcatogory drop down option Thread.Sleep(1000); SubCategory.Click(); //Select the Sub-Category option Thread.Sleep(500); QA.Click(); Thread.Sleep(500); //Enter Tags Tags.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); Tags.SendKeys(Keys.Enter); Base.test.Log(LogStatus.Info, "TagName has been successfully entered"); //Select service type //ServiceTypeHourly.Click(); if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "Hourly basis service") { ServiceTypeHourly.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Service Type") == "One-off service") { ServiceTypeOneOff.Click(); } //Select Location Type //LocationTypeOnline.Click(); if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "Online") { LocationTypeOnline.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Location Type") == "On-site") { LocationTypeOnsite.Click(); } //Select the date Thread.Sleep(1000); StartDate.SendKeys(Keys.Delete); Thread.Sleep(2000); StartDate.SendKeys(Keys.Backspace); Thread.Sleep(1000); StartDate.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Date")); Console.WriteLine("Start date is : " + GlobalDefinitions.ExcelLib.ReadData(2, "Start Date")); //StartDate.SendKeys("25-07-2019"); ////Select the end Date //EndDate.SendKeys("21-08-2019"); Thread.Sleep(1000); EndDate.SendKeys(Keys.Delete); EndDate.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "End Date")); Thread.Sleep(2000); Console.WriteLine("End date is : " + GlobalDefinitions.ExcelLib.ReadData(2, "End Date")); //Select the Days available SelectDays.Click(); Thread.Sleep(500); //Select starttime Thread.Sleep(1000); StartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Time")); Thread.Sleep(2000); Console.WriteLine("Start Time is : " + GlobalDefinitions.ExcelLib.ReadData(2, "Start Time")); //StartTime.SendKeys("12:00PM"); //Select EndTime Thread.Sleep(1000); EndTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "End Time")); Console.WriteLine("End Time is : " + GlobalDefinitions.ExcelLib.ReadData(2, "End Time")); //EndTime.SendKeys("3:00PM"); //Select Skill Trade Credit.Click(); Thread.Sleep(500); if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Skill-exchange") { Skillstrade.Click(); Skillstrade.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade")); Skillstrade.SendKeys(Keys.Enter); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade") == "Credit") { CreditAmount.Click(); CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Credit Amount")); CreditAmount.SendKeys(Keys.Enter); //Enter credit amount // CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Credit Amount")); //Select the stats // StatusActive.Click(); //Thread.Sleep(500); //select Work Sample Sample.Click(); AutoItX3 fileupload = new AutoItX3(); fileupload.WinActivate("Open"); Thread.Sleep(3000); fileupload.Send(@"C:\Users\harpr\OneDrive\Documents\Testing.jpg"); Thread.Sleep(1000); fileupload.Send("{ENTER}"); //Thread.Sleep(4000); Console.WriteLine("File has been uploaded successfully"); if (GlobalDefinitions.ExcelLib.ReadData(2, "Status") == "Active") { Active.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "Status") == "Hidden") { Hidden.Click(); } //Save the Share Skill Thread.Sleep(500); Save.Click(); Thread.Sleep(500); //Verify if newShared skill is saved Thread.Sleep(3000); string ShareSkillSucess = Global.GlobalDefinitions.driver.FindElement(By.XPath("//th[contains(text(),'Image')]")).Text; if (ShareSkillSucess == "Image") { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Saved Skill Successful"); } else { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Saving Skill Unsuccessful"); } } } #endregion }
public ActionResult Update(SubCategory model) { sub.Update(model); return(RedirectToAction("Index")); }
private SubCategory GetSubCategory(MongodbDatabaseDescription description, ServerInfo serverInfo) { try { var subCategory = new SubCategory() { DatabasePrefix = description.DatabasePrefix, DisplayName = description.DisplayName, Name = description.Name, TableNames = new List<string>(), TypeFullName = description.TypeFullName, }; subCategory.TableNames = serverInfo.Databases .Where(database => database.DatabaseName.StartsWith(description.DatabasePrefix)) .SelectMany(database => database.Collections).Select(collection => collection.CollectionName).Distinct().ToList(); return subCategory; } catch (Exception ex) { LocalLoggingService.Error("{0} {1} {2} {3}", MongodbServerConfiguration.ModuleName, "MongodbServer_Slave", "GetSubCategory", ex.Message); throw; } }
private static int countSubCategoryPharmacyInteractions(DatabaseDataContext db, SubCategory subCat) { int interCnt = 0; var query = (from inter in db.InteractionPharmacyPharmacies where inter.PharmacyChemical1.SubCategory.subCategoryName == subCat.subCategoryName select inter.PharmacyChemical); interCnt += query.Count(); var query0 = (from inter in db.InteractionPharmacyPharmacies where inter.PharmacyChemical.SubCategory.subCategoryName == subCat.subCategoryName select inter.PharmacyChemical1); interCnt += query0.Count(); var query1 = (from inter in db.InteractionPharmacySubCategories where inter.PharmacyChemical.SubCategory.subCategoryName == subCat.subCategoryName select inter.subCategoryName); foreach (String subCatQ2 in query1) { var query3 = from phar in db.PharmacyChemicals where phar.subCategoryName == subCatQ2 select phar; interCnt += query3.Count(); } var query2 = (from inter in db.InteractionPharmacySubCategories where inter.SubCategory.subCategoryName == subCat.subCategoryName select inter); interCnt += query2.Count(); return interCnt; }
/// <summary> /// Initializes a new instance of the <see cref="SubCharacteristics"/> class. /// </summary> /// <param name="key"> /// The key. /// </param> /// <param name="name"> /// The name. /// </param> public SubCharacteristics(SubCategory key, string name) { this.Key = key; this.Name = name; }
public ActionResult AddSubCategory(SubcategoryModel model) { if (ModelState.IsValid) { using (ClothesShopEntities entity = new ClothesShopEntities()) { if (entity.Categories.Where(category => category.ID == model.CategoryID).Count() != 0) { if (entity.SubCategories.Where(subcategory => subcategory.SubCategoryName == model.SubcategoryName && subcategory.CategoryID == model.CategoryID).Count() == 0) { SubCategory newSubcategory = new SubCategory() { SubCategoryName = model.SubcategoryName, CategoryID = model.CategoryID }; entity.AddToSubCategories(newSubcategory); entity.SaveChanges(); } else { ModelState.AddModelError("", "A subcategory with the same name already exists."); } } else { ModelState.AddModelError("", "A category with the given ID does not exist."); } } } return RedirectToAction("SubCategories"); }
public void RenderSubCategories(Category category) { Vector2 tempSpacing = new Vector2(95, 26); this.ItemsList.GetComponent <GridLayoutGroup>().spacing = tempSpacing; this.BackButton.SetActive(true); this.ClearItemsList(); List <SubCategory> subItems = new List <SubCategory>(); SubCategory tempItem; switch (category) { // case Category.ARMY: // subItems = new SubCategory[] {SubCategory.BARRACK, SubCategory.CAMP, SubCategory.BOAT}; // break; case Category.DECORATIONS: tempItem = new SubCategory("TREE1", 3); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 5; subItems.Add(tempItem); tempItem = new SubCategory("TREE2", 2); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 5; subItems.Add(tempItem); tempItem = new SubCategory("TREE3", 3); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 5; subItems.Add(tempItem); tempItem = new SubCategory("CoconutTree", 3); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 5; subItems.Add(tempItem); break; // case Category.DEFENCE: // subItems = new SubCategory[] {SubCategory.CANNON, SubCategory.TOWER}; // break; case Category.OTHER: tempItem = new SubCategory("TOWN_CENTER", 3); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 40; tempItem.reqMap[DataBaseManager.WOOD_RESOURCE_NAME] = 25; subItems.Add(tempItem); tempItem = new SubCategory("BUILDER_HUT", 2); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 25; tempItem.reqMap[DataBaseManager.WOOD_RESOURCE_NAME] = 15; subItems.Add(tempItem); tempItem = new SubCategory("WALL", 3); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 5; subItems.Add(tempItem); tempItem = new SubCategory("Tent", 3); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 5; tempItem.reqMap[DataBaseManager.WOOD_RESOURCE_NAME] = 10; tempItem.reqMap[DataBaseManager.LEAVES_RESOURCE_NAME] = 5; subItems.Add(tempItem); break; case Category.RESOURCES: tempItem = new SubCategory("ELIXIR_COLLECTOR", 3); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 15; subItems.Add(tempItem); tempItem = new SubCategory("ELIXIR_STORAGE", 3); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 15; subItems.Add(tempItem); tempItem = new SubCategory("GOLD_MINE", 3); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 15; subItems.Add(tempItem); tempItem = new SubCategory("GOLD_STORAGE", 2); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 15; subItems.Add(tempItem); tempItem = new SubCategory("WINDMILL", 3); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 15; subItems.Add(tempItem); break; case Category.TREASURE: tempItem = new SubCategory("GEMS", 3); tempItem.reqMap[DataBaseManager.GOLD_RESOURCE_NAME] = 15; tempItem.reqMap[DataBaseManager.WOOD_RESOURCE_NAME] = 10; subItems.Add(tempItem); break; } for (int index = 0; index < subItems.Count; index++) { GameObject inst = Utilities.CreateInstance(this.SubCategoryItem, this.ItemsList, true); inst.GetComponent <SubCategoryItemScript>().SetSubCategory(subItems[index]); } RectTransform rt = this.ItemsList.GetComponent <RectTransform>(); Vector2 sizeDelta = this.ItemsList.GetComponent <RectTransform>().sizeDelta; sizeDelta.x = subItems.Count * 250 + subItems.Count * this.ItemsList.GetComponent <GridLayoutGroup>().spacing.x; rt.sizeDelta = sizeDelta; this.ResetScrollPosition(); }
private async Task <SubCategoryAndCategoryViewModel> CreateSubCategoryAndCategoryViewModelInstance(SubCategory subCategory = null) { return(new SubCategoryAndCategoryViewModel() { CategoryList = await _db.Category.ToListAsync(), SubCategory = subCategory ?? new SubCategory(), SubCategoryList = await _db.SubCategory.OrderBy(s => s.Name).Select(s => s.Name).ToListAsync() }); }
async private Task getProducts(SubCategory category) { /* ObservableCollection<Product> products = await CategoryDataService.Instance.GetItems(category); * vm.Products = products; */ }
public void PopulateProductsInfoBySubcategory(StardogConnector context, SubCategory s) { var queryUrl = context.Query("PREFIX t: <http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#> SELECT ?ind ?url WHERE { ?ind t:Has_URL ?url. ?ind rdf:type t:" + s.SubCategoryName + " } ") as SparqlResultSet; if (queryUrl != null) { foreach (var res in queryUrl.Results) { var p = s.Products.FirstOrDefault(f => f.URI.ToLower() == res["ind"].ToString().ToLower()); if (p != null) { p.Url = res["url"].ToString(); } } } var queryBuyUrl = context.Query("PREFIX t: <http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#> SELECT ?ind ?url WHERE { ?ind t:Has_buy_url ?url. ?ind rdf:type t:" + s.SubCategoryName + " } ") as SparqlResultSet; if (queryBuyUrl != null) { foreach (var res in queryBuyUrl.Results) { var p = s.Products.FirstOrDefault(f => f.URI.ToLower() == res["ind"].ToString().ToLower()); if (p != null) { p.BuyUrl = res["url"].ToString(); } } } var queryColours = context.Query("PREFIX t: <http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#> SELECT ?ind ?c WHERE { ?ind t:Has_colour ?c. ?ind rdf:type t:" + s.SubCategoryName + " } ") as SparqlResultSet; if (queryColours != null) { foreach (var res in queryColours.Results) { var p = s.Products.FirstOrDefault(f => f.URI.ToLower() == res["ind"].ToString().ToLower()); if (p != null) { if (p.Colour == null) { p.Colour = new List <string>(); } p.Colour.Add(res["c"].ToString().Substring("http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#".Length)); } } } var querySeason = context.Query("PREFIX t: <http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#> SELECT ?ind ?s WHERE { ?ind t:Is_from_season ?s. ?ind rdf:type t:" + s.SubCategoryName + " } ") as SparqlResultSet; if (querySeason != null) { foreach (var res in querySeason.Results) { var p = s.Products.FirstOrDefault(f => f.URI.ToLower() == res["ind"].ToString().ToLower()); if (p != null) { if (p.Season == null) { p.Season = new List <string>(); } p.Season.Add(res["s"].ToString().Substring("http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#".Length)); } } } var queryBrand = context.Query("PREFIX t: <http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#> SELECT ?ind ?s WHERE { ?ind t:Is_from ?s. ?ind rdf:type t:" + s.SubCategoryName + " } ") as SparqlResultSet; if (queryBrand != null) { foreach (var res in queryBrand.Results) { var p = s.Products.FirstOrDefault(f => f.URI.ToLower() == res["ind"].ToString().ToLower()); if (p != null) { if (p.Brand == null) { p.Brand = new List <string>(); } p.Brand.Add(res["s"].ToString().Substring("http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#".Length)); } } } var queryStyle = context.Query("PREFIX t: <http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#> SELECT ?ind ?s WHERE { ?ind t:Has_style ?s. ?ind rdf:type t:" + s.SubCategoryName + " } ") as SparqlResultSet; if (queryStyle != null) { foreach (var res in queryStyle.Results) { var p = s.Products.FirstOrDefault(f => f.URI.ToLower() == res["ind"].ToString().ToLower()); if (p != null) { if (p.Style == null) { p.Style = new List <string>(); } p.Style.Add(res["s"].ToString().Substring("http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#".Length)); } } } var queryGender = context.Query("PREFIX t: <http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#> SELECT ?ind ?s WHERE { ?ind t:For_gender ?s. ?ind rdf:type t:" + s.SubCategoryName + " } ") as SparqlResultSet; if (queryGender != null) { foreach (var res in queryGender.Results) { var p = s.Products.FirstOrDefault(f => f.URI.ToLower() == res["ind"].ToString().ToLower()); if (p != null) { if (p.Gender == null) { p.Gender = new List <string>(); } p.Gender.Add(res["s"].ToString().Substring("http://www.semanticweb.org/bobo/ontologies/2015/0/Adriana#".Length)); } } } }
/// <summary> /// get sub categories for all selected categories. /// </summary> /// <param name="sessionKey">string</param> /// <param name="categorylist">string</param> /// <returns>string</returns> public ResponseObjectForAnything GetSubCatsbyCategories(string sessionKey, string categorylist) { List<SubCategory> lstsubcategory = new List<SubCategory>(); AuthenticationEngine authEngine = new AuthenticationEngine(); bool isValid = authEngine.IsValidSession(sessionKey); ResponseObjectForAnything responseObject = new ResponseObjectForAnything(); int count = 0; try { if (isValid) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("usp_GetSubCategoriesByCategories"); using (IDataReader dr = db.ExecuteReader(dbCommand)) { while (dr.Read()) { SubCategory subcategory = new SubCategory(); if (dr["SubCategoryID"] != DBNull.Value) { subcategory.SubCategoryID = Convert.ToInt32(dr["SubCategoryID"]); } if (dr["SubCategoryName"] != DBNull.Value) { subcategory.SubCategoryName = dr["SubCategoryName"].ToString(); } lstsubcategory.Add(subcategory); count++; } } responseObject.ResultCode = "SUCCESS"; responseObject.ResultObjectJSON = Serializer.ObjectToJSON(lstsubcategory); responseObject.ResultObjectRecordCount = count; if (responseObject.ResultObjectRecordCount == 0) { responseObject.ResultMessage = "No subcategories configured."; } } } catch (Exception ex) { responseObject.ResultCode = "ERROR"; responseObject.ResultMessage = ex.Message; CustomException exc = new CustomException(ex.ToString(), this.ToString(), "GetSubCatsbyCategories", System.DateTime.Now); ExceptionManager.PublishException(exc); } return (responseObject); }
protected override void Seed(DataAccess.Context.ProjectDbContext context) { Category category1 = null; Category category2 = null; Category category3 = null; if (!context.Categories.Any()) { List <Category> categories = new List <Category>() { new Category { CategoryName = "Elektronik", MasterId = 1, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, }, new Category { CategoryName = "Kitap", MasterId = 2, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, }, new Category { CategoryName = "Oyun", MasterId = 3, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, } }; context.Categories.AddRange(categories); context.SaveChanges(); category1 = categories.Where(x => x.CategoryName == "Elektronik").FirstOrDefault(); category2 = categories.Where(x => x.CategoryName == "Kitap").FirstOrDefault(); category3 = categories.Where(x => x.CategoryName == "Oyun").FirstOrDefault(); } SubCategory subCategory1 = null; SubCategory subCategory2 = null; SubCategory subCategory3 = null; if (!context.SubCategories.Any()) { subCategory1 = new SubCategory { CategoryId = category1.ID, GetCategory = category1, SubCategoryName = "Telefon", Description = "asdadasdf", MasterId = 1 }; subCategory2 = new SubCategory { CategoryId = category2.ID, GetCategory = category2, SubCategoryName = "Roman", Description = "asdadasdf", MasterId = 2 }; subCategory3 = new SubCategory { CategoryId = category3.ID, GetCategory = category3, SubCategoryName = "Savaþ", Description = "asdadasdf", MasterId = 3 }; List <SubCategory> subCategories = new List <SubCategory> { subCategory1, subCategory2, subCategory3 }; context.SubCategories.AddRange(subCategories); context.SaveChanges(); } if (!context.Products.Any()) { List <Product> products = new List <Product>() { new Product { ImagePath = "IPhone12.jpg", MasterId = 1, SubCategory = subCategory1, SubCategoryId = subCategory1.ID, ProductName = "IPhone 12", UnitPrice = 20000, UnitsInStock = 45 }, new Product { ImagePath = "ZFold2.jpg", MasterId = 2, SubCategory = subCategory1, SubCategoryId = subCategory1.ID, ProductName = "Cesur Yeni Dünya", UnitPrice = 18000, UnitsInStock = 50 }, new Product { ImagePath = "PS5.jpg", MasterId = 3, SubCategory = subCategory3, SubCategoryId = subCategory3.ID, ProductName = "PS 5", UnitPrice = 8000, UnitsInStock = 15 } }; context.Products.AddRange(products); context.SaveChanges(); } }
private void LoadChangedSubCategories(int categoryId) { SubCategory subCategory = new SubCategory(); subCategory.ProductCategoryId = categoryId; ProcessGetSubCategoryByProductCategoryId processGetSubCategory = new ProcessGetSubCategoryByProductCategoryId(); processGetSubCategory.SubCategory = subCategory; try { processGetSubCategory.Invoke(); } catch (Exception ex) { Response.Redirect("~/ErrorPage.aspx"); } ddlSubCategory.DataTextField = "SubCategoryDisplayName"; ddlSubCategory.DataValueField = "SubCategoryId"; ddlSubCategory.DataSource = processGetSubCategory.ResultSet; ddlSubCategory.DataBind(); }
public frmSubCategory(SubCategory _ObjSubCategory) { InitializeComponent(); ObjSubCategory = _ObjSubCategory; }
public ActionResult CreateSubCode(SubCategory subCategory) { if (ModelState.IsValid) { subCategory.IsMenu = false; try { if (_categoryService.GetCategory(subCategory.Code) == null) { _categoryService.CreateCategory(subCategory); _categoryService.SaveCategory(); return RedirectToAction("Index"); } else { ModelState.AddModelError("Code", ErrorMessages.CATEGORYCODE_EXIST); } } catch (Exception e) { ModelState.AddModelError("", e); } } return View(subCategory); }
public IActionResult PostSubCategory([FromBody] SubCategory sc) { objds.CreateSubCategory(sc); return(new OkResult()); }
public PartialViewResult Detail(Guid id) { SubCategory temp = SubCategoryService.GetById(id); return(PartialView(temp)); }
public void AddNewSkill() { #region Navigate to Share Skills Page // Click on Share Skills Page ShareSkill.WaitForElementClickable(_driver, 60); ShareSkill.Click(); //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkills"); #endregion #region Enter Title Title.WaitForElementClickable(_driver, 60); //Enter the data in Title textbox Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "title")); #endregion #region Enter Description //Enter the data in Description textbox Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EnterDescription")); #endregion #region Category Drop Down // Click on Category Dropdown Category.Click(); // Select Category from Category Drop Down var SelectElement = new SelectElement(Category); SelectElement.SelectByText((GlobalDefinitions.ExcelLib.ReadData(2, "category"))); // Click on Sub-Category Dropdown SubCategory.Click(); //Select Sub-Category from the Drop Down var SelectElement1 = new SelectElement(SubCategory); SelectElement1.SelectByText((GlobalDefinitions.ExcelLib.ReadData(2, "subcategory"))); #endregion #region Tags // Eneter Tag Tag.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "TagName")); Tag.SendKeys(Keys.Enter); #endregion #region Service Type Selection // Service Type Selection if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "Hourly basis service") { ServiceTypeHourly.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType") == "One-off service") { ServiceTypeOnOff.Click(); } #endregion #region Select Location Type // Location Type Selection if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "On-site") { LocationTypeOnsite.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectLocationType") == "Online") { LocationTypeOnline.Click(); } #endregion #region Select Available Dates from Calendar // Select Start Date StartDate.Click(); // Select End Date EndDate.Click(); #endregion #region Select Skill Trade // Select Skill Trade if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Skill-exchange") { RequiredSkills.Click(); RequiredSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "ExchangeSkill")); RequiredSkills.SendKeys(Keys.Enter); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "SelectSkillTrade") == "Credit") { CreditAmount.Click(); CreditAmount.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "AmountInExchange")); CreditAmount.SendKeys(Keys.Enter); } #endregion #region Select User Status // Select User Status if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Active") { StatusActive.Click(); } else if (GlobalDefinitions.ExcelLib.ReadData(2, "UserStatus") == "Hidden") { StatusHidden.Click(); } #endregion #region Add Work Sample //Work Sample upload button path IWebElement upload = _driver.FindElement(By.XPath("//*[@id='selectFile']")); // Uploading File path var GetCurrentDirectory = Directory.GetCurrentDirectory(); String path = GetCurrentDirectory + @"\MarsFramework\Upload Files\Samplework.txt"; upload.SendKeys(path); #endregion #region Save / Cancel Skill // Save or Cancel New Skill if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Save") { SaveShareSkills.Click(); } else if (Global.GlobalDefinitions.ExcelLib.ReadData(2, "SaveOrCancel") == "Cancel") { CancelShareSkills.Click(); } #endregion #region Check whether New skill created sucessfully string ShareSkillSucess = _driver.FindElement(By.LinkText("Manage Listings")).Text; if (ShareSkillSucess == "Manage Listings") { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Shared Skill Successful"); } else { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Share Skill Unsuccessful"); } #endregion }
public void Add(SubCategory subCategory) { subCategoryService.Add(subCategory); //return RedirectToAction("Index"); }
public EditSubCategory(SubCategory category) { this.category = category; }
private void BindDDLSubcategory() { SubCategory Subcateogory = new SubCategory(); DataSet ds = new DataSet(); string categoryid = ddlCategory.SelectedItem.Value; ds = Subcateogory.GetList(categoryid); ddlSubCategory.DataSource = ds; ddlSubCategory.DataValueField = "subcategoryid"; ddlSubCategory.DataTextField = "name"; ddlSubCategory.DataBind(); }
public Task <List <SubCategory> > GetSubcategoryByCatid(SubCategory obj) { return(_SubCategoryRepository.GetSubcategoryByCatid(obj)); }
public void Update(SubCategory subCat) { _db.SubCategory.Update(subCat); }
public Task <List <SubCategory> > GetSideSubcategory(SubCategory obj) { return(_SubCategoryRepository.GetSideSubcategory(obj)); }
public async Task GetAllByCategoryId_ShouldReturnCorrectly() { var categoryName = "test"; var category = new Category { Name = categoryName, }; await context.Categories.AddAsync(category); await context.SaveChangesAsync(); var subCategoryOne = new SubCategory { Name = "test", CategoryId = category.Id, }; var subCategoryTwo = new SubCategory { Name = "test2", CategoryId = category.Id, }; var subCategoryThree = new SubCategory { Name = "test3", CategoryId = "anotherId", }; await context.SubCategories.AddAsync(subCategoryOne); await context.SubCategories.AddAsync(subCategoryTwo); await context.SubCategories.AddAsync(subCategoryThree); await context.SaveChangesAsync(); var subCategories = service.GetAllByCategoryId(category.Id).ToList(); var expectedSubCategoryOne = new SubCategoryServiceModel() { Name = subCategoryOne.Name, CategoryId = subCategoryOne.CategoryId, Id = subCategoryOne.Id, }; var expectedSubCategoryTwo = new SubCategoryServiceModel { Name = subCategoryTwo.Name, CategoryId = subCategoryTwo.CategoryId, Id = subCategoryTwo.Id, }; var expectedCategoriesCount = 2; var actualCategoriesCount = subCategories.Count; Assert.AreEqual(expectedCategoriesCount, actualCategoriesCount); AssertEx.PropertyValuesAreEquals(subCategories[0], expectedSubCategoryOne); AssertEx.PropertyValuesAreEquals(subCategories[1], expectedSubCategoryTwo); }
public List <Blog> GetBlogs(SubCategory category) { throw new NotImplementedException(); }
/// <summary> /// Converts this class to its string form. /// </summary> /// <returns>string representation of this class</returns> public override string ToString() { return(string.Format("{1}{0}{2}", DELIMETER, Category.ToString(), SubCategory.ToString())); }
protected void uiGridViewSubCats_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditSubCat") { SubCategory subcat = new EGEMech.BLL.SubCategory(); subcat.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument)); CurrentSubCategory = subcat; uiDropDownListCategory.SelectedValue = subcat.CategoryID.ToString(); uiTextBoxName.Text = subcat.Name; uiPanelViewCats.Visible = false; uiPanelEdit.Visible = true; } else if (e.CommandName == "DeleteSubCat") { try { SubCategory cat = new EGEMech.BLL.SubCategory(); cat.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument)); cat.MarkAsDeleted(); cat.Save(); BindData(); } catch (Exception ex) { uiLabelError.Visible = true; } } }
static void NewCreateLocalData() { string[] paths = Directory.GetDirectories(Application.dataPath + "/Resources/Products/"); int pIndex = 1; List <Category> clist = new List <Category>(); Debug.Log("paths.Length = " + paths.Length); for (int i = 0; i < paths.Length; i++) { DirectoryInfo dir = new DirectoryInfo(paths[i]); Debug.Log("dir = " + dir); Category mc = new Category(); mc.id = i; mc.name = dir.Name; Debug.Log("mc.name = " + mc.name); mc.SubCategorys = new List <SubCategory>(); mc.Products = new List <CategoryProduct>(); //the sub path (second layer) List <SubCategory> subclist = new List <SubCategory>(); string[] subPaths = Directory.GetDirectories(paths[i]); Debug.Log("subPaths.Length = " + subPaths.Length); for (int j = 0; j < subPaths.Length; j++) { DirectoryInfo subDir = new DirectoryInfo(subPaths[j]); Debug.Log("subDir = " + subDir); SubCategory sc = new SubCategory(); sc.sub_id = mc.id * 100 + j; //the subCatagory id is made up from parent_id and its own current id sc.sub_name = subDir.Name; sc.parent_id = mc.id; sc.parent_name = mc.name; FileInfo[] subFiles = subDir.GetFiles(); foreach (FileInfo f in subFiles) { if (string.Equals(f.Extension, ".DS_Store")) { continue; } if (string.Equals(f.Extension, ".prefab")) { CategoryProduct cp = new CategoryProduct(); cp.category_id = sc.sub_id; cp.sku = f.Name.Substring(0, f.Name.Length - f.Extension.Length); Debug.Log("cp.sku = " + cp.sku); sc.Products.Add(cp); } } // subclist.Add(sc); mc.SubCategorys.Add(sc); } // mc.SubCategorys = subclist; //the products inside the current path, not including the folder FileInfo[] files = dir.GetFiles(); foreach (FileInfo f in files) { Debug.Log("ffffffffff = " + f.ToString()); if (string.Equals(f.Extension, ".DS_Store")) { continue; } if (string.Equals(f.Extension, ".prefab")) { CategoryProduct cp = new CategoryProduct(); cp.category_id = mc.id; cp.sku = f.Name.Substring(0, f.Name.Length - f.Extension.Length); Debug.Log("cp.sku = " + cp.sku); mc.Products.Add(cp); } // if (!string.Equals(f.Extension, ".meta")) // { // CategoryProduct cp = new CategoryProduct(); // cp.category_id = c.id; // cp.position = 1; // cp.sku = f.Name.Substring(0, f.Name.Length - f.Extension.Length); // Debug.Log("cp.sku = " + cp.sku); // c.Products.Add(cp); // } } string mcstr = JsonConvert.SerializeObject(mc); string filePath = Application.dataPath + "/Resources/Json/mc/"; if (!File.Exists(filePath)) { Directory.CreateDirectory(filePath); } Debug.Log("mcout: " + mcstr); File.WriteAllText(Application.dataPath + "/Resources/Json/mc/" + mc.id + ".json", mcstr); clist.Add(mc); } string str = JsonConvert.SerializeObject(clist); Debug.Log("out: " + str); File.WriteAllText(Application.dataPath + "/Resources/Products/products.json", str); }
private static int countSubCategoryPharmacyComercials(DatabaseDataContext db, SubCategory subCat) { int cnt = 0; var query = (from phar in db.PharmacyCommercials where phar.PharmacyChemical.subCategoryName == subCat.subCategoryName select phar); cnt = query.Count(); return cnt; }
private static int countSubCategoryPharmacyComercialInteractions(DatabaseDataContext db, SubCategory subCat) { int interCnt = 0; var query = (from phar in db.PharmacyCommercials where phar.PharmacyChemical.SubCategory.subCategoryName == subCat.subCategoryName select phar); foreach (PharmacyCommercial phar in query) { String pharCname = phar.chemicalName; String pharSubCatName =(from chem in db.PharmacyChemicals where chem.chemicalName == pharCname select chem.subCategoryName).First(); var query1 = (from inter in db.InteractionPharmacyPharmacies where inter.pharmacyname1 == pharCname select inter.PharmacyChemical1); if (query1.Count() > 0) { foreach (PharmacyChemical chem in query1) { interCnt += countPharmacyComercials(db, chem); } } var query2 = (from inter in db.InteractionPharmacyPharmacies where inter.pharmacyname2 == pharCname select inter.PharmacyChemical); if (query2.Count() > 0) { foreach (PharmacyChemical chem in query2) { interCnt += countPharmacyComercials(db, chem); } } var query3 = (from inter in db.InteractionPharmacySubCategories where inter.chemicalName == pharCname select inter.SubCategory); if (query3.Count() > 0) { foreach (SubCategory subcat in query3) { interCnt += countSubCategoryPharmacyComercials(db, subcat); } } var query4 = (from inter in db.InteractionPharmacySubCategories where inter.subCategoryName == pharSubCatName select inter.PharmacyChemical); if (query4.Count()>0) { foreach (PharmacyChemical chem in query4) { interCnt += countPharmacyComercials(db, chem); } } } return interCnt; }
public void RunEdits(SubCategory Entity) { throw new NotImplementedException(); }
public ActionResult CreateSubCode(int mainCode) { SubCategory subMenu = new SubCategory(); subMenu.ParentCategoryCode = mainCode; return View(subMenu); }
public void SetEdits(SubCategory Entity) { }
private void LoadSubCategories() { Product prod = new Product(); prod.ProductId = int.Parse(Request.QueryString["ProductId"]); ProcessGetProductByProductId getProduct = new ProcessGetProductByProductId(); getProduct.Product = prod; getProduct.Invoke(); SubCategory subCategory = new SubCategory(); subCategory.ProductCategoryId = getProduct.Product.ProductCategoryId; ProcessGetSubCategoryByProductCategoryId processGetSubCategory = new ProcessGetSubCategoryByProductCategoryId(); processGetSubCategory.SubCategory = subCategory; try { processGetSubCategory.Invoke(); } catch (Exception ex) { Response.Redirect("~/ErrorPage.aspx"); } ddlSubCategory.DataTextField = "SubCategoryDisplayName"; ddlSubCategory.DataValueField = "SubCategoryId"; ddlSubCategory.DataSource = processGetSubCategory.ResultSet; ddlSubCategory.DataBind(); }
public void ImportIntoClass(FileStream fileStream, string pathAndFile) { string[] contractProps = new string[6]; var companyNames = _context.Company.Select(a => a.CompanyName); var categories = _context.MainCategory.Select(a => a.CategoryName); var subcategories = _context.SubCategory.Select(a => a.SubcategoryName); fileStream = new FileStream(pathAndFile, FileMode.Open); StreamReader reader = new StreamReader(fileStream); string headLine = reader.ReadLine(); while (!reader.EndOfStream) { bool clientIsExist = false; bool contractorIsExist = false; bool categoryIsExist = false; bool subcategoryIsExist = false; var line = reader.ReadLine(); contractProps = line.Split(','); foreach (var item in companyNames) { if (item == contractProps[3]) { clientIsExist = true; } if (item == contractProps[4]) { contractorIsExist = true; } } foreach (var item in categories) { if (item == contractProps[1]) { categoryIsExist = true; } } if (categoryIsExist == false) { MainCategory category = new MainCategory { CategoryId = GenerateCategoryId(), CategoryName = contractProps[1] }; _context.Add(category); _context.SaveChanges(); } foreach (var item in subcategories) { if (item == contractProps[2]) { subcategoryIsExist = true; } } if (subcategoryIsExist == false) { SubCategory subCategory = new SubCategory { SubcategoryId = GenerateSubcategoryId(), CategoryId = _context.MainCategory.Where(a => a.CategoryName == contractProps[1]).Select(a => a.CategoryId).FirstOrDefault(), SubcategoryName = contractProps[2] }; _context.Add(subCategory); _context.SaveChanges(); } if (clientIsExist == false) { Company clientCompany = new Company { CompanyId = GenerateComId(), CompanyName = contractProps[3] }; Client client = new Client { ClientId = clientCompany.CompanyId }; _context.Add(clientCompany); _context.Add(client); _context.SaveChanges(); } if (contractorIsExist == false) { Company contractorCompany = new Company { CompanyId = GenerateComId(), CompanyName = contractProps[4] }; Contractor contractor = new Contractor { ContractorId = contractorCompany.CompanyId, }; _context.Add(contractorCompany); _context.Add(contractor); _context.SaveChanges(); } Contract contract = new Contract { ContractId = GenerateContractId(), StartDate = DateTime.Parse(contractProps[9]), EndDate = DateTime.Parse(contractProps[10]) }; ContractDetail contractDetail = new ContractDetail { ContractId = contract.ContractId, ContractName = contractProps[0], CategoryId = _context.MainCategory.Where(a => a.CategoryName == contractProps[1]).Select(a => a.CategoryId).FirstOrDefault(), SubCategoryId = _context.SubCategory.Where(a => a.SubcategoryName == contractProps[2]).Select(a => a.SubcategoryId).FirstOrDefault(), ClientId = _context.Company.Where(a => a.CompanyName == contractProps[3]).Select(a => a.CompanyId).FirstOrDefault(), ContractorId = _context.Company.Where(a => a.CompanyName == contractProps[4]).Select(a => a.CompanyId).FirstOrDefault() }; try { if (ModelState.IsValid) { _context.Add(contract); _context.Add(contractDetail); _context.SaveChanges(); } } catch (Exception ex) { TempData["message"] = $"exception import: {ex.GetBaseException().Message}"; } //} } reader.Close(); TempData["message"] = "imorted"; }
private void BindData() { SubCategory cat = new SubCategory(); cat.GetAllSubCats(); uiGridViewSubCats.DataSource = cat.DefaultView; uiGridViewSubCats.DataBind(); }
public ActionResult Add(SubCategory subCategory) { subCategory.ID = Guid.NewGuid(); SubCategoryService.Add(subCategory); return(RedirectToAction("List")); }
public SubCategoryBL MapSubCategory(SubCategory subCategory) { return(Mapper.Map <SubCategory, SubCategoryBL>(subCategory)); }
/// <summary> /// The is sub char present. /// </summary> /// <param name="key"> /// The key. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool IsSubCharPresent(SubCategory key) { return this.Subchars.Any(subCharacteristicse => subCharacteristicse.Key.Equals(key)); }
private void fillSubCategory(int subCategoryCnt, DatabaseDataContext db) { foreach (Category tmpCat in db.Categories) { for (int i = 0; i < subCategoryCnt;i++ ) { SubCategory tmpitem = new SubCategory(); tmpitem.categoryName = tmpCat.categoryName; tmpitem.subCategoryName = randomName(rad.Next() % 20); db.SubCategories.InsertOnSubmit(tmpitem); } } db.SubmitChanges(); }
public JsonResult CopyQuestionMappingToCategory(string subCategoryId, string categoryId) { _logger.LogInformation($"Request to Insert Subcategory for {subCategoryId} and its Question Mapping to Category: {categoryId}"); try { if (isAdmin) { var subCat = _auditToolContext.SubCategory.Where(a => a.SubCatgId == Convert.ToInt32(subCategoryId) && a.IsActive == true).FirstOrDefault(); if (subCat != null && Convert.ToInt32(categoryId) > 0) { SubCategory category = new SubCategory { CatgId = Convert.ToInt32(categoryId), CreatedBy = _authService.LoggedInUserInfo().Result.LoggedInFullName, CreatedDate = DateTime.Now, ModifiedBy = _authService.LoggedInUserInfo().Result.LoggedInFullName, ModifiedDate = DateTime.Now, IsActive = true, SubCatgDescription = subCat.SubCatgDescription }; _auditToolContext.SubCategory.Add(category); var questionMapping = _auditToolContext.QuestionMapping.Where(a => a.SubCatgId == subCat.SubCatgId && a.IsActive == true).ToList(); foreach (var item in questionMapping) { QuestionMapping question = new QuestionMapping { SubCatg = category, SeqNumber = item.SeqNumber, QuestionId = item.QuestionId, IsActive = true, CreatedBy = _authService.LoggedInUserInfo().Result.LoggedInFullName, CreatedDate = DateTime.Now, ModifiedBy = _authService.LoggedInUserInfo().Result.LoggedInFullName, ModifiedDate = DateTime.Now }; _auditToolContext.QuestionMapping.Add(question); } int insertstatus = _auditToolContext.SaveChanges(); if (insertstatus > 0) { _logger.LogInformation($"Inserted Sucessfully."); } else { _logger.LogInformation($"Inserted failed."); } return(Json("")); } else { return(Json(new { Success = "False", responseText = "Subcategory not Found" })); } } } catch (Exception ex) { _logger.LogInformation($"Exception in CopyQuestionMappingToCategory method"); _log.WriteErrorLog(new LogItem { ErrorType = "Error", ErrorSource = "QuestionsController_CopyQuestionMappingToCategory", ErrorDiscription = ex.InnerException != null ? ex.InnerException.ToString() : ex.Message }); } return(Json(new { Success = "False", responseText = "Authorization Error" })); }