public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,DT_Creation,DT_DeadLine,DT_Done,Priority")] TodoItem todoItem)
        {
            if (id != todoItem.Id)
            {
                return(NotFound());
            }

            try
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(todoItem), Encoding.UTF8, "application/json");

                await _api.Put(todoItem.Id, content);
            }
            catch (Exception ex)
            {
                if (!await TodoItemExists(todoItem.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
示例#2
0
        /// <summary>
        /// Updates the entity
        /// </summary>
        /// <returns>True if the entity is updated</returns>
        public Boolean Update(object entity)
        {
            // Convert object to json
            var    converter = new EntityConverter();
            string json      = converter.ConvertObjectToJson(OriginalEntity, entity, _entityControllerDelegate);

            // Update entire object
            Boolean returnValue = false;

            // Update and set _originalentity to current entity (_entity)
            if (_connection.Put(_keyName, _identifier, json))
            {
                returnValue    = true;
                OriginalEntity = Clone(entity);
            }
            return(returnValue);
        }
 /// <inheritdoc />
 public async Task <HttpResponse <Annotation> > UpdateAnnotation(string annotationId,
                                                                 AnnotationPayload annotationPayload,
                                                                 TextFormat textFormat)
 {
     return(await _apiConnection.Put <Annotation>(textFormat, annotationId, annotationPayload));
 }