public async Task <ApiModels.SecondaryObject> UpdateAsync(Guid id, ApiModels.SecondaryObject inputModel)
        {
            var domainSecondaryObject = await _secondaryObjectService.UpdateAsync(id, inputModel);

            Ensure.That(domainSecondaryObject, nameof(domainSecondaryObject))
            .WithException(_ => new HttpResponseException(HttpStatusCode.NotFound))
            .IsNotNull();

            return(this.Map(domainSecondaryObject));
        }
Beispiel #2
0
        public async Task <ActionResult> Edit(Guid id, FormCollection collection)
        {
            var primaryObjectIdString = collection[nameof(Models.SecondaryObject.PrimaryObjectId)];
            var model = new Models.SecondaryObject()
            {
                Id              = id,
                Description     = collection[nameof(Models.SecondaryObject.Description)],
                Name            = collection[nameof(Models.SecondaryObject.Name)],
                PrimaryObjectId = string.IsNullOrWhiteSpace(primaryObjectIdString) ? null : Guid.Parse(primaryObjectIdString) as Guid?,
            };

            try
            {
                await _secondaryObjectService.UpdateAsync(id, model);

                return(RedirectToAction("Edit", "PrimaryObjects", new { id = model.PrimaryObjectId }));
            }
            catch (Exception ex)
            {
                return(View(model));
            }
        }