Ejemplo n.º 1
0
        public JsonResult SaveHomeFloorBasicInfo(long id, string name, string categoryIds)
        {
            string msg     = string.Empty;
            bool   success = false;

            if (string.IsNullOrWhiteSpace(name))
            {
                msg = "楼层名称不能为空";
            }
            else if (name.Trim().Length > 4)
            {
                msg = "楼层名称长度不能超过4个字";
            }
            else
            {
                name = name.Trim();
                try
                {
                    IEnumerable <long> categoryIds_long = categoryIds.Split(',').Where(item => !string.IsNullOrWhiteSpace(item)).Select(item => long.Parse(item));
                    if (id > 0)
                    {
                        _iFloorService.UpdateFloorBasicInfo(id, name, categoryIds_long);
                    }
                    else
                    {
                        var basicInfo = _iFloorService.AddHomeFloorBasicInfo(name, categoryIds_long);
                        id = basicInfo.Id;
                    }
                    success = true;
                }
                catch (FormatException)
                {
                    msg = "商品分类编号有误";
                }
            }
            return(Json(new
            {
                success = success,
                msg = msg,
                id = id
            }));
        }