Exemple #1
0
        // CreateRequestresponseModel
        public ActionResult Create([FromBody] CreateSmartphoneRequest smartphoneRequest)
        {
            var response = _smartphoneService.Create(new CreateSmartphoneRequest
            {
                SmartphoneModel   = smartphoneRequest.SmartphoneModel,
                ManufacturerModel = smartphoneRequest.ManufacturerModel
            });


            return(Ok(response));
        }
Exemple #2
0
        public IResponse <CreateSmartphoneResponse, int> Create(CreateSmartphoneRequest request)
        {
            var smartphoneModel   = request.SmartphoneModel;
            var manufacturerModel = request.ManufacturerModel;

            _smartphoneRepository.Create(new Smartphone(smartphoneModel.Name,
                                                        new Manufacturer(manufacturerModel.Name)
            {
                Id = manufacturerModel.Id
            },
                                                        smartphoneModel.Size,
                                                        smartphoneModel.Weight,
                                                        new ScreenResolution(smartphoneModel.ScreenWidth, smartphoneModel.ScreenHeight),
                                                        smartphoneModel.Ram,
                                                        smartphoneModel.Processor,
                                                        smartphoneModel.OperatingSystem,
                                                        smartphoneModel.Price));

            return(new CreateSmartphoneResponse
            {
                Data = smartphoneModel.Id,
                IsSuccess = true
            });
        }