Esempio n. 1
0
        public IActionResult ConfirmSend(Guid Id)
        {
            try
            {
                var CurrentUser   = _context.Users.Find(userManager.GetUserId(User));
                var existingGroup = _GroupStore.GetGroupById(Id);
                var Requestor     = new GroupRequestUser()
                {
                    Username = CurrentUser.UserName,
                    UserId   = CurrentUser.Id,
                };
                _GroupRequestStore.NewRequestUser(Requestor);

                var Request = new GroupRequest()
                {
                    GroupId       = Id,
                    RequestDate   = DateTime.Now,
                    RequestUserId = Requestor.Id
                };
                _GroupRequestStore.SendRequest(Request);

                return(RedirectToAction("GroupDetails", "Groups", new { id = Request.GroupId }));
            }
            catch (DomainException ex)
            {
                _logger.LogError(ex.Message);
                if (ex.Message.Equals(ErrorMessages.GroupDoesNotExist))
                {
                    return(RedirectToAction(ActionName.NotFound, ControllerName.Accounts));
                }
                if (ex.Message.Equals(ErrorMessages.GroupUserExists))
                {
                    return(RedirectToAction("AlreadyExists"));
                }
                return(RedirectToAction(ActionName.ServerError, ControllerName.Accounts));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(RedirectToAction(ActionName.ServerError, ControllerName.Accounts));
            }
        }
Esempio n. 2
0
 public GroupRequestUser NewRequestUser(GroupRequestUser requestUser)
 {
     _Context.GroupRequestUser.Add(requestUser);
     _Context.SaveChanges();
     return(requestUser);
 }