Beispiel #1
0
        public ActionResult Edit([FromQuery] int Id)
        {
            MroomtagInfo item = Mroomtag.GetItem(Id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            ViewBag.item = item;
            return(View());
        }
Beispiel #2
0
        public APIReturn _Add([FromForm] string Name, [FromForm] int[] mn_Mroom)
        {
            MroomtagInfo item = new MroomtagInfo();

            item.Name = Name;
            item      = Mroomtag.Insert(item);
            //关联 Mroom
            foreach (int mn_Mroom_in in mn_Mroom)
            {
                item.FlagMroom(mn_Mroom_in);
            }
            return(APIReturn.成功.SetData("item", item.ToBson()));
        }
Beispiel #3
0
        public APIReturn _Edit([FromQuery] int Id, [FromForm] string Name, [FromForm] int[] mn_Mroom)
        {
            MroomtagInfo item = Mroomtag.GetItem(Id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            item.Name = Name;
            int affrows = Mroomtag.Update(item);

            //关联 Mroom
            if (mn_Mroom.Length == 0)
            {
                item.UnflagMroomALL();
            }
            else
            {
                List <int> mn_Mroom_list = mn_Mroom.ToList();
                foreach (var Obj_mroom in item.Obj_mrooms)
                {
                    int idx = mn_Mroom_list.FindIndex(a => a == Obj_mroom.Id);
                    if (idx == -1)
                    {
                        item.UnflagMroom(Obj_mroom.Id);
                    }
                    else
                    {
                        mn_Mroom_list.RemoveAt(idx);
                    }
                }
                mn_Mroom_list.ForEach(a => item.FlagMroom(a));
            }
            if (affrows > 0)
            {
                return(APIReturn.成功.SetMessage($"更新成功,影响行数:{affrows}"));
            }
            return(APIReturn.失败);
        }