Example #1
0
        public ModelResponse LoadProfile(UserInfo user, long portalUserId)
        {
            OrgVm r;

            try
            {
                //Authorization
                if (user == null)
                {
                    return(new ModelResponse(101));
                }
                if (string.IsNullOrWhiteSpace(user.UserId))
                {
                    return(new ModelResponse(101));
                }
                if (user.PortalUserId != portalUserId)
                {
                    if (!DalFactory.Singleton.DataService.IsAdmin(user.UserId))
                    {
                        return(new ModelResponse(101));
                    }
                }
                else
                {
                    var userClass = PUserRepo.GetUserClass(user);
                    if (userClass != UserClass.OrgAdmin && userClass != UserClass.OrgContact)
                    {
                        return(new ModelResponse(101));
                    }
                }

                //Load from DB
                r = Repo.LoadProfile(portalUserId);
            }
            catch (Exception ex)
            {
                return(new ModelResponse(ex));
            }

            return(new ModelResponse(0, r));
        }