Beispiel #1
0
        public async void GetListOfLaptopAsyncTest()
        {
            ILaptopService laptopService = GetServiceObject();

            DC.LaptopResponse list = await laptopService.GetListOfLaptopAsync();

            Assert.NotEmpty(list.Laptops);
        }
Beispiel #2
0
        public async Task <IActionResult> GetListOfLaptopAsync()
        {
            DC.LaptopResponse result = await _laptopProvider.GetListOfLaptopAsync();

            if (result == null)
            {
                return(this.NotFound(result));
            }
            return(this.Ok(await Task.FromResult(result)));
        }
Beispiel #3
0
        public async Task <IActionResult> AddLaptopAsync([FromBody] DC.Laptop laptop)
        {
            DC.LaptopResponse result = null;
            result = await _laptopProvider.AddLaptopAsync(laptop);

            if (result == null)
            {
                return(this.StatusCode(StatusCodes.Status400BadRequest, "Unable to create site."));
            }
            return(Ok(result));
        }
Beispiel #4
0
        public async void AddLaptopAsyncTest()
        {
            ILaptopService laptopService = GetServiceObject();
            Laptop         laptop        = new Laptop();

            laptop.Name  = "Lenova";
            laptop.Price = "500";
            DC.LaptopResponse laptopResponse = await laptopService.AddLaptopAsync(laptop);

            Laptop laptopActual = laptopResponse.Laptops[laptopResponse.Laptops.Count - 1];

            Assert.Equal(laptop.Name, laptopActual.Name);
            Assert.Equal(laptop.Price, laptopActual.Price);
        }
Beispiel #5
0
        public async Task <DC.LaptopResponse> AddLaptopAsync(Laptop laptop)
        {
            DC.LaptopResponse laptopResponse1 = new DC.LaptopResponse();
            try
            {
                Model.LaptopResponse laptopResponse = await _laptopDAL.AddLaptopAsync(_mapper.Map <Model.Laptop>(laptop));

                laptopResponse1 = _mapper.Map <DC.LaptopResponse>(laptopResponse);
            }
            catch (Exception)
            {
            }
            return(laptopResponse1);
        }
Beispiel #6
0
        public async Task <DC.LaptopResponse> GetListOfLaptopAsync()
        {
            DC.LaptopResponse laptopResponse1 = new DC.LaptopResponse();
            try
            {
                Model.LaptopResponse laptopResponse = await _laptopDAL.GetListOfLaptopAsync();

                laptopResponse1 = _mapper.Map <DC.LaptopResponse>(laptopResponse);
            }
            catch (Exception)
            {
            }
            return(laptopResponse1);
        }