Example #1
0
        public JsonResult CustomerServicesEdit(PlatformCustomerServiceModel[] css)
        {
            var count = 3;//客服个数,可设计成从站点配置取

            css = css.Where(p => !string.IsNullOrEmpty(p.Name) && !string.IsNullOrEmpty(p.AccountCode)).Take(count).ToArray();

            foreach (var item in css)
            {
                item.ShopId = 0;
                if (!string.IsNullOrEmpty(item.Name))
                {
                    item.Name = item.Name.Trim();
                }
                if (!string.IsNullOrEmpty(item.AccountCode))
                {
                    item.AccountCode = item.AccountCode.Trim();
                }
            }

            var newIds = new Dictionary <Guid, long>();

            if (css.Any(p => p.Id == 0))
            {
                foreach (var item in css.Where(p => p.Id == 0))
                {
                    var newId = CustomerServiceApplication.AddPlateCustomerService(item.Map <CustomerService>());
                    newIds.Add(item.CreateId, newId);
                }
            }
            if (css.Any(p => p.Id > 0))
            {
                Application.CustomerServiceApplication.UpdatePlatformService(css.Where(p => p.Id > 0));
            }

            return(Json(new
            {
                Success = true,
                NewIds = newIds
            }, true));
        }