public async Task Post([FromBody] ApiProduct product) { Product newProduct = new Product() { Id = Guid.NewGuid(), Name = product.Name, Description = product.Description, Price = product.Price, Availability = 150 }; await _productCatalogService.AddProduct(newProduct); }
public async Task Post([FromBody] ApiProduct product) { var newProduct = new Product { Id = Guid.NewGuid(), Availability = 100, Name = product.Description, Description = product.Description, Price = product.Price }; await _catalogService.AddProductAsync(newProduct); }
public Task AddProductAsync([FromBody] ApiProduct product) { var newProduct = new Product { Id = Guid.NewGuid(), Name = product.Name, Description = product.Description, Price = product.Price, Availability = 100 }; return(_productCatalogService.AddProductAsync(newProduct)); }
public ApiProduct Put([FromBody] ApiProduct apiProduct) { try { int?id = apiProduct.ProID; apiProduct = service.Update(id, apiProduct); } catch (Exception ex) { throw ex; } return(apiProduct); }
public async Task PostAsync([FromBody] ApiProduct product) { var newProduct = new Product() { Id = Guid.NewGuid(), Name = product.Name, Description = product.Description, Price = product.Price, Availability = 100 }; await _service.AddProductAsync(newProduct); }
public ApiProduct Get(int id) { var existingProduct = context.Products.Include(p => p.Variants).SingleOrDefault(p => p.Id == id); if (existingProduct == null) { throw new ForagerApiException(ForagerApiExceptionCode.ListNotFound); } var product = ApiProduct.FromProduct(existingProduct); return(product); }
public async Task PostAsync([FromBody] ApiProduct apiProduct) { var newProduct = new Product.Model.Product() { Price = apiProduct.Price, Name = apiProduct.Name, Description = apiProduct.Description, Availability = apiProduct.Availability, Id = Guid.NewGuid() }; await _service.AddProductAsync(newProduct); }
public async Task PostAsync(ApiProduct product) { var productObj = new Product { Price = product.Price, Name = product.Name, Availability = 100, Description = product.Description, Id = product.Id }; await _service.AddProductAsync(productObj); }
public async Task Post([FromBody] ApiProduct product) { Product newProduct = new Product() { Description = product.Description, ID = Guid.NewGuid(), IsAvailable = product.IsAvailable, Name = product.Name, Price = product.Price }; await mService.AddProduct(newProduct); }
public ApiProduct Update(int?id, ApiProduct apiProduct) { var productInDB = db.Products.Where(p => p.ProID == id).FirstOrDefault(); if (productInDB != null) { apiProduct.ProID = productInDB.ProID; productInDB = Mapper.Map <ApiProduct, Product>(apiProduct); db.Entry(productInDB).State = System.Data.EntityState.Modified; db.SaveChanges(); } return(apiProduct); }
public ApiProduct Post([FromBody] ApiProduct apiproduct) { var product = Mapper.Map <ApiProduct, Product>(apiproduct, new Product(true)); product.ParticipantId = apiproduct.Participant.Href.ToId(); if (product.IsValid) { ParticipantContext.Products.Insert(product); apiproduct.Href = product.Id.ToProductHref(); return(apiproduct); } return(null); }
public ApiProduct GetSingle(int?id) { ApiProduct apiProduct = new ApiProduct(); try { apiProduct = service.GetSingle(id); } catch (Exception ex) { throw ex; } return(apiProduct); }
public ApiProduct Put(int?id, [FromBody] ApiProduct apiproduct) { var product = Mapper.Map <ApiProduct, Product>(apiproduct); product.ParticipantId = apiproduct.Participant.Href.ToId(); if (product.IsValid) { ParticipantContext.Products.Update(product); return(apiproduct); } return(null); }
public static ProductDto StaticDBToDto(Product product, ApiProduct apiProduct, ShoppingListEntry entry, TranslationOfProduct translation) { return(new ProductDto { Id = entry.Id, ProductTypeId = product.ProductType_Id, Name = translation.Translation, Currency_Id = (int)apiProduct.Currency_Id, Unit_Id = (int)apiProduct.Unit_Id, Quantity = (int)entry.Quantity, Price = (decimal)apiProduct.Price, ProductId = product.Id, //Category_Id = defaultProduct.Category_Id }); }
public async Task <ApiProduct> GetByIdAsync(Guid productId) { ApiProduct result = new ApiProduct(); Product product = await _service.GetProductAsync(productId); if (product != null) { result.Id = product.Id; result.Description = product.Description; result.Price = product.Price; result.IsAvailable = product.Availability > 0; } return(result); }
public async Task PostAsync([FromBody] ApiProduct product) { await _service.AddProductAsync( new Product() { Name = product.Name, Description = product.Description, Price = product.Price, Availbility = 1 } ); }
public void Update(ApiProduct it) { using (var context = _di.GetService <ApplicationDbContext>()) { var real = context.Products.Find(it.Id); if (real != null) { real.Color = it.Color; real.CategoryId = it.CategoryId; real.FreeNote = it.FreeNote; real.Model = it.Model; real.Producer = it.Producer; real.ProductType = it.ProductType; real.RecommendedBuyPrice = it.RecommendedBuyPrice; real.RecommendedSalePrice = it.RecommendedSalePrice; real.Size = it.Size; } context.SaveChanges(); } }
public ActionResult ProductList() { try { var token = GetProductUserToken(); var productList = ApiProduct.GetList(token.AccessToken, AppConfigBll.AppConfig.AppKey, AppConfigBll.AppConfig.AppSecrect, null, 1, 20, null, null); return(Json(productList)); } catch (Exception ex) { RPoney.Log.LoggerManager.Error(GetType().Name, "", ex); return(new EmptyResult()); } }
public ApiProduct[] PostAll(int p = 0, int s = 0, [FromBody] int[] ignores = null) { var currentUserEmail = userInformation.GetUserEmail(); var currentUser = context.GetUserByEmail(currentUserEmail); var familiesToInclude = currentUser.Families.Select(f => f.Id).Concat(new[] { ForagerContext.UniversalFamilyId }).ToArray(); var numberToTake = p == 0 ? context.Products.Count() : p; var products = context.Families .Include(p => p.FamilyProducts) .Where(f => familiesToInclude.Contains(f.Id)) .SelectMany(f => f.FamilyProducts) .Select(fp => fp.Product) .Where(p => ignores == null || !ignores.Contains(p.Id)) .OrderBy(p => p.Id) .Distinct() .OrderBy(p => p.Name) .Skip(s) .Take(numberToTake) .Select(p => ApiProduct.FromProduct(p)) .ToArray(); return(products); }
public ApiProduct Post(int id, [FromBody] ProductApiPutRequest productData) { if (string.IsNullOrWhiteSpace(productData.Name)) { throw new ForagerApiException(ForagerApiExceptionCode.InvalidNameProvided); } var existingProduct = context.Products.Include(p => p.Variants).SingleOrDefault(f => f.Id == id); if (existingProduct == null) { throw new ForagerApiException(ForagerApiExceptionCode.ProductNotFound); } existingProduct.Name = productData.Name.Trim(); existingProduct.Description = productData.Description?.Trim(); existingProduct.Units = productData.Units?.Trim(); context.SaveChanges(); var product = ApiProduct.FromProduct(existingProduct); return(product); }
public ApiProduct Update(int?id, ApiProduct product) { return(factory.ProductsDAO.Update(id, product)); }
public ApiProduct Add(ApiProduct product) { return(factory.ProductsDAO.Add(product)); }
public async Task ReturnApiProductByNameForValidJson() { var json = @"{ ""apiResources"": [ ""/*/featureinfo/*/*/*/*/*/*.**"" ], ""approvalType"": ""auto"", ""attributes"": [ { ""name"": ""MINT_TRANSACTION_SUCCESS_CRITERIA"", ""value"": ""txProviderStatus == '200'"" }, { ""name"": ""access"", ""value"": ""public"" }, { ""name"": ""transactionRecordingPolicies"", ""value"": ""[{\""name\"":\""/*/featureinfo/*/*/*/*/*/*.**\"",\""policies\"":{\""request\"":[],\""response\"":[\""{\\\""policyType\\\"":\\\""ExtractVariables\\\"",\\\""async\\\"":false,\\\""continueOnError\\\"":false,\\\""displayName\\\"":\\\""Transaction Policy\\\"",\\\""enabled\\\"":true,\\\""faultRules\\\"":[],\\\""ignoreUnresolvedVariables\\\"":true,\\\""jSONPayload\\\"":{\\\""variable\\\"":[]},\\\""name\\\"":\\\""\\\"",\\\""source\\\"":{\\\""clearPayload\\\"":false,\\\""value\\\"":\\\""response\\\""},\\\""variablePrefix\\\"":\\\""apigee\\\"",\\\""xMLPayload\\\"":{\\\""namespaces\\\"":[],\\\""stopPayloadProcessing\\\"":false,\\\""variable\\\"":[]},\\\""extractions\\\"":[{\\\""Variable\\\"":{\\\""name\\\"":\\\""response.status.code\\\"",\\\""pattern\\\"":[{\\\""ignoreCase\\\"":true,\\\""value\\\"":\\\""{mint.tx.status}\\\""}]}}]}\""]}}]"" } ], ""createdAt"": 1540825200000, ""createdBy"": ""*****@*****.**"", ""description"": ""test description"", ""displayName"": ""Name to display"", ""environments"": [], ""lastModifiedAt"": 1540828800000, ""lastModifiedBy"": ""*****@*****.**"", ""name"": ""Maps Feature Info"", ""proxies"": [ ""Maps-Online"" ], ""scopes"": [ """" ] }"; var apiProductName = "some product name"; var expectedApiProduct = new ApiProduct() { LastModifiedBy = "*****@*****.**", CreatedBy = "*****@*****.**", CreatedAt = 1540825200000, LastModifiedAt = 1540828800000, Description = "test description", DisplayName = "Name to display", Name = "Maps Feature Info" }; var url = BaseUrl + $"/v1/o/{OrgName}/apiproducts/{apiProductName}"; RegisterUrl(url, json); var apigeeService = GetApigeeClient(); var apiProduct = await apigeeService.GetApiProduct(apiProductName); expectedApiProduct.AsSource().OfLikeness <ApiProduct>() .Without(x => x.Attributes) .Without(x => x.IsPublic) .ShouldEqual(apiProduct); Assert.True(apiProduct.IsPublic); Assert.Equal(new DateTime(2018, 10, 29, 15, 0, 0), apiProduct.CreatedAtDateTime); Assert.Equal(new DateTime(2018, 10, 29, 16, 0, 0), apiProduct.LastModifiedAtDateTime); }
private static Product Map(ApiProduct apiProduct) => apiProduct is not null ? Product.Create(apiProduct.Id, apiProduct.Name, apiProduct.Ean, apiProduct.Stock)
protected ProductDto ConvertApiProductDBToDto(Product entity, ApiProduct apiProduct, ShoppingListEntry entry, TranslationOfProduct translation) { return(StaticDBToDto(entity, apiProduct, entry, translation)); }
public async Task Post([FromBody] ApiProduct product) { }