Esempio n. 1
0
        public async Task <IActionResult> Add([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;
                }
            }
            var optresult = await _contactService.AddAsync(adminmodel);

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

            return(Ok(result));
        }