コード例 #1
0
        public IActionResult CreatePost(CreatePublicationViewModel model)
        {
            byte[] imageData = null;
            // считываем переданный файл в массив байтов
            using (var binaryReader = new BinaryReader(model.AvatarPost.OpenReadStream()))
            {
                imageData = binaryReader.ReadBytes((int)model.AvatarPost.Length);
            }

            string      a    = _userManager.GetUserId(User);
            Publication publ = new Publication {
                PublicationName = model.PublicationName,
                Discription     = model.Discription,
                PublicationText = model.PublicationText,
                AvatarPost      = imageData,
                isFavorite      = model.isFavorite,
                TopicId         = _topic.GetTopicDB(model.TopicName).Id,
                Topic           = _topic.GetTopicDB(model.TopicName),
                User            = _user.GetUserDB(_userManager.GetUserId(User)),
            };

            _publication.AddPublicationDB(publ);
            return(RedirectToAction("CreatePost"));
        }
コード例 #2
0
ファイル: TopicService.cs プロジェクト: Natalie0593/2020
 public Topic GetTopicDB(string nameTopic)
 {
     return(_topic.GetTopicDB(nameTopic));
 }