public async Task <IActionResult> GetDimension([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dimension = await dimensionRepository.FindById(id);

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

            DimensionDTO dto = new DimensionDTO();

            dto.Depth             = new MeasureDTO();
            dto.Height            = new MeasureDTO();
            dto.Width             = new MeasureDTO();
            dto.DimensionId       = dimension.DimensionId;
            dto.Depth.Id          = dimension.Depth.MeasureId;
            dto.Depth.Value       = dimension.Depth.Value;
            dto.Depth.ValueMax    = dimension.Depth.ValueMax;
            dto.Depth.isDiscrete  = dimension.Depth.isDiscrete;
            dto.Height.Id         = dimension.Height.MeasureId;
            dto.Height.Value      = dimension.Height.Value;
            dto.Height.ValueMax   = dimension.Height.ValueMax;
            dto.Height.isDiscrete = dimension.Height.isDiscrete;
            dto.Width.Id          = dimension.Width.MeasureId;
            dto.Width.Value       = dimension.Width.Value;
            dto.Width.ValueMax    = dimension.Width.ValueMax;
            dto.Width.isDiscrete  = dimension.Width.isDiscrete;

            return(Ok(dto));
        }
        public async Task <IActionResult> PostDimension([FromBody] DimensionDTO dimensionDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dimension = await dimensionRepository.Add(dimensionDTO);

            if (dimension == null)
            {
                return(BadRequest());
            }

            DimensionDTO dto = new DimensionDTO();

            dto.Depth             = new MeasureDTO();
            dto.Height            = new MeasureDTO();
            dto.Width             = new MeasureDTO();
            dto.DimensionId       = dimension.DimensionId;
            dto.Depth.Id          = dimension.Depth.MeasureId;
            dto.Depth.Value       = dimension.Depth.Value;
            dto.Depth.ValueMax    = dimension.Depth.ValueMax;
            dto.Depth.isDiscrete  = dimension.Depth.isDiscrete;
            dto.Height.Id         = dimension.Height.MeasureId;
            dto.Height.Value      = dimension.Height.Value;
            dto.Height.ValueMax   = dimension.Height.ValueMax;
            dto.Height.isDiscrete = dimension.Height.isDiscrete;
            dto.Width.Id          = dimension.Width.MeasureId;
            dto.Width.Value       = dimension.Width.Value;
            dto.Width.ValueMax    = dimension.Width.ValueMax;
            dto.Width.isDiscrete  = dimension.Width.isDiscrete;

            return(CreatedAtAction("GetDimension", dto));
        }
        public IEnumerable <DimensionDTO> GetDimension()
        {
            List <DimensionDTO> dtos = new List <DimensionDTO>();

            foreach (Dimension dimension in dimensionRepository.FindAll())
            {
                DimensionDTO dto = new DimensionDTO();
                dto.Depth             = new MeasureDTO();
                dto.Height            = new MeasureDTO();
                dto.Width             = new MeasureDTO();
                dto.DimensionId       = dimension.DimensionId;
                dto.Depth.Id          = dimension.Depth.MeasureId;
                dto.Depth.Value       = dimension.Depth.Value;
                dto.Depth.ValueMax    = dimension.Depth.ValueMax;
                dto.Depth.isDiscrete  = dimension.Depth.isDiscrete;
                dto.Height.Id         = dimension.Height.MeasureId;
                dto.Height.Value      = dimension.Height.Value;
                dto.Height.ValueMax   = dimension.Height.ValueMax;
                dto.Height.isDiscrete = dimension.Height.isDiscrete;
                dto.Width.Id          = dimension.Width.MeasureId;
                dto.Width.Value       = dimension.Width.Value;
                dto.Width.ValueMax    = dimension.Width.ValueMax;
                dto.Width.isDiscrete  = dimension.Width.isDiscrete;

                dtos.Add(dto);
            }
            return(dtos);
        }
Ejemplo n.º 4
0
        public IEnumerable <ProductDTO> GetProduct()
        {
            List <ProductDTO> dtos = new List <ProductDTO>();

            foreach (Product product in productRepository.FindAll())
            {
                ProductDTO  dto     = new ProductDTO();
                CategoryDTO cat_dto = new CategoryDTO(product.category);
                dto.ProductId   = product.ProductId;
                dto.name        = product.name;
                dto.description = product.description;
                dto.dimensions  = new List <DimensionDTO>();
                dto.materials   = new List <MaterialDTO>();
                foreach (ProductMaterial pm in product.ProductMaterials)
                {
                    MaterialDTO mat_dto = new MaterialDTO();
                    mat_dto.name        = pm.Material.name;
                    mat_dto.description = pm.Material.description;
                    mat_dto.MaterialId  = pm.Material.MaterialId;
                    mat_dto.finishes    = new List <FinishingDTO>();

                    foreach (MaterialFinishing mf in pm.Material.MaterialFinishings)
                    {
                        FinishingDTO fdto = new FinishingDTO();
                        fdto.finishingId = mf.Finishing.FinishingId;
                        fdto.description = mf.Finishing.description;
                        fdto.name        = mf.Finishing.name;
                        mat_dto.finishes.Add(fdto);
                    }

                    dto.materials.Add(mat_dto);
                }

                foreach (Dimension dimension in product.dimensions)
                {
                    DimensionDTO dim_dto = new DimensionDTO();
                    dim_dto.Depth             = new MeasureDTO();
                    dim_dto.Height            = new MeasureDTO();
                    dim_dto.Width             = new MeasureDTO();
                    dim_dto.DimensionId       = dimension.DimensionId;
                    dim_dto.Depth.Id          = dimension.Depth.MeasureId;
                    dim_dto.Depth.Value       = dimension.Depth.Value;
                    dim_dto.Depth.ValueMax    = dimension.Depth.ValueMax;
                    dim_dto.Depth.isDiscrete  = dimension.Depth.isDiscrete;
                    dim_dto.Height.Id         = dimension.Height.MeasureId;
                    dim_dto.Height.Value      = dimension.Height.Value;
                    dim_dto.Height.ValueMax   = dimension.Height.ValueMax;
                    dim_dto.Height.isDiscrete = dimension.Height.isDiscrete;
                    dim_dto.Width.Id          = dimension.Width.MeasureId;
                    dim_dto.Width.Value       = dimension.Width.Value;
                    dim_dto.Width.ValueMax    = dimension.Width.ValueMax;
                    dim_dto.Width.isDiscrete  = dimension.Width.isDiscrete;

                    dto.dimensions.Add(dim_dto);
                }
                dtos.Add(dto);
            }
            return(dtos);
        }
Ejemplo n.º 5
0
        public IDimension GetNew()
        {
            _dto = new DimensionDTO();
            _view.BindToSource(_dto);

            using (var presenter = IoC.Resolve <IModalPresenter>())
            {
                presenter.Encapsulate(this);
                if (presenter.Show())
                {
                    return(dimensionFromDTO());
                }
            }
            return(null);
        }
Ejemplo n.º 6
0
        public DimensionDTO MapFrom(IDimension input)
        {
            var dto = new DimensionDTO
            {
                Name     = input.Name,
                BaseUnit = input.BaseUnit != null ? input.BaseUnit.Name : String.Empty,
                Units    = new List <Unit>(input.Units.MapAllUsing(_unitToDTOUnitMapper))
            };

            if (input.BaseRepresentation != null)
            {
                dto.Amount            = input.BaseRepresentation.AmountExponent;
                dto.ElectricCurrent   = input.BaseRepresentation.ElectricCurrentExponent;
                dto.Length            = input.BaseRepresentation.LengthExponent;
                dto.LuminousIntensity = input.BaseRepresentation.LuminousIntensityExponent;
                dto.Mass        = input.BaseRepresentation.MassExponent;
                dto.Temperature = input.BaseRepresentation.TemperatureExponent;
                dto.Time        = input.BaseRepresentation.TimeExponent;
            }

            return(dto);
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> GetProduct([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var product = await productRepository.FindById(id);

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

            ProductDTO  dto     = new ProductDTO();
            CategoryDTO cat_dto = new CategoryDTO(product.category);

            dto.ProductId   = product.ProductId;
            dto.name        = product.name;
            dto.description = product.description;
            dto.dimensions  = new List <DimensionDTO>();
            dto.materials   = new List <MaterialDTO>();
            foreach (ProductMaterial pm in product.ProductMaterials)
            {
                MaterialDTO mat_dto = new MaterialDTO();
                mat_dto.name        = pm.Material.name;
                mat_dto.description = pm.Material.description;
                mat_dto.MaterialId  = pm.Material.MaterialId;
                mat_dto.finishes    = new List <FinishingDTO>();

                foreach (MaterialFinishing mf in pm.Material.MaterialFinishings)
                {
                    FinishingDTO fdto = new FinishingDTO();
                    fdto.finishingId = mf.Finishing.FinishingId;
                    fdto.description = mf.Finishing.description;
                    fdto.name        = mf.Finishing.name;
                    mat_dto.finishes.Add(fdto);
                }

                dto.materials.Add(mat_dto);
            }

            foreach (Dimension dimension in product.dimensions)
            {
                DimensionDTO dim_dto = new DimensionDTO();
                dim_dto.Depth             = new MeasureDTO();
                dim_dto.Height            = new MeasureDTO();
                dim_dto.Width             = new MeasureDTO();
                dim_dto.DimensionId       = dimension.DimensionId;
                dim_dto.Depth.Id          = dimension.Depth.MeasureId;
                dim_dto.Depth.Value       = dimension.Depth.Value;
                dim_dto.Depth.ValueMax    = dimension.Depth.ValueMax;
                dim_dto.Depth.isDiscrete  = dimension.Depth.isDiscrete;
                dim_dto.Height.Id         = dimension.Height.MeasureId;
                dim_dto.Height.Value      = dimension.Height.Value;
                dim_dto.Height.ValueMax   = dimension.Height.ValueMax;
                dim_dto.Height.isDiscrete = dimension.Height.isDiscrete;
                dim_dto.Width.Id          = dimension.Width.MeasureId;
                dim_dto.Width.Value       = dimension.Width.Value;
                dim_dto.Width.ValueMax    = dimension.Width.ValueMax;
                dim_dto.Width.isDiscrete  = dimension.Width.isDiscrete;

                dto.dimensions.Add(dim_dto);
            }

            return(Ok(dto));
        }
Ejemplo n.º 8
0
 public void BindToSource(DimensionDTO dto)
 {
     _screenBinder.BindToSource(dto);
     _gridBinder.BindToSource(dto.Units);
 }