Beispiel #1
0
        public async Task <IActionResult> Create(CommunityCreateViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }
                var name = User.Identity.Name;
                var user = await _userManager.FindByNameAsync(User.Identity.Name);

                var community = new Community();
                community.CreatedAt   = DateTime.Now;
                community.CreatedBy   = user.Id;
                community.Description = model.Description;
                community.Name        = model.Name;

                _communityService.Add(community);
                return(RedirectToAction("index"));
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
                return(RedirectToAction("index"));
            }
        }
Beispiel #2
0
        public IActionResult CreateCommunity(CommunityCreateViewModel model)     // id에 email 값이 들어온다.
        {
            homeRepository.UploadCommunity(model);
            homeRepository.Save();

            return(RedirectToAction("Community"));
        }
Beispiel #3
0
        // 커뮤니티 글 등록
        public void UploadCommunity(CommunityCreateViewModel model)
        {
            AccountUser accountUser = context.AccountUsers.Where(a => a.Email == model.AccountUser.Email).FirstOrDefault();

            var community = new Community
            {
                Title       = model.Community.Title,
                Description = model.Community.Description,
                EnrollTime  = DateTime.Now,
                Id          = accountUser.Id
            };

            context.Communitys.Add(community);
        }