public IHttpActionResult PostMyCategory(MyCategory myCategory) { if (myCategory == null || string.IsNullOrEmpty(myCategory.user_id) || string.IsNullOrEmpty(myCategory.group_code) || myCategory.categorys == null || myCategory.categorys.Count <= 0) { return(BadRequest("参数不合规")); } var list = myCategory.categorys.Select(p => new data.stockcategory_user_map { cate_code = p.code, user_id = myCategory.user_id, group_code = myCategory.group_code }).ToList(); try { categoryService.AddMyCategory(list); versionService.UpdateUserDataVersion(myCategory.user_id, data.DataVersionCode.my_category.ToString(), myCategory.version); return(Ok <Message>(new Message() { success = true })); } catch (Exception ex) { return(this.InternalServerError(ex)); } }
public static void UploadData() { MyCompany.Find(); MyCategory.Find(); MyManufacturer.Find(Hardware.ComputerMake()); MyAssetModel.Find(Hardware.ComputerMake(), Hardware.ComputerModel()); MyAsset.Find(Hardware.ComputerName(), Hardware.ComputerMake(), Hardware.ComputerModel(), Hardware.SerialNumber()); }
private ObservableCollection <MyCategory> CreateCategories() { ObservableCollection <MyCategory> result = new ObservableCollection <MyCategory>(); result.Add(MyCategory.Create(0, "White category", Colors.White)); result.Add(MyCategory.Create(1, "Orange category", Colors.Orange)); result.Add(MyCategory.Create(2, "Red category", Colors.Red)); return(result); }
public object GetPropertyValue(MyCategory my, string name) { PropertyInfo[] properties = my.GetType().GetProperties(); foreach (var i in properties) { if (i.Name == name) { return(i.GetValue(my)); } } return(null); }
public ActionResult GetCategory(int id) { var data = context.Category.Find(id); MyCategory category = new MyCategory(); category.CategoryId = data.CategoryId; category.Category1 = data.Category1; category.Description = data.Description; if (data == null) { return(HttpNotFound()); } return(View("GetCategory", category)); }
protected void btnSave_Click(object sender, EventArgs e) { this.Validate(); int index = Convert.ToInt32(ViewState["EditedIndex"]); int id = Convert.ToInt32(ViewState["EditedId"]); RepeaterItem item = repCategories.Items[index]; MyCategory my = new MyCategory(); if (id != -1) { my = rep.GetEntityById(id) as MyCategory; } for (int i = 0; i < item.Controls.Count; i++) { TextBox t = item.Controls[i] as TextBox; if (t != null) { string propName = t.ToolTip; if (my.Name != t.Text) { my.Name = t.Text; } t.Style.Add("display", "none"); } } rep.Save(my); ViewState.Add("EditedId", -1); ViewState.Add("EditedIndex", -1); btnSave.Style.Add("display", "none"); btnCancel.Style.Add("display", "none"); isEditing = true; UpdateData(); }
/// <summary> /// Recursive method to process each level in the input string, creating a node if necessary /// and then calling itself to process the next level. /// </summary> private static bool AddNodesToTree(string[] titleArray, int thisIndex, Dictionary <string, MyCategory> priorDictionary) { if (thisIndex >= titleArray.Length) { return(false); } bool treeUpdated = false; // Create node entry in prior Dictionary if not already there string thisTitle = titleArray[thisIndex].Trim(); MyCategory thisNode; if (!priorDictionary.TryGetValue(thisTitle, out thisNode)) { thisNode = new MyCategory(thisTitle); priorDictionary.Add(thisTitle, thisNode); treeUpdated = true; } // Process the lower-level nodes using this recursive method return(AddNodesToTree(titleArray, ++thisIndex, thisNode.Children) | treeUpdated); }
protected void repCategories_ItemCommand(object source, RepeaterCommandEventArgs e) { #region Delete if (e.CommandName == "Delete") { int id = Convert.ToInt32(e.CommandArgument); rep.Delete(id); UpdateData(); } #endregion #region Edit if (e.CommandName == "Edit") { int id = Convert.ToInt32(e.CommandArgument); MyCategory my = rep.GetEntityById(id) as MyCategory; for (int i = 0; i < e.Item.Controls.Count; i++) { TextBox t = e.Item.Controls[i] as TextBox; if (t != null) { t.Style.Add("display", "block"); t.Text = my.Name; } } int index = -1; for (int i = 0; i < repCategories.Items.Count; i++) { if (repCategories.Items[i] == e.Item) { index = i; } } ViewState.Add("EditedId", id); ViewState.Add("EditedIndex", index); btnSave.Style.Add("display", "inline"); btnCancel.Style.Add("display", "inline"); isEditing = true; } #endregion #region Add if (e.CommandName == "Add") { List <MyCategory> users = rep.GetAll(); MyCategory my = new MyCategory(); users.Add(my); repCategories.DataSource = users; repCategories.DataBind(); RepeaterItem item = repCategories.Items.OfType <RepeaterItem>().ElementAt(repCategories.Items.Count - 1); for (int i = 0; i < item.Controls.Count; i++) { TextBox t = item.Controls[i] as TextBox; if (t != null) { t.Style.Add("display", "block"); object obj = my.Name; t.Text = (obj == null) ? "" : obj.ToString(); } } int index = -1; for (int i = 0; i < repCategories.Items.Count; i++) { if (repCategories.Items[i] == item) { index = i; } } ViewState.Add("EditedId", -1); ViewState.Add("EditedIndex", index); btnSave.Style.Add("display", "inline"); btnCancel.Style.Add("display", "inline"); isEditing = true; } #endregion }
private void Btn_Category_Click(object sender, EventArgs e) { Lbl_category.Text = MyCategory.Find(); Btn_Category.Enabled = false; }