public async void GetListOfLaptopAsyncTest() { ILaptopService laptopService = GetServiceObject(); DC.LaptopResponse list = await laptopService.GetListOfLaptopAsync(); Assert.NotEmpty(list.Laptops); }
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))); }
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)); }
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); }
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); }
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); }