コード例 #1
0
        public async Task <IActionResult> Create(GroupActionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var username = User.Identity.Name;
                var user     = await _userManager.FindByNameAsync(username);

                var profile = await _profileService.GetProfileByUserId(user.Id);

                var groupDto = new GroupsDto
                {
                    ProfileId   = profile.Id,
                    Title       = model.Title,
                    Description = model.Description,
                    //Currency
                    CurrencyType = 933
                };

                await _groupService.AddAsync(groupDto);

                return(RedirectToAction("Index", "Group"));
            }

            return(View(model));
        }
コード例 #2
0
        public async Task AddAsync(GroupsDto group)
        {
            if (group is null)
            {
                throw new ArgumentNullException(nameof(group));
            }
            var groupGuid  = Guid.NewGuid();
            var groupModel = new Groups
            {
                ProfileId   = group.ProfileId,
                Title       = group.Title,
                Description = group.Description,
                Guid        = groupGuid,
            };

            await _repository.AddAsync(groupModel);

            await _repository.SaveChangesAsync();

            var getGroup = await _repository.GetEntityWithoutTrackingAsync(group => group.Title == groupModel.Title && group.Guid == groupModel.Guid);

            var groupProfileModel = new GroupProfiles
            {
                ProfileId = getGroup.ProfileId,
                GroupId   = getGroup.Id
            };

            await _repositoryGroupProfiles.AddAsync(groupProfileModel);

            await _repository.SaveChangesAsync();
        }
コード例 #3
0
        public static GroupsDto ConvertToSingleDto(Group groups)
        {
            GroupsDto newgroups = new GroupsDto();

            newgroups.Id   = groups.Id;
            newgroups.Name = groups.Name;
            return(newgroups);
        }
コード例 #4
0
        public static Group ConvertToGroups(GroupsDto groups)
        {
            Group newgroups = new Group();

            newgroups.Id     = groups.Id;
            newgroups.Name   = groups.Name;
            newgroups.Image  = groups.Image;
            newgroups.Events = EventsConvertion.convertToListEvent(groups.Events);
            return(newgroups);
        }
コード例 #5
0
        public static GroupsDto ConvertToDto(Group groups)
        {
            GroupsDto newgroups = new GroupsDto();

            newgroups.Id     = groups.Id;
            newgroups.Name   = groups.Name;
            newgroups.Image  = groups.Image;
            newgroups.Events = EventsConvertion.ConvertToDtoList(groups.Events.ToList());
            return(newgroups);
        }
コード例 #6
0
        public IHttpActionResult DeleteUserFromGroup(DeleteUserFromGroupRequest request)
        {
            GroupsDto group = GroupService.DeleteUserFromGroup(request);

            if (group == null)
            {
                return(BadRequest());
            }
            if (group != null)
            {
                return(Ok(group));
            }
            return(BadRequest());
        }
コード例 #7
0
        public IHttpActionResult AddGroup(AddGroupRequest request)
        {
            GroupsDto group = GroupService.AddGroup(request);

            if (group == null)
            {
                return(BadRequest());
            }
            if (group != null)
            {
                return(Ok(group));
            }
            return(BadRequest());
        }
コード例 #8
0
        public async Task Edit(GroupsDto group)
        {
            if (group is null)
            {
                throw new ArgumentNullException(nameof(group));
            }
            ;
            var editGroup = await _repository.GetEntityAsync(q => q.Id.Equals(group.Id));

            editGroup.Title       = group.Title;
            editGroup.Description = group.Description;
            _repository.Update(editGroup);
            await _repository.SaveChangesAsync();
        }
コード例 #9
0
        public async Task <IActionResult> Edit(GroupActionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var groupDto = new GroupsDto
                {
                    Id          = model.Id,
                    Title       = model.Title,
                    Description = model.Description,
                };

                await _groupService.Edit(groupDto);

                return(RedirectToAction("Detail", "Group", new { id = groupDto.Id }));
            }
            return(View(model));
        }
コード例 #10
0
        public async Task <GroupsDto> GetGroupByGuidAsync(Guid guid)
        {
            var group = await _repository.GetEntityWithoutTrackingAsync(group => group.Guid == guid);

            if (group is null)
            {
                return(new GroupsDto());
            }

            var groupDto = new GroupsDto
            {
                Id          = group.Id,
                Title       = group.Title,
                Description = group.Description
            };

            return(groupDto);
        }