public async Task <IActionResult> CreateOrUpdateTag([FromBody] UpdateTagModel model) { if (model.TagId != default) { var result = await tagService.Update(model.TagId, model.TagName, model.TagDescription, ApplicationContext).ConfigureAwait(false); if (result.State == ResultState.Success) { return(Ok(result.Data.Map())); } return(BadRequest(result.FailureReason)); } else { var result = await tagService.Create(model.TagName, model.TagDescription, ApplicationContext).ConfigureAwait(false); if (result.State == ResultState.Success) { return(Ok(result.Data.Map())); } return(BadRequest(result.FailureReason)); } }
public async Task UpdateTag(Guid tagId, string tagName, string tagDescription) { if (!userService.IsUserAdmin) { return; } var model = new UpdateTagModel { TagId = tagId, TagName = tagName, TagDescription = tagDescription }; var updatedTag = await apiGateway.Post <TagModel, UpdateTagModel>(model, "tags").ConfigureAwait(false); if (updatedTag != null) { var existingTag = Tags.Find(x => x.TagId == tagId); if (existingTag != null) { Tags.Remove(existingTag); } Tags.Add(updatedTag); NotifyStateChanged(); } }
public async Task <bool> UpdateTag([FromBody] UpdateTagModel model) { var result = false; result = await Server.UpdateTag(model.ID, model.Name, model.Description); return(result); }