Exemplo n.º 1
0
 public IActionResult Create(Announcement announcement)
 {
     if (ModelState.IsValid)
     {
         announcementRepository.Add(announcement);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Exemplo n.º 2
0
 public void AddAnnouncement(string title, string content)
 {
     announcementRepository.Add(new Announcement()
     {
         AnnouncementId = Guid.NewGuid(),
         Title          = title,
         Content        = content,
         AddedTime      = DateTime.Now,
     });
 }
Exemplo n.º 3
0
        public async Task <IActionResult> New(AnnouncementNewVM vm)
        {
            AppUser user = await _userManager.FindByNameAsync(User.Identity.Name);

            Announcement announcement = new Announcement
            {
                Title               = vm.Title,
                Description         = vm.Description,
                ShortDescription    = vm.ShortDescription,
                FilterType          = (AnnouncementFilterType)vm.AnnouncementFilterID,
                RecordCreated       = DateTime.Now,
                PostOwner           = user.FirstName + " " + user.LastName,
                AnnouncementOwnerID = user.Id,
            };

            _announcementRepository.Add(announcement);

            return(RedirectToAction("Index"));
        }
        public async Task <bool> AnnounSendUser(Guid userId, AnnouncementViewModel content, List <AppUserViewModel> appUsers)
        {
            var announcement = content.AddModel();
            await _announcementRepository.Add(announcement);

            foreach (var item in appUsers)
            {
                if (item.Id != userId)
                {
                    var announcementUser = null as AnnouncementUserViewModel;
                    announcementUser = new AnnouncementUserViewModel()
                    {
                        AnnouncementId = content.Id, HasRead = false, UserId = item.Id
                    };
                    var user = announcementUser.AddModel();
                    await _announcementUserRepository.AddAsyn(user);
                }
            }
            _unitOfWork.Commit();
            return(true);
        }
Exemplo n.º 5
0
 public Announcement Create(Announcement announcement)
 {
     return(_announcementRepository.Add(announcement));
 }
Exemplo n.º 6
0
 public void Add(Announcement announcement)
 {
     announcementRepository.Add(announcement);
 }
        public void Add(AnnouncementViewModel announcementVm)
        {
            var announcement = Mapper.Map <AnnouncementViewModel, Announcement>(announcementVm);

            _announcementRepository.Add(announcement);
        }