public ActionResult Access(AccessViewModel vm)
        {
            foreach (var friend in vm.AccessList.Where(a => a.Selected))
            {
                EntryAccess entryAccess = new EntryAccess
                {
                    AccountId = friend.SimpleId,
                    Active = 1,
                    Created = DateTime.Now,
                    EntryId = vm.EntryId,
                };

                Rep.AddEntryAccess(entryAccess);
            }

            foreach (var group in vm.Groups.Where(a => a.Selected))
            {
                Group grp = Rep.GetGroupById(group.Group.Id);
                foreach (var member in grp.GroupMembers)
                {
                    EntryAccess entryAccess = new EntryAccess
                    {
                        AccountId = member.AccountId.ToString(),
                        Active = 1,
                        Created = DateTime.Now,
                        EntryId = vm.EntryId,
                    };

                    Rep.AddEntryAccess(entryAccess);
                }
            }

            Rep.Save();

            return RedirectToAction("View", "Post", new { id = vm.EntryId });
        }
 public void AddEntryAccess(EntryAccess entryAccess)
 {
     context.EntryAccesses.Add(entryAccess);
 }
Exemplo n.º 3
0
        public ActionResult Access(AccessViewModel vm)
        {
            foreach (var friend in vm.AccessList.Where(a => a.Selected))
            {
                EntryAccess entryAccess = new EntryAccess
                {
                    AccountId = friend.SimpleId,
                    Active = 1,
                    Created = DateTime.Now,
                    EntryId = vm.EntryId,
                };

                Rep.AddEntryAccess(entryAccess);
            }

            Rep.Save();

            return RedirectToAction("View", "Post", new { id = vm.EntryId });
        }