예제 #1
0
        public void UpdateGroup(GroupUpdateModel input)
        {
            var user  = _userService.GetCurrentUser();
            var group = _groupQueryService.GetGroup(input.Group.Id);

            group.Name           = input.Group.Name;
            group.Description    = input.Group.Description;
            group.LastUpdateDate = DateTime.Now;
            group.LastUpdatedBy  = user.Identity.Name;

            using (var dbContextScope = _dbContextScopeFactory.Create())
            {
                var dbContext = dbContextScope.DbContexts.Get <EntityManagerDbContext>();

                dbContext.Set <Group>().AddOrUpdate(group);
                dbContext.SaveChanges();
            }
        }
예제 #2
0
        /// <inheritdoc/>
        public Group CreateGroup(GroupCreateDto dto)
        {
            var now    = DateUtil.Now;
            var entity = new GroupTableEntity
            {
                GroupId     = Guid.NewGuid(),
                GroupCode   = dto.GroupCode,
                GroupTree   = dto.GroupTree,
                Name        = dto.Name,
                Description = dto.Description,
                Status      = dto.Status,
                SortNo      = dto.SortNo,
                CreateTime  = now,
                UpdateTime  = now,
            };

            using (var tran = new TransactionScope())
            {
                _groupRepository.Create(entity);

                foreach (var tag in dto.Tags)
                {
                    _tagRepository.Create(new TagTableEntity
                    {
                        TagId       = Guid.NewGuid(),
                        TargetId    = entity.GroupId,
                        Value       = tag,
                        TargetTable = "Group",
                        CreateTime  = now,
                    });
                }

                tran.Complete();
            }
            return(_groupQueryService.GetGroup(entity.GroupId));
        }
예제 #3
0
        public ActionResult Details(Guid id)
        {
            var group = _groupQueryService.GetGroup(id);

            return(View("Details", group));
        }