Beispiel #1
0
        public async Task <IActionResult> Update([FromBody] MajorDto dto)
        {
            var result = await _majorService.UpdateAsync(dto);

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
Beispiel #2
0
        public JsonResult Set(Major model)
        {
            if (model == null)
            {
                return(Error("参数错误。"));
            }

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

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

            var fileMajor = Request.Files["fileMajor"];

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

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

            return(Json(result));
        }