Exemplo n.º 1
0
        public ActionResult Invite(int id, string email = "", int[] userIds = null)
        {
            var us = new UserService();
            if (email != "")
            {
                try
                {
                    us.SendInvitation(email, SessionStorage.User.Id, id);
                    return new JsonResult {Data = "Message sent!"};
                }
                catch (Exception ex)
                {
                    return new JsonResult {Data = ex.Message};
                }
            }

            if (userIds != null)
            {
                foreach (var userId in userIds)
                {
                    if (userId != SessionStorage.User.Id)
                    {
                        us.SendInvitation(userId, SessionStorage.User.Id, id);
                    }
                }
                return new JsonResult {Data = "Invitations sent!"};
            }
            return new ContentResult();
        }
Exemplo n.º 2
0
        public ActionResult BlockInvitation(int id)
        {
            string result = new UserService().ProcessInvitation(id, "block", 0);
            this.SetTempMessage(result, "success");

            return RedirectToAction("Index");
        }
Exemplo n.º 3
0
        public ActionResult Settings()
        {
            var us = new UserService().GetUser(SessionStorage.User.Id);

            var model = new Settings()
                            {
                                HoursOffsetFromUtc = us.HoursOffsetFromUtc,
                                FirstName = us.FirstName,
                                LastName = us.LastName,
                                Email = us.Email,
                                Language = us.Language
                            };
            return View(model);
        }
Exemplo n.º 4
0
 public int GetDefaultWorkspaceForUser(int userId)
 {
     var us = new UserService();
     //TODO: Add support for default and non-default
     return us.GetUser(userId).OwnedWorkspaces.FirstOrDefault().Id;
 }
Exemplo n.º 5
0
        public ActionResult ProcessInvite(int id, string verb)
        {
            string result;
            var us = new UserService();
            var invitation = us.GetInvitation(id);
            if (invitation == null) return RedirectToAction("Index", "Home");

            //invitation sent to already resgistered user
            if (invitation.Invitee != null)
            {
                //current logged user is target user
                if (invitation.Invitee.Id == SessionStorage.User.Id)
                    result = us.ProcessInvitation(invitation, verb, SessionStorage.User.Id);
                    //non-authorized
                else
                    return RedirectToAction("Index", "Home");
            }
            //we look for email in database
            else
            {
                var userId = us.GetUserIdByEmail(invitation.InviteeEmail);
                if (userId == -1)
                {
                    if (verb == "block")
                        result = us.ProcessInvitation(invitation, "block", 0);
                    else
                    {
                        TempData["InformationMessage"] = "You should register before processing";
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                    result = us.ProcessInvitation(invitation, verb, userId);
            }
            TempData["InformationMessage"] = result;
            return RedirectToAction("Shared", "Project");
        }
Exemplo n.º 6
0
        //
        // GET: /Admin/User/
        public ActionResult Index()
        {
            var us = new UserService();

            return View(us.GetUsers());
        }
Exemplo n.º 7
0
 public AccountController()
 {
     UserService = new UserService();
 }