public IActionResult UpdateReminderStatus(Guid id, [FromBody] JsonPatchDocument jsonPatchDocument)
        {
            var reminderItem = _reminderStorage.Get(id);

            if (reminderItem == null)
            {
                BadRequest();
            }

            if (jsonPatchDocument == null || !ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var reminderItemModelToPatch = new ReminderItemUpdateModel
            {
                Status = reminderItem.Status
            };

            jsonPatchDocument.ApplyTo(reminderItemModelToPatch);

            _reminderStorage.UpdateStatus(reminderItem.Id, reminderItem.Status);

            return(NoContent());
        }
        public IActionResult UpdateReminderStatus([FromBody] ReminderItemsUpdateModel reminderItemsUpdateModel)
        {
            if (reminderItemsUpdateModel == null || !ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var reminderItemModelToPatch = new ReminderItemUpdateModel();

            reminderItemsUpdateModel.PatchDocument.ApplyTo(reminderItemModelToPatch);

            _reminderStorage.UpdateStatus(reminderItemsUpdateModel.Ids, reminderItemModelToPatch.Status);

            return(NoContent());
        }
Пример #3
0
        public void Update(Guid id, ReminderItemStatus status)
        {
            // PATCH http://localhost:5000/api/reminders/id ReminderItemUpdateModel

            var model = new ReminderItemUpdateModel {
                Status = status
            };
            string content = JsonConvert.SerializeObject(model);

            HttpResponseMessage response = SendRequest(
                _baseWebApiUrl + $"/{id}",
                "PATCH",
                content);

            ThrowExceptionIfStatusCodeOtherThan(HttpStatusCode.NoContent, response);
        }
Пример #4
0
        public IActionResult Update(Guid id, [FromBody] ReminderItemUpdateModel model)
        {
            ReminderItem reminderItem = _reminderStorage.Get(id);

            if (reminderItem == null)
            {
                return(NotFound());
            }

            if (model == null && !ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _reminderStorage.Update(id, model.Status);
            return(NoContent());
        }
        public IActionResult Update(Guid id, [FromBody] ReminderItemUpdateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ReminderItem reminderItem = _storage.Get(id);

            if (reminderItem == null)
            {
                return(NotFound());
            }

            model.UpdateRemiderItem(reminderItem);
            _storage.Update(reminderItem);

            return(NoContent());
        }
        public IActionResult Update(Guid id, [FromBody] ReminderItemUpdateModel model)
        {
            _logger.LogInformation($"{nameof(Update)} called");

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var reminderItem = _storage.Get(id);

            if (reminderItem == null)
            {
                return(NotFound());
            }

            model.UpdateReminderItem(reminderItem);
            _storage.Update(reminderItem);

            return(NoContent());
        }