Exemple #1
0
        private WallModelInfoResponse GetInfo(WallModel model)
        {
            var users = new List <WallModelInfoAuthorizedUsersResponse>();

            foreach (var usr in model.AuthorizedUsers)
            {
                users.Add(new WallModelInfoAuthorizedUsersResponse()
                {
                    KeyPublic   = usr.User.TokenKeyPublic,
                    Permissions = usr.PermissionLevel,
                    Username    = usr.User.UserName
                });
            }

            return(new WallModelInfoResponse()
            {
                OwnerName = model.OwnerName,
                OwnerPublic = model.OwnerPublic,
                HasPassword = model.Password != null && model.Password != "",
                Title = model.Title,
                Subtitle = model.Subtitle,
                Url = model.WallUrl,
                AuthorizedUsers = users,
                BackgroundUrl = model.BackgroundUrl,
                TileBackground = model.TileBackground,
                IsPrivate = !IsViewPermission(model.UnauthorizedUserPermissionLevel),
                UnauthorizedUsersPermission = model.UnauthorizedUserPermissionLevel,
                WallMode = model.WallMode,
            });
        }
Exemple #2
0
        private bool CanModerate(WallModel model, GenericWallRequest request)
        {
            //No view permission
            if (!IsAuthorizedToView(model, GetPassword(request)))
            {
                return(false);
            }
            //Everyone has admin
            if (model.UnauthorizedUserPermissionLevel ==
                WallModel.WallAccessPermissionLevels.ViewEditModerate)
            {
                return(true);
            }
            //Owner
            if (IsOwner(model, request))
            {
                return(true);
            }
            //Not authorized to do anything / aren't on authorized list
            if (!User.Identity.IsAuthenticated)
            {
                return(false);
            }
            //Get them if possible
            var mx = model.AuthorizedUsers.FirstOrDefault(
                (m) => m.User.UserName == User.Identity.Name &&
                m.PermissionLevel == WallModel.WallAccessPermissionLevels.ViewEditModerate);

            //and verify
            return(mx != null);
        }
Exemple #3
0
        private bool RenderReflectionScene()
        {
            // Use the camera to render the reflection and create a reflection view matrix.
            Camera.RenderReflection(WaterHeight);

            // Get the camera reflection view matrix instead of the normal view matrix.
            var viewMatrix = Camera.ReflectionViewMatrix;
            // Get the world and projection matrices from the d3d object.
            var worldMatrix      = D3D.WorldMatrix;
            var projectionMatrix = D3D.ProjectionMatrix;

            // Translate to where the bath model will be rendered.
            Matrix.Translation(0f, 6f, 8f, out worldMatrix);

            // Put the wall model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            WallModel.Render(D3D.DeviceContext);

            // Render the wall model using the light shader and the reflection view matrix.
            if (!LightShader.Render(D3D.DeviceContext, WallModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, WallModel.TextureCollection.Select(item => item.TextureResource).First(), Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }

            return(true);
        }
Exemple #4
0
        public IHttpActionResult AddPost(string wallId, WallModelAddPostRequest request)
        {
            wallId = Helpers.TextSanitizer.Hypersanitize(wallId, true);
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }


            WallModel wallModel = DatabaseContext.Shared.WallModels.Find(wallId);

            if (wallModel == null)
            {
                return(NotFound());
            }
            if (!CanCreatePost(wallModel, request))
            {
                return(Unauthorized());
            }

            var username = GetUsername();

            var post = DatabaseContext.Shared.WallPosts.Create();

            post.Attachment     = Helpers.TextSanitizer.MakeSafe(request.AttachmentUrl, false);
            post.Content        = Helpers.TextSanitizer.MakeSafe(request.Content, true);
            post.CreationTime   = DateTime.UtcNow;
            post.UpdateTime     = DateTime.UtcNow;
            post.CreatorName    = username;
            post.CreatorPrivate = GetPrivateKey(request);
            post.CreatorPublic  = GetPublicKey(request);
            post.Header         = Helpers.TextSanitizer.MakeSafe(request.Header, false) ?? "";
            post.Wall           = wallModel;
            post.WallId         = wallModel.WallUrl;

            wallModel.AddPost(post);

            try
            {
                DatabaseContext.Shared.SaveChanges();
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }

            //Add to the user if any
            var user = GetUser();

            if (user != null)
            {
                user.Add(post);
                _authRepo.SaveUserUpdate();
            }

            DatabaseContext.Release();
            return(Ok(GetPostInfo(post)));
        }
Exemple #5
0
        private void SignUpButton_Click(object sender, RoutedEventArgs e)
        {
            UserModel userModelSignUp = new UserModel()
            {
                Gmail = LoginTextBox.Text, Password = PasswordTextBox.Text, Name = NameTextBox.Text
            };
            HttpWebRequest myRequestSignUp = WebRequest.CreateHttp("https://localhost:44359/api/user/signup");

            myRequestSignUp.Method      = "POST";
            myRequestSignUp.ContentType = "application/json";
            using (StreamWriter writer = new StreamWriter(myRequestSignUp.GetRequestStream()))
            {
                writer.Write(JsonConvert.SerializeObject(userModelSignUp));
            }
            WebResponse wrSignUp = myRequestSignUp.GetResponse();

            UserModel userModel = new UserModel()
            {
                Gmail = LoginTextBox.Text, Password = PasswordTextBox.Text
            };
            HttpWebRequest myRequest = WebRequest.CreateHttp("https://localhost:44359/api/user/login");

            myRequest.Method      = "POST";
            myRequest.ContentType = "application/json";
            using (StreamWriter writer = new StreamWriter(myRequest.GetRequestStream()))
            {
                writer.Write(JsonConvert.SerializeObject(userModel));
            }
            WebResponse wr = myRequest.GetResponse();
            int         id;

            using (StreamReader reader = new StreamReader(wr.GetResponseStream()))
            {
                id = int.Parse(reader.ReadToEnd());
            }

            WallModel wallModel = new WallModel()
            {
                Age     = int.Parse(AgeTextBox.Text),
                City    = CityTextBox.Text,
                Country = CountryTextBox.Text,
                IdUser  = id
            };
            HttpWebRequest myRequestNewWall = WebRequest.CreateHttp("https://localhost:44359/api/wall/newwall");

            myRequestNewWall.Method      = "POST";
            myRequestNewWall.ContentType = "application/json";
            using (StreamWriter writer = new StreamWriter(myRequestNewWall.GetRequestStream()))
            {
                writer.Write(JsonConvert.SerializeObject(wallModel));
            }
            WebResponse wrNewWall = myRequestNewWall.GetResponse();

            Wall WindowProg = new Wall(id);

            WindowProg.Show();
            this.Close();
        }
Exemple #6
0
        public void generateMeAWall(int width, int height, bool type, int top, int left)
        {
            WallModel wallmodel;

            wallmodel = new WallModel(width, height, type);
            Canvas.SetZIndex(wallmodel.Image, 2);
            Canvas.SetLeft(wallmodel.Image, left);
            Canvas.SetTop(wallmodel.Image, top);
            _canvasTopBottom.Children.Add(wallmodel.Image);
        }
Exemple #7
0
 private bool UserHasCreatePermissions(WallModel model)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(false);
     }
     return(model.AuthorizedUsers.FirstOrDefault((m) => m.User.UserName == User.Identity.Name &&
                                                 m.PermissionLevel == WallModel.WallAccessPermissionLevels.ViewEdit ||
                                                 m.PermissionLevel == WallModel.WallAccessPermissionLevels.ViewEditModerate) != null);
 }
        public void UpdateModel(WallModel wallModel)
        {
            var parameters = new Dictionary <string, object>();

            parameters.Add("UserID", wallModel.UserID);
            parameters.Add("Details", wallModel.Details);
            parameters.Add("MarkerID", 0);

            Execute(WallQueries.UpdateModel, parameters);
        }
Exemple #9
0
        protected WallPostCreateRequest GetSampleWallCreateRequest(string postedBy, WallModel targetWall)
        {
            var body = TestUtils.GenerateLoremIpsumText();

            return(new WallPostCreateRequest
            {
                Body = body,
                PostedBy = postedBy,
                PostType = WallPostType.text,
                TargetWall = targetWall,
            });
        }
Exemple #10
0
 public IActionResult NewWall([FromBody] WallModel model)
 {
     _context.Walls.Add(new Wall
     {
         Age     = model.Age,
         Country = model.Country,
         City    = model.City,
         IdUser  = model.IdUser
     });
     _context.SaveChanges();
     return(Ok());
 }
        public ActionResult Wall(WallModel model)
        {
            ViewBag.MessageName        = model.Name;
            ViewBag.MessageEmailAdress = model.EmailAdress;
            ViewBag.MessagePost        = model.Post;
            ViewBag.CurrentTime        = DateTime.UtcNow;



            //e sada, kako da storujem model u database??????

            return(View());
        }
Exemple #12
0
        public static GameObject CreateWall(WallModel model)
        {
            float      width = Vector3.Distance(model.Start, model.End);
            float      a     = Vector3.Angle(model.Start - model.End, Vector3.right);
            GameObject go    = new GameObject("PositionedWall");
            GameObject wall  = CreateWall(width, model.Height, model.Material);

            wall.transform.parent   = go.transform;
            wall.transform.position = Vector3.zero;
            wall.transform.Rotate(Vector3.up, -a);
            go.transform.position = model.Start;
            go.AddComponent <ModelContainer>().Model = model;
            return(go);
        }
Exemple #13
0
        public IHttpActionResult GetPosts(string wallId, Models.WallChunkRequest chunks)
        {
            wallId = Helpers.TextSanitizer.Hypersanitize(wallId, true);
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            WallModel wallModel = DatabaseContext.Shared.WallModels.Find(wallId);

            if (wallModel == null)
            {
                return(NotFound());
            }

            var headers = HttpContext.Current.Request.Headers;

            if (!IsAuthorizedToView(wallModel, chunks.Password))
            {
                return(Unauthorized());
            }

            if (chunks.Count <= 0 || chunks.Count > wallModel.Posts.Count)
            {
                chunks.Count = wallModel.Posts.Count;
            }

            //We do some spinning around so that the newest is #0 and oldest is X, rather than the reverse
            //That way, a call to (0) yields the newest results and not the oldest
            var relativeStart = wallModel.Posts.Count - chunks.Beginning - chunks.Count;

            //If we are requesting past the end, return empty rather than the entire list
            if (relativeStart < 0)
            {
                return(Ok(Enumerable.Empty <WallModelPostInfoResponse>()));
            }

            var posts = new List <WallModelPostInfoResponse>();

            foreach (var post in wallModel.Posts.Skip(relativeStart).Take(chunks.Count))
            {
                posts.Add(GetPostInfo(post));
            }

            //reverse posts so newest are first
            posts.Reverse();

            DatabaseContext.Release();
            return(Ok(posts));
        }
Exemple #14
0
        public IHttpActionResult DeletePost(string wallId, WallModelDeletePostRequest request)
        {
            wallId = Helpers.TextSanitizer.Hypersanitize(wallId, true);
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }


            WallModel wallModel = DatabaseContext.Shared.WallModels.Find(wallId);

            if (wallModel == null)
            {
                return(NotFound());
            }
            var post = wallModel.Posts.Where((w) => w.PostId == request.PostId).FirstOrDefault();

            if (post == null)
            {
                return(NotFound());
            }

            if (!CanEdit(wallModel, post, request))
            {
                return(Unauthorized());
            }

            wallModel.RemovePost(post);
            DatabaseContext.Shared.WallPosts.Remove(post);
            //Remove post
            var user = GetUser();

            if (user != null)
            {
                user.Remove(post);
                _authRepo.SaveUserUpdate();
            }

            try
            {
                DatabaseContext.Shared.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(InternalServerError());
            }

            DatabaseContext.Release();
            return(Ok());
        }
        public WallFriend(int idF, int idU)
        {
            InitializeComponent();

            id   = idF;
            _idU = idU;
            HttpWebRequest myRequestUser = WebRequest.CreateHttp($"https://localhost:44359/api/user/get/{id}");

            myRequestUser.Method      = "GET";
            myRequestUser.ContentType = "application/json";
            try
            {
                WebResponse wr        = myRequestUser.GetResponse();
                UserModel   userModel = new UserModel();
                using (StreamReader reader = new StreamReader(wr.GetResponseStream()))
                {
                    string responseFromServer = reader.ReadToEnd();
                    userModel = JsonConvert.DeserializeObject <UserModel>(responseFromServer);
                }
                FirstAndSecondNameTextBox.Content = userModel.Name;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            HttpWebRequest myRequestWall = WebRequest.CreateHttp($"https://localhost:44359/api/wall/get/{id}");

            myRequestWall.Method      = "GET";
            myRequestWall.ContentType = "application/json";
            try
            {
                WebResponse wr        = myRequestWall.GetResponse();
                WallModel   wallModel = new WallModel();
                using (StreamReader reader = new StreamReader(wr.GetResponseStream()))
                {
                    string responseFromServer = reader.ReadToEnd();
                    wallModel = JsonConvert.DeserializeObject <WallModel>(responseFromServer);
                }
                StatusTextBox.Text   = wallModel.Status;
                AgeLabel.Content     = wallModel.Age;
                CityLabel.Content    = wallModel.City;
                CountryLabel.Content = wallModel.Country;
            }
            catch (Exception ex)
            {
                MessageBox.Show("У вас Бан");
            }
        }
Exemple #16
0
 private bool CanEdit(WallModel model, WallPost post, dynamic request)
 {
     //No view permission
     if (!IsAuthorizedToView(model, GetPassword(request)))
     {
         return(false);
     }
     //Guaranteed to have edit permission if can moderate
     if (CanModerate(model, request))
     {
         return(true);
     }
     //Check that create permission is enabled and that user is owner
     return(CanCreatePost(model, request) && post.CreatorPrivate == GetPrivateKey(request));
 }
Exemple #17
0
        private WallPostWithDetailsModel MapWallPost(GetWallPost_Result postResult,
                                                     IEnumerable <GetLatestComments_Result> commentResult)
        {
            var mapped = new WallPostWithDetailsModel
            {
                Body         = postResult.Body,
                CommentCount = postResult.CommentCount.Value,
                CreatedDate  = postResult.CreatedDate,
                Id           = postResult.Id,
                LikeCount    = postResult.LikeCount.Value,
                ModifiedDate = postResult.ModifiedDate,
                PostedBy     = postResult.CreatedBy,
                PostType     = postResult.PostType
            };
            var wallModel = new WallModel();

            if (!string.IsNullOrWhiteSpace(postResult.GroupId))
            {
                wallModel.OwnerId       = postResult.GroupId;
                wallModel.WallOwnerType = WallType.group;
            }
            else
            {
                wallModel.OwnerId       = postResult.UserId;
                wallModel.WallOwnerType = WallType.user;
            }
            mapped.WallOwner = wallModel;

            var commentList = new List <CommentModel>();

            if (commentResult != null && commentResult.Any())
            {
                foreach (var comment in commentResult)
                {
                    commentList.Add(new CommentModel
                    {
                        Body         = comment.Body,
                        CreatedBy    = comment.CreatedBy,
                        CreatedDate  = comment.CreatedDate,
                        Id           = comment.Id,
                        LikeCount    = comment.LikeCount.Value,
                        ModifiedDate = comment.ModifiedDate
                    });
                }
            }
            mapped.LatestComments = commentList;
            return(mapped);
        }
Exemple #18
0
        public IHttpActionResult EditPost(string wallId, WallModelEditPostRequest request)
        {
            wallId = Helpers.TextSanitizer.Hypersanitize(wallId, true);
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }


            WallModel wallModel = DatabaseContext.Shared.WallModels.Find(wallId);

            if (wallModel == null)
            {
                return(NotFound());
            }
            var post = wallModel.Posts.Where((w) => w.PostId == request.PostId).FirstOrDefault();

            if (post == null)
            {
                return(NotFound());
            }

            if (!CanEdit(wallModel, post, request))
            {
                return(Unauthorized());
            }

            post.Header  = (request.NewHeader == null ? post.Header : Helpers.TextSanitizer.MakeSafe(request.NewHeader, false));
            post.Content = (request.NewContent == null || request.NewContent == "" ?
                            post.Content : Helpers.TextSanitizer.MakeSafe(request.NewContent, true));
            post.Attachment = (request.NewAttachment == null ? post.Attachment :
                               Helpers.TextSanitizer.MakeSafe(request.NewAttachment, false));
            post.XPosition  = (request.NewX == 0 ? post.XPosition : request.NewX);
            post.YPosition  = (request.NewY == 0 ? post.YPosition : request.NewY);
            post.UpdateTime = DateTime.UtcNow;

            try
            {
                DatabaseContext.Shared.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(InternalServerError());
            }

            DatabaseContext.Release();
            return(Ok(GetPostInfo(post)));
        }
Exemple #19
0
        private bool WallSuccess()
        {
            try
            {
                wallModel = Wall.GetWalls(autorizationModel.user_id, autorizationModel.access_token, true);
                GlobalConfig.AccessToken = autorizationModel.access_token;
                GlobalConfig.logger.Info("WallSerialize: " + Serialized <WallModel> .GetSerializeString(wallModel));
                return(true);
            }
            #region Отраработка Ошибок
            //TODO: Нехватает МоделиОшибок при другом JSON ответе сервера
            catch (HttpException ex)
            {
                GlobalConfig.logger.Info("Произошла ошибка при работе с HTTP-сервером: {0}", ex.Message);
                switch (ex.Status)
                {
                case HttpExceptionStatus.Other:
                    GlobalConfig.logger.Info("Неизвестная ошибка");
                    break;

                case HttpExceptionStatus.ProtocolError:
                    GlobalConfig.logger.Info("Код состояния: {0}", (int)ex.HttpStatusCode);
                    break;

                case HttpExceptionStatus.ConnectFailure:
                    GlobalConfig.logger.Info("Не удалось соединиться с HTTP-сервером.");
                    break;

                case HttpExceptionStatus.SendFailure:
                    GlobalConfig.logger.Info("Не удалось отправить запрос HTTP-серверу.");
                    break;

                case HttpExceptionStatus.ReceiveFailure:
                    GlobalConfig.logger.Info("Не удалось загрузить ответ от HTTP-сервера.");
                    break;
                }
            }
            catch (Exception ex)
            {
                GlobalConfig.logger.Error($"Непредвиденная ошибка \n {ex.Message} \r\n {ex.StackTrace} \r\n {ex}");
                //MessageBox.Show(ex.Message);
            }
            return(false);

            #endregion
        }
Exemple #20
0
        public IHttpActionResult CheckPassword(string wallId, GenericWallRequest request)
        {
            wallId = Helpers.TextSanitizer.Hypersanitize(wallId, true);
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            WallModel wallModel = DatabaseContext.Shared.WallModels.Find(wallId);

            if (wallModel == null)
            {
                return(NotFound());
            }

            DatabaseContext.Release();
            return(Ok(new { authenticated = request.Password == wallModel.Password }));
        }
Exemple #21
0
        private bool CanCreatePost(WallModel model, GenericWallRequest request)
        {
            //No view permission
            if (!IsAuthorizedToView(model, GetPassword(request)))
            {
                return(false);
            }
            if (CanModerate(model, request))
            {
                return(true);
            }
            if (IsEditPermission(model.UnauthorizedUserPermissionLevel)) //If anyone can edit
            {
                return(true);
            }

            return(UserHasCreatePermissions(model));
        }
Exemple #22
0
 public IActionResult Get(int id)
 {
     foreach (var wall in _context.Walls.ToList())
     {
         if (wall.IdUser == id)
         {
             WallModel model = new WallModel()
             {
                 Age         = wall.Age,
                 City        = wall.City,
                 Country     = wall.Country,
                 Status      = wall.Status,
                 ImageAvatar = wall.ImageAvatar,
             };
             string json = JsonConvert.SerializeObject(model);
             return(Content(json, "application/json"));
         }
     }
     return(BadRequest());
 }
Exemple #23
0
        /// <summary>
        /// Checks that view permissions are given.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="pass"></param>
        /// <returns></returns>
        private bool IsAuthorizedToView(WallModel model, string pass)
        {
            if (model.Password == null || model.Password == "" &&
                IsViewPermission(model.UnauthorizedUserPermissionLevel))
            {
                return(true);
            }

            if (model.Password == pass && IsViewPermission(model.UnauthorizedUserPermissionLevel))
            {
                return(true);
            }

            var user = User.Identity.IsAuthenticated ? _authRepo.FindUserByNameSync(User.Identity.Name) : null;

            return((user != null ? user.TokenKeyPrivate == model.OwnerPrivate : false) ||
                   (user != null ? model.AuthorizedUsers.FirstOrDefault((m) =>
                                                                        (m.PermissionLevel == WallModel.WallAccessPermissionLevels.View ||
                                                                         m.PermissionLevel == WallModel.WallAccessPermissionLevels.ViewEdit ||
                                                                         m.PermissionLevel == WallModel.WallAccessPermissionLevels.ViewEditModerate) &&
                                                                        m.User.UserName == User.Identity.Name) != null : false));
        }
        public async Task <IActionResult> Index()
        {
            int companyID = 1;

            var model = new WallModel();

            model.PointTransfers = await _unitOfWork.PointRepository.GetTransfers(companyID);

            var reasons = await _unitOfWork.PointRepository.GetReasons(companyID);

            var users = await _unitOfWork.UserRepository.Get(companyID);

            model.Reasons = reasons.ToDictionary(p => p.Id, pp => pp.Name);
            model.Users   = users.ToDictionary(p => p.Id, pp => pp.FirstName + " " + pp.LastName);

            model.NewTransfer = new PointTransferModel {
                CompanyId = companyID, FromUserId = 2
            };

            model.ActiveUser = users.FirstOrDefault(s => s.Id == 2);
            return(View(model));
        }
Exemple #25
0
        public void Shutdown()
        {
            // Release the light object.
            Light = null;
            // Release the camera object.
            Camera = null;

            // Release the water shader object.
            WaterShader?.ShutDown();
            WaterShader = null;
            // Release the refraction shader object.
            RefractionShader?.ShutDown();
            RefractionShader = null;
            /// Release the render to texture object.
            RenderReflectionTexture?.Shutdown();
            RenderReflectionTexture = null;
            // Release the render to texture object.
            RenderRefractionTexture?.Shutdown();
            RenderRefractionTexture = null;
            // Release the light shader object.
            LightShader?.ShutDown();
            LightShader = null;
            // Release the model object.
            GroundModel?.Shutdown();
            GroundModel = null;
            // Release the model object.
            WallModel?.Shutdown();
            WallModel = null;
            // Release the model object.
            BathModel?.Shutdown();
            BathModel = null;
            // Release the model object.
            WaterModel?.Shutdown();
            WaterModel = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }
Exemple #26
0
 public void UpdateModel(WallModel wallModel)
 {
     wallsContext.UpdateModel(wallModel);
 }
Exemple #27
0
        private IEnumerable <WallPostWithDetailsModel> MapWall(IEnumerable <GetWall_Result> procedureResult, WallModel wallOwner)
        {
            var result = new List <WallPostWithDetailsModel>();

            if (procedureResult != null)
            {
                foreach (var record in procedureResult)
                {
                    var comment        = MapComment(record);
                    var existingRecord = result.FirstOrDefault(p => p.Id == record.Id);
                    if (existingRecord == null)
                    {
                        var relatedPost = new WallPostWithDetailsModel
                        {
                            Body           = record.Body,
                            CommentCount   = record.CommentCount.Value,
                            CreatedDate    = record.CreatedDate,
                            Id             = record.Id,
                            LikeCount      = record.LikeCount.Value,
                            ModifiedDate   = record.ModifiedDate,
                            PostedBy       = record.CreatedBy,
                            PostType       = record.PostType,
                            WallOwner      = wallOwner,
                            LatestComments = new List <CommentModel>()
                        };
                        existingRecord = relatedPost;
                        result.Add(relatedPost);
                    }
                    if (comment != null)
                    {
                        (existingRecord.LatestComments as List <CommentModel>).Add(comment);
                    }
                }
            }
            return(result);
        }
Exemple #28
0
        private bool RenderScene()
        {
            // Generate the view matrix based on the camera position.
            Camera.Render();

            // Get the world, view, and projection matrices from camera and d3d objects.
            var viewMatrix       = Camera.ViewMatrix;
            var worldMatrix      = D3D.WorldMatrix;
            var projectionMatrix = D3D.ProjectionMatrix;

            #region Render Ground Model
            // Translate to where the ground model will be rendered.
            Matrix.Translation(0f, 1f, 0f, out worldMatrix);

            // Put the ground model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            GroundModel.Render(D3D.DeviceContext);

            // Render the ground model using the light shader.
            if (!LightShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, GroundModel.TextureCollection.Select(item => item.TextureResource).First(), Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }
            #endregion

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            #region Render Wall Model
            // Translate to where the ground model will be rendered.
            Matrix.Translation(0f, 6f, 8f, out worldMatrix);

            // Put the wall model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            WallModel.Render(D3D.DeviceContext);

            // Render the wall model using the light shader.
            if (!LightShader.Render(D3D.DeviceContext, WallModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, WallModel.TextureCollection.Select(item => item.TextureResource).First(), Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }
            #endregion

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            #region Render Bath Model
            // Translate to where the bath model will be rendered.
            Matrix.Translation(0f, 2f, 0f, out worldMatrix);

            // Put the bath model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            BathModel.Render(D3D.DeviceContext);

            // Render the bath model using the light shader.
            if (!LightShader.Render(D3D.DeviceContext, BathModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, BathModel.TextureCollection.Select(item => item.TextureResource).First(), Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }
            #endregion

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            #region Render Water Model
            // Get the camera reflection view matrix.
            var reflectionMatrix = Camera.ReflectionViewMatrix;

            // Translate to where the water model will be rendered.
            Matrix.Translation(0f, WaterHeight, 0f, out worldMatrix);

            // Put the water model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            WaterModel.Render(D3D.DeviceContext);

            // Render the bath model using the light shader.
            if (!WaterShader.Render(D3D.DeviceContext, WaterModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, RenderReflectionTexture.ShaderResourceView, RenderRefractionTexture.ShaderResourceView, WaterModel.TextureCollection.Select(item => item.TextureResource).First(), WaterTranslation, 0.1f)) // was 0.01f for scale originally.
            {
                return(false);
            }
            #endregion

            return(true);
        }
Exemple #29
0
 public void Configure(WallModel wallModel)
 {
     WallModel = wallModel;
 }
Exemple #30
0
 private bool IsOwner(WallModel model, GenericWallRequest request)
 {
     return(model.OwnerPrivate == GetPrivateKey(request));
 }