public Result <EmptyResult> UpdateGroup(UpdateGroupCommand command) { if (command.OrganizationId <= 0) { return(new Result <EmptyResult>(GroupServiceErrors.InvalidUpdateGroupDataError(nameof(command.OrganizationId)))); } if (command.GroupId <= 0) { return(new Result <EmptyResult>(GroupServiceErrors.InvalidUpdateGroupDataError(nameof(command.GroupId)))); } if (!groupRepository.GroupExists(command.GroupId, command.OrganizationId)) { return(new Result <EmptyResult>(GroupServiceErrors.GroupNotFoundError())); } if (groupRepository.GroupNameExists(command.GroupId, command.Name, command.OrganizationId)) { return(new Result <EmptyResult>(GroupServiceErrors.GroupAlreadyExistsError())); } groupRepository.UpdateGroup(command); return(new Result <EmptyResult>()); }
public Result <int> CreateGroup(CreateGroupCommand command) { if (command.OrganizationId <= 0) { return(new Result <int>(GroupServiceErrors.InvalidCreateGroupDataError(nameof(command.OrganizationId)))); } if (command.ParentGroupId <= 0) { return(new Result <int>(GroupServiceErrors.InvalidCreateGroupDataError(nameof(command.ParentGroupId)))); } if (string.IsNullOrWhiteSpace(command.Name)) { return(new Result <int>(GroupServiceErrors.InvalidCreateGroupDataError(nameof(command.Name)))); } if (groupRepository.GroupExists(command.Name, command.OrganizationId)) { return(new Result <int>(GroupServiceErrors.GroupAlreadyExistsError())); } return(new Result <int>(this.groupRepository.CreateGroup(command))); }