Пример #1
0
        public JsonResult Set(Campus model, List <HttpPostedFileBase> imgs)
        {
            if (model == null)
            {
                return(Error("参数错误。"));
            }

            if (string.IsNullOrEmpty(model.Name))
            {
                return(Error("校区名称不能为空。"));
            }

            model.Name = model.Name.Trim();
            var result = new ResultBase();

            if (model.Id > 0)
            {
                result.success = _campusService.UpdateAsync(model);
            }
            else
            {
                result.success = _campusService.InsertAsync(model);
            }

            return(Json(result));
        }
Пример #2
0
        public JsonResult Set(Campus model, List <HttpPostedFileBase> imgs)
        {
            if (model == null)
            {
                return(Error("参数错误。"));
            }

            if (string.IsNullOrEmpty(model.Name))
            {
                return(Error("校区名称不能为空。"));
            }

            model.Name = model.Name.Trim();

            var avatarFile = Request.Files["fileAvatar"];

            if (avatarFile != null)
            {
                string uploadResult = UploadHelper.Process(avatarFile.FileName, avatarFile.InputStream);
                if (!string.IsNullOrEmpty(uploadResult))
                {
                    model.Avatar = uploadResult;
                }
            }

            var bannerFile = Request.Files["fileBanner"];

            if (bannerFile != null)
            {
                string uploadResult = UploadHelper.Process(bannerFile.FileName, bannerFile.InputStream);
                if (!string.IsNullOrEmpty(uploadResult))
                {
                    model.BannerImg = uploadResult;
                }
            }
            var result = new ResultBase();

            if (model.Id > 0)
            {
                result.success = _campusService.UpdateAsync(model);
            }
            else
            {
                result.success = _campusService.InsertAsync(model);
            }

            return(Json(result));
        }