public SpaceContract Add(string parentId, string name, string userId, string userName, string depId)
        {
            _logger.InfoFormat("Add Space parentId:{0},name:{1}, userId:{2}, userName:{3}, depId:{4}",
                               parentId, name, userId, userName);

            try
            {
                return
                    (_spaceService.Add(parentId, Guid.NewGuid().ToString(), name, userId, userName, depId, Visible.Public)
                     .ToObject <SpaceContract>());
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                _logger.Error(ex.StackTrace);
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
        public ActionResult Add()
        {
            _logger.Info("Enter SpaceController Add");

            var     userId    = _contextService.UserId;
            var     userName  = _contextService.NickName;
            var     depId     = _contextService.DepId;
            var     spaceName = _requestProvider["SpaceName"];
            var     parentId  = _requestProvider["ParentId"];
            Visible visiblity = Visible.Dep;

            //判断空间重名问题
            var children   = _spaceService.GetChildren(parentId, userId, depId);
            var spanObject = children.Find(f => f.SpaceName == spaceName);

            if (spanObject != null)
            {
                return(Json(spanObject));
            }
            try
            {
                _logger.Info(string.Format("Add Space, spacename:[{0}];userId:[{1}];userName:[{2}];parentId:[{3}]。", spaceName, userId, userName, parentId));

                var space = _spaceService.Add(parentId, Guid.NewGuid().ToString(), spaceName, userId, userName, depId, visiblity);
                if (space != null)
                {
                    _contextService.SpaceTreeHtml = _spaceTreeService.GetOrSetSpaceTree(_contextService.UserId);

                    return(Json(new SpaceViewModel(space, _contextService.UserId)));
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex.StackTrace);
                _logger.Error(ex.Message);
            }

            return(Json(new SpaceViewModel(new SpaceObject(), _contextService.UserId)));
        }
Exemple #3
0
        public void should_pass_rename_process()
        {
            int count = _spaceService.GetAllSpaces().Count;

            string userId = Guid.NewGuid().ToString();
            string depId  = Guid.NewGuid().ToString();

            var space = MakeSimpleSpace(userId, depId);

            Assert.IsNotNull(_spaceService.Add(space));
            var result = _spaceService.GetSpace(space.Id.ToString());

            Assert.AreEqual(result.SpaceName, "技术空间");

            Assert.IsNotNull(_spaceService.ReName(space.Id.ToString(), "产品空间"));
            space = _spaceService.GetSpace(space.Id.ToString());
            Assert.AreEqual(space.SpaceName, @"产品空间");


            _spaceService.Delete(space.Id.ToString());
            result = _spaceService.GetSpace(space.Id.ToString());
            Assert.IsNull(result);

            int count2 = _spaceService.GetAllSpaces().Count;

            Assert.AreEqual(count, count2);
        }