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")); }
public Topic GetTopicDB(string nameTopic) { return(_topic.GetTopicDB(nameTopic)); }