Ejemplo n.º 1
0
        public async Task <ActionResult> Edit(Guid id)
        {
            var secondaryObject = await _secondaryObjectService.GetAsync(id);

            var model = new Models.SecondaryObject()
            {
                Id              = secondaryObject.Id,
                Description     = secondaryObject.Description,
                Name            = secondaryObject.Name,
                PrimaryObjectId = secondaryObject.PrimaryObject?.Id,
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Edit(Guid id)
        {
            var primaryObject = await _primaryObjectService.GetAsync(id);

            var secondaryObjectModels = new List <Models.SecondaryObject>();

            if (primaryObject.SecondaryObjects != null)
            {
                foreach (var secondaryObjectThin in primaryObject.SecondaryObjects.Where(so => so.Id.HasValue))
                {
                    var secondaryObject = await _secondaryObjectService.GetAsync(secondaryObjectThin.Id.Value);

                    secondaryObjectModels.Add(new Models.SecondaryObject()
                    {
                        Id              = secondaryObject.Id,
                        Description     = secondaryObject.Description,
                        Name            = secondaryObject.Name,
                        PrimaryObjectId = primaryObject.Id,
                    });
                }
            }

            var model = new Models.PrimaryObject()
            {
                Id               = primaryObject.Id,
                Description      = primaryObject.Description,
                Name             = primaryObject.Name,
                SecondaryObjects = secondaryObjectModels.OrderBy(_ => _.Name).ToArray(),
            };

            return(View(model));
        }
        public async Task <ApiModels.SecondaryObject> GetAsync(Guid id)
        {
            var domainSecondaryObject = await _secondaryObjectService.GetAsync(id);

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

            return(this.Map(domainSecondaryObject));
        }