Exemplo n.º 1
0
        protected T DecorateViewModel <T>(T model) where T : BaseViewModel // T is extended with the baseviewmodel
        {
            if (UserService.IsLoggedIn())
            {
                UserPageDomain upd        = UserPageService.GetModel();
                string         thisUserId = UserService.GetCurrentUserId();
                model._IsLoggedIn = true;
                model._AccountId  = thisUserId;// attach the user id to the model (string value)
                Console.WriteLine("Right");

                model._UserName = upd.UserName;

                model._IsEmailConfirmed = upd.IsEmailConfirmed;

                model._UserEmail = upd.UserEmail;

                model._FirstName = upd.FirstName;

                model._LastName = upd.LastName;

                model._CompanyId = upd.CompanyId;

                model._UserPhone = upd.UserPhone;

                model._UserPhotoUrl = upd.UserPhotoUrl;

                model._CompanyOwnerId = upd.CompanyOwnerId;

                model._DateCreated = upd.DateCreated;

                model._CompanyName = upd.CompanyName;

                model._CompanyType = upd.CompanyType;

                model._CompanyEmail = upd.CompanyEmail;

                model._CompanyAddressString = upd.CompanyAddressString;

                model._CompanyPhotoUrl = upd.CompanyPhotoUrl;

                if (thisUserId != null)
                {
                    model._Auth = true;
                }

                if (_UserProfileService.IsCompanyAdmin(thisUserId))
                {
                    model._Admin = true;
                }

                if (_UserProfileService.IsCompanyOwner(thisUserId))
                {
                    model._Owner = true;
                    model._Admin = true;
                }
            }
            else
            {
                model._IsLoggedIn = false;
                Console.WriteLine("Wrong");
            }


            return(model); // return the value
        }