Esempio n. 1
0
        public async Task <IActionResult> Edit(long id, [FromForm] ContactInfoInput model)
        {
            var       adminmodel = _mapper.Map <ContactInfo>(model);
            IFormFile formFile   = model?.WeChat;

            if (formFile != null)
            {
                var fs = formFile.OpenReadStream();
                using (BinaryReader br = new BinaryReader(fs))
                {
                    var imgBytesIn = br.ReadBytes((int)fs.Length);
                    adminmodel.WeChat = imgBytesIn;
                }
            }
            adminmodel.Id = id;
            var optresult = await _contactService.EditAsync(adminmodel);

            var result = ApiResultBase.GetInstance(optresult ? ResultCode.Access : ResultCode.Fail, result: optresult);

            return(Ok(result));
        }