public async Task TagUpdated(TagUpdated @event) { var repos = this._unitOfWork.GetRepositoryAsync <TagsEntity>(); //删除原有的。 await repos.DelAsync(t => t.CourseId == @event.CourseId); // await this.InsertTags( @event.Val, @event.CourseId, @event.SchoolId, @event.RegtionId, @event.CreatorId, @event.SchoolName, @event.RegionName); this._unitOfWork.SaveChanges(); }
public async Task <IActionResult> UpdateByIdAsync(int id, [FromBody] TagArgs args) { ValidateTagArgs(args); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_entityIndex.Exists(ResourceType.Tag, id)) { return(NotFound()); } if (!UserPermissions.IsAllowedToEdit(User.Identity, args.Status, _entityIndex.Owner(ResourceType.Tag, id))) { return(Forbid()); } var oldStatus = _entityIndex.Status(ResourceType.Tag, id).GetValueOrDefault(); if (args.Status == ContentStatus.Unpublished && oldStatus != ContentStatus.Published) { return(BadRequest(ErrorMessages.CannotBeUnpublished(ResourceType.Tag))); } var tagIdWithSameTitle = _tagIndex.GetIdByTagTitle(args.Title); if (tagIdWithSameTitle != null && tagIdWithSameTitle != id) { return(StatusCode(409, ErrorMessages.TagNameAlreadyUsed)); } var ev = new TagUpdated { Id = id, UserId = User.Identity.GetUserIdentity(), Properties = args, Timestamp = DateTimeOffset.Now, }; await _eventStore.AppendEventAsync(ev); return(NoContent()); }
private async Task SaveTag() { if (string.IsNullOrWhiteSpace(Tag.Name)) { await pageService.DisplayAlert("Error", "Tag Name Cannot be Blank", "OK"); return; } if (Tag.TagId == 0) // New Tag { await tagStore.AddTag(Tag); TagAdded?.Invoke(this, Tag); } else // Exisiting Tag { await tagStore.UpdateTag(Tag); TagUpdated?.Invoke(this, Tag); } await pageService.PopAsync(); }
private void NewTag_Changed(object sender, EventArgs e) { TagUpdated?.Invoke(null); }