Example #1
0
        public IHttpActionResult EditWall(UpdateWallViewModel updateWallViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var updateWallDto = _mapper.Map <UpdateWallViewModel, UpdateWallDto>(updateWallViewModel);

            SetOrganizationAndUser(updateWallDto);

            try
            {
                _wallService.UpdateWall(updateWallDto);
                return(Ok());
            }
            catch (ValidationException e)
            {
                return(BadRequestWithError(e));
            }
            catch (UnauthorizedException)
            {
                return(Unauthorized());
            }
        }
Example #2
0
        private void UpdateWall(EditProjectDto dto, int wallId)
        {
            var updateWallDto = new UpdateWallDto
            {
                Id             = wallId,
                Description    = dto.Description,
                Logo           = dto.Logo,
                Name           = dto.Title,
                OrganizationId = dto.OrganizationId,
                UserId         = dto.UserId
            };

            _wallService.UpdateWall(updateWallDto);
        }
Example #3
0
        public IHttpActionResult UpdateWall(WallUpdateModel model)
        {
            _wallService.UpdateWall(model, User.Identity.GetUserId());

            return(Ok());
        }
Example #4
0
        public IHttpActionResult SaveMap(SiteViewModel model)
        {
            foreach (var wall in model.WallViewModels)
            {
                if (wall.IsDirty)
                {
                    if (!wall.IsDelete)
                    {
                        if (wall.Id != null)
                        {
                            if (!wall.Length.Equals(0))
                            {
                                _wallService.UpdateWall(
                                    new WallUpdateModel
                                {
                                    Angle  = wall.Angle,
                                    Length = wall.Length,
                                    SiteId = wall.SiteId,
                                    WallId = wall.Id,
                                    X      = wall.X,
                                    Y      = wall.Y,
                                    Type   = wall.Type,
                                }, User.Identity.GetUserId());
                            }
                            else
                            {
                                var deleteModel = new WallUpdateModel
                                {
                                    SiteId = wall.SiteId,
                                    WallId = wall.Id
                                };
                                _wallService.DeleteWall(deleteModel, User.Identity.GetUserId());
                            }
                        }
                        else if (wall.Length > 0)
                        {
                            _wallService.CreateWall(new WallUpdateModel
                            {
                                Angle  = wall.Angle,
                                Length = wall.Length,
                                SiteId = wall.SiteId,
                                WallId = wall.Id,
                                X      = wall.X,
                                Y      = wall.Y,
                                Type   = wall.Type,
                            });
                        }
                    }
                    else
                    {
                        if (wall.Id != null)
                        {
                            var deleteModel = new WallUpdateModel
                            {
                                SiteId = wall.SiteId,
                                WallId = wall.Id
                            };
                            _wallService.DeleteWall(deleteModel, User.Identity.GetUserId());
                        }
                    }
                }
            }

            var result = _siteService.GetSite(model.Id, User.Identity.GetUserId());

            var obj = new
            {
                Success = true,
                Message = "",
                Result  = result
            };

            return(Ok(obj));
        }