public async Task <IDomainResult> AssignToUser(string backlogItemId, string?userShortenId) { var fullId = GetFullId(backlogItemId); if (!await DbSession.Advanced.ExistsAsync(fullId)) { return(IDomainResult.NotFound("The Backlog Item not found")); } UserReference?userRef = null; if (userShortenId != null) { userRef = await _userResolver.GetReferenceById(userShortenId); if (userRef == null) { return(DomainResult.NotFound("The user not found")); } userRef = userRef.RemoveEntityPrefixFromId(); } DbSession.Advanced.Patch <BacklogItem, UserReference?>(fullId, x => x.Assignee, userRef); await AddHistoryRecordPatch(backlogItemId, userRef == null? "Removed assigned user" : $"Assigned user '{userRef.MentionedName}'"); return(IDomainResult.Success()); }
public async Task <IDomainResult> SetState(string backlogItemId, BacklogItemState newState) { var fullId = GetFullId(backlogItemId); if (!await DbSession.Advanced.ExistsAsync(fullId)) { return(IDomainResult.NotFound()); } DbSession.Advanced.Patch <BacklogItem, BacklogItemState>(fullId, x => x.State, newState); await AddHistoryRecordPatch(backlogItemId, $"Changed status to {newState.ToString()}"); return(IDomainResult.Success()); }