public IActionResult Create(int userId)
        {
            var treat = new AddTreatDto()
            {
                UserId = userId
            };

            return(View(treat));
        }
        public WebAPIOutput <int> Add([FromBody] AddTreatDto treatDto)
        {
            var treat = new Treat()
            {
                UserId       = treatDto.UserId,
                TreatDate    = treatDto.TreatDate,
                TreatDoctor  = treatDto.TreatDoctor,
                TreatPlace   = treatDto.TreatPlace,
                TreateDetail = treatDto.TreateDetail
            };
            var treatId = _treatService.Add(treat);

            return(WebAPIOutput <int> .Success(treatId));
        }
        /// <summary>
        /// 添加治疗
        /// </summary>
        /// <param name="treat"></param>
        /// <returns></returns>
        public async Task <WebAPIOutput <int> > AddTreat(AddTreatDto treatDto)
        {
            var request = new RestRequest()
            {
                Resource       = "/api/Treat",
                RequestFormat  = DataFormat.Json,
                JsonSerializer = new RestSharpJsonSerializer(),
                Method         = Method.POST
            };

            request.AddBody(treatDto);

            return(await ExecuteAsync <WebAPIOutput <int> >(request));
        }
        public async Task <IActionResult> Create(AddTreatDto model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var response = await _lovePlatformApi.AddTreat(model);

            if (!response.IsSuccess)
            {
                ModelState.AddModelError("", response.Message);
                return(View(model));
            }
            var treatId = response.ResultValue;

            //上传文件
            //var files = Request.Form.Files;
            //foreach (var file in files)
            //{
            //    //转换成二进制
            //    Byte[] fileData = new Byte[(int)file.Length];
            //    using (var memoryStream = new MemoryStream())
            //    {
            //        await file.CopyToAsync(memoryStream);
            //        fileData = memoryStream.ToArray();
            //    }

            //    //保存图片到服务器
            //    var r = await _lovePlatformApi.UploadImage(
            //        new UploadImageInput { AvatarBuffer = fileData, Folder = "cure-record" });

            //    var fileName = r.ResultValue;

            //    await _lovePlatformApi.AddTreatImage(new TreatImage() { ImagePath = fileName, TreatId = treatId, UserId = model.UserId });

            //}
            var user = await _lovePlatformApi.GetUser(model.UserId);

            return(RedirectToAction("Index", "User", new { openId = user.WexinOpenId }));
        }