예제 #1
0
        public APIReturn _Edit([FromQuery] uint Id, [FromForm] uint?Area_id, [FromForm] string Capacity, [FromForm] string Main_business, [FromForm] string Min_order, [FromForm] string Process_cost, [FromForm] string Sampling_period, [FromForm] string Sampling_price, [FromForm] string Telphone, [FromForm] string Title, [FromForm] string Turn_single_time, [FromForm] uint[] mn_Franchising)
        {
            FactoryInfo item = Factory.GetItem(Id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            item.Area_id          = Area_id;
            item.Capacity         = Capacity;
            item.Create_time      = DateTime.Now;
            item.Main_business    = Main_business;
            item.Min_order        = Min_order;
            item.Process_cost     = Process_cost;
            item.Sampling_period  = Sampling_period;
            item.Sampling_price   = Sampling_price;
            item.Telphone         = Telphone;
            item.Title            = Title;
            item.Turn_single_time = Turn_single_time;
            int affrows = Factory.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.失败);
        }
예제 #2
0
        public APIReturn _Add([FromForm] uint?Area_id, [FromForm] string Capacity, [FromForm] string Main_business, [FromForm] string Min_order, [FromForm] string Process_cost, [FromForm] string Sampling_period, [FromForm] string Sampling_price, [FromForm] string Telphone, [FromForm] string Title, [FromForm] string Turn_single_time, [FromForm] uint[] mn_Franchising)
        {
            FactoryInfo item = new FactoryInfo();

            item.Area_id          = Area_id;
            item.Capacity         = Capacity;
            item.Create_time      = DateTime.Now;
            item.Main_business    = Main_business;
            item.Min_order        = Min_order;
            item.Process_cost     = Process_cost;
            item.Sampling_period  = Sampling_period;
            item.Sampling_price   = Sampling_price;
            item.Telphone         = Telphone;
            item.Title            = Title;
            item.Turn_single_time = Turn_single_time;
            item = Factory.Insert(item);
            //关联 Franchising
            foreach (uint mn_Franchising_in in mn_Franchising)
            {
                item.FlagFranchising(mn_Franchising_in);
            }
            return(APIReturn.成功.SetData("item", item.ToBson()));
        }