public async Task <ApiModels.SecondaryObject> CreateAsync(Guid primaryObjectd, ApiModels.SecondaryObject inputModel) { var domainSecondaryObject = await _secondaryObjectService.CreateAsync(primaryObjectd, inputModel); Ensure.That(domainSecondaryObject, nameof(domainSecondaryObject)) .WithException(_ => new HttpResponseException(HttpStatusCode.BadRequest)) .IsNotNull(); return(this.Map(domainSecondaryObject)); }
public async Task <ActionResult> Create(Guid id, FormCollection collection) { var model = new Models.SecondaryObject() { Description = collection[nameof(Models.SecondaryObject.Description)], Name = collection[nameof(Models.SecondaryObject.Name)], PrimaryObjectId = id, }; try { await _secondaryObjectService.CreateAsync(id, model); return(RedirectToAction("Edit", "PrimaryObjects", new { id = id })); } catch (Exception ex) { return(View(model)); } }