Ejemplo n.º 1
0
        public static VendorInformationDbModel ToVendorInformationDbModel(this VendorInformationBo vendorInformationBo)
        {
            MapperConfiguration config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <VendorInformationBo, VendorInformationDbModel>()
                .ForMember(dest => dest.CategoryModels, opt => opt.MapFrom(src => src.Categories));
            });
            IMapper iMapper = config.CreateMapper();

            return(iMapper.Map <VendorInformationBo, VendorInformationDbModel>(vendorInformationBo));
        }
        public HttpResponseMessage GetVendorInformation(string id)
        {
            VendorInformationBo vendorModel = null;

            bool isIdInGuidFormat = Guid.TryParseExact(id, "D", out Guid guid);

            if (isIdInGuidFormat)
            {
                IVendorInformationService service = new VendorInformationService();
                vendorModel = service.GetVendorInformation(guid);
            }

            if (vendorModel == null)
            {
                string    message = $"Vendor {id} is not found";
                HttpError err     = new HttpError(message);
                return(Request.CreateResponse(HttpStatusCode.NotFound, err));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, vendorModel));
        }
Ejemplo n.º 3
0
        public void ResetTestData()
        {
            _vendor1 = new VendorInformationBo
            {
                Id         = Guid.NewGuid(),
                Name       = "Test corporation",
                Rating     = 2,
                Categories = new List <CategoryBo>
                {
                    new CategoryBo
                    {
                        Id   = Guid.NewGuid(),
                        Name = "Test name"
                    },
                    new CategoryBo
                    {
                        Id   = Guid.NewGuid(),
                        Name = "Test name2"
                    }
                }
            };

            _vendor2 = new VendorInformationBo
            {
                Id         = Guid.NewGuid(),
                Name       = "Test vendor",
                Rating     = 99,
                Categories = new List <CategoryBo>
                {
                    new CategoryBo
                    {
                        Id   = Guid.NewGuid(),
                        Name = "Test software for second vendor, first category"
                    }
                }
            };
        }
 public void InsertVendorInformation(VendorInformationBo vendorInfo)
 {
     VendorInformationRepository.InsertVendorInformation(vendorInfo.ToVendorInformationDbModel());
 }