public void AddProduct() { //string urlSuffix = "api/phone/masterdata/addcategory"; HttpClient client = Client(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); Guid categoryid = Guid.NewGuid(); CategoryDTO dto = new CategoryDTO() { Name = Guid.NewGuid().ToString(), Id = categoryid, IsActive = true, AccountId = GetAccountId(), Description = "noma", }; var response = client.PostAsJsonAsync("api/phone/masterdata/addcategory", dto); var _response = response.Result; ProductDTO product = new ProductDTO() { Name = Guid.NewGuid().ToString(), Id = Guid.NewGuid(), IsActive = true, BuyingPrice = 1, SellingPrice = 90, AccountId = GetAccountId(), CategoryId = categoryid, Description = "product web api", }; var response2 = client.PostAsJsonAsync("api/phone/masterdata/addproduct", product); var _response2 = response2.Result; }
public BasicResponse AddProduct(ProductDTO dto) { BasicResponse response = new BasicResponse(); try { var account = new Product() { Name = dto.Name, Id = dto.Id, AccountId = dto.AccountId, Description = dto.Description, IsActive = true, CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, CategoryId = dto.CategoryId, BuyingPrice = dto.BuyingPrice, SellingPrice = dto.SellingPrice, }; _productRepository.Save(account); response.Status = true; response.Info = "Success"; } catch (Exception ex) { response.Status = false; response.Info = ex.Message; } return response; }
public BasicResponse AddProduct(ProductDTO dto) { var all = _dataTransferBuilder.AddProduct(dto); return all; }