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)); }
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(); }
public static GroupsDto ConvertToSingleDto(Group groups) { GroupsDto newgroups = new GroupsDto(); newgroups.Id = groups.Id; newgroups.Name = groups.Name; return(newgroups); }
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); }
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); }
public IHttpActionResult DeleteUserFromGroup(DeleteUserFromGroupRequest request) { GroupsDto group = GroupService.DeleteUserFromGroup(request); if (group == null) { return(BadRequest()); } if (group != null) { return(Ok(group)); } return(BadRequest()); }
public IHttpActionResult AddGroup(AddGroupRequest request) { GroupsDto group = GroupService.AddGroup(request); if (group == null) { return(BadRequest()); } if (group != null) { return(Ok(group)); } return(BadRequest()); }
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(); }
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)); }
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); }