コード例 #1
0
        public APIReturn _Edit([FromQuery] uint Id, [FromForm] uint?Markettype_id, [FromForm] uint?Member_id, [FromForm] string Address, [FromForm] decimal?Area, [FromForm] string Code, [FromForm] string Fax, [FromForm] ShopFUNC_SWITCH[] Func_switch, [FromForm] ShopICON[] Icon, [FromForm] string Kefu, [FromForm] string Main_business, [FromForm] string Nickname, [FromForm] ShopSTATE?State, [FromForm] string Title, [FromForm] uint[] mn_Franchising)
        {
            ShopInfo item = Shop.GetItem(Id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            item.Markettype_id = Markettype_id;
            item.Member_id     = Member_id;
            item.Address       = Address;
            item.Area          = Area;
            item.Code          = Code;
            item.Create_time   = DateTime.Now;
            item.Fax           = Fax;
            item.Func_switch   = null;
            Func_switch?.ToList().ForEach(a => item.Func_switch = (item.Func_switch ?? 0) | a);
            item.Icon = null;
            Icon?.ToList().ForEach(a => item.Icon = (item.Icon ?? 0) | a);
            item.Kefu          = Kefu;
            item.Main_business = Main_business;
            item.Nickname      = Nickname;
            item.State         = State;
            item.Title         = Title;
            int affrows = Shop.Update(item);

            //关联 Franchising
            if (mn_Franchising.Length == 0)
            {
                item.UnflagFranchisingALL();
            }
            else
            {
                List <uint> mn_Franchising_list = mn_Franchising.ToList();
                foreach (var Obj_franchising in item.Obj_franchisings)
                {
                    int idx = mn_Franchising_list.FindIndex(a => a == Obj_franchising.Id);
                    if (idx == -1)
                    {
                        item.UnflagFranchising(Obj_franchising.Id);
                    }
                    else
                    {
                        mn_Franchising_list.RemoveAt(idx);
                    }
                }
                mn_Franchising_list.ForEach(a => item.FlagFranchising(a));
            }
            if (affrows > 0)
            {
                return(APIReturn.成功.SetMessage($"更新成功,影响行数:{affrows}"));
            }
            return(APIReturn.失败);
        }