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

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            ViewBag.item = item;
            return(View());
        }
Exemplo n.º 2
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.失败);
        }