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

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            ViewBag.item = item;
            return(View());
        }
Beispiel #2
0
        public APIReturn _Add([FromForm] int?Mtype_id, [FromForm] string Name, [FromForm] short?Number, [FromForm] string Reason, [FromForm] Et_mroomstateENUM?State, [FromForm] string Username, [FromForm] int[] mn_Mroomtag)
        {
            MroomInfo item = new MroomInfo();

            item.Mtype_id = Mtype_id;
            item.Name     = Name;
            item.Number   = Number;
            item.Reason   = Reason;
            item.State    = State;
            item.Username = Username;
            item          = Mroom.Insert(item);
            //关联 Mroomtag
            foreach (int mn_Mroomtag_in in mn_Mroomtag)
            {
                item.FlagMroomtag(mn_Mroomtag_in);
            }
            return(APIReturn.成功.SetData("item", item.ToBson()));
        }
Beispiel #3
0
        public APIReturn _Edit([FromQuery] int Id, [FromForm] int?Mtype_id, [FromForm] string Name, [FromForm] short?Number, [FromForm] string Reason, [FromForm] Et_mroomstateENUM?State, [FromForm] string Username, [FromForm] int[] mn_Mroomtag)
        {
            MroomInfo item = Mroom.GetItem(Id);

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

            //关联 Mroomtag
            if (mn_Mroomtag.Length == 0)
            {
                item.UnflagMroomtagALL();
            }
            else
            {
                List <int> mn_Mroomtag_list = mn_Mroomtag.ToList();
                foreach (var Obj_mroomtag in item.Obj_mroomtags)
                {
                    int idx = mn_Mroomtag_list.FindIndex(a => a == Obj_mroomtag.Id);
                    if (idx == -1)
                    {
                        item.UnflagMroomtag(Obj_mroomtag.Id);
                    }
                    else
                    {
                        mn_Mroomtag_list.RemoveAt(idx);
                    }
                }
                mn_Mroomtag_list.ForEach(a => item.FlagMroomtag(a));
            }
            if (affrows > 0)
            {
                return(APIReturn.成功.SetMessage($"更新成功,影响行数:{affrows}"));
            }
            return(APIReturn.失败);
        }