Ejemplo n.º 1
0
        public ActionResult Index(SendViewModels vm)
        {
            if (ModelState.IsValid)
            {
                var usersSelected = new List<string>();
                usersSelected.AddRange(UserLogic.GetAllUserIds(vm.ReceiversSelected));
                vm.GroupsSelected.ForEach(g => usersSelected.AddRange(UserGroupsLogic.GetMembersId(g)));
                var distinctUsers = usersSelected.Distinct();
                usersSelected = distinctUsers.ToList();

                // User must have selected a Receiver (Users or Groups or Both)
                if (usersSelected.Capacity == 0)
                {
                    return Index();
                }

                var msg = new Message
                {
                    SenderId = User.Identity.GetUserId(),
                    TimeSent = DateTime.Now,
                    Title = vm.Title,
                    Body = vm.Body
                };
                MessageLogic.Send(msg, usersSelected);
                var rc = new StringBuilder();
                vm.ReceiversSelected.ForEach(l => rc.Append(l + ", "));
                vm.GroupsSelected.ForEach(l => rc.Append(l + ", "));
                var receipt = new SuccessfulViewModels
                {
                    MessageNumber = msg.MessageId,
                    TimeSent = msg.TimeSent,
                    ReceiversSent = rc.ToString()
                };
                return RedirectToAction("Successful", "Send", receipt);
            }
            return Index();
        }
Ejemplo n.º 2
0
 public ActionResult Successful(SuccessfulViewModels svm)
 {
     return View(svm);
 }