public APIReturn Post_insert([FromForm] string Keyname, [FromForm] string Name, [FromForm] ulong[] mn_Topics) { TagsInfo item = new TagsInfo(); item.Create_time = DateTime.Now; item.Keyname = Keyname; item.Name = Name; item = Tags.Insert(item); //关联 Topics foreach (ulong mn_Topics_in in mn_Topics) { item.FlagTopics(mn_Topics_in); } return(new APIReturn(0, "成功", "item", item.ToBson())); }
public APIReturn Put_update(uint?Id, [FromForm] string Keyname, [FromForm] string Name, [FromForm] ulong[] mn_Topics) { TagsInfo item = new TagsInfo(); item.Id = Id; item.Create_time = DateTime.Now; item.Keyname = Keyname; item.Name = Name; int affrows = Tags.Update(item); //关联 Topics if (mn_Topics.Length == 0) { item.UnflagTopicsALL(); } else { List <ulong> mn_Topics_list = mn_Topics.ToList(); foreach (TopicsInfo Obj_topics in item.Obj_topicss) { int idx = mn_Topics_list.FindIndex(a => a == Obj_topics.Id); if (idx == -1) { item.UnflagTopics(Obj_topics.Id); } else { mn_Topics_list.RemoveAt(idx); } } mn_Topics_list.ForEach(a => item.FlagTopics(a)); } if (affrows > 0) { return(new APIReturn(0, "成功")); } return(new APIReturn(99, "失败")); }