Ejemplo n.º 1
0
        public void Put(Guid guid, ProductColourInfo request)
        {
            using (DatabaseContext context = new DatabaseContext())
            {
                var item = (from c in context.ProductColours
                            where c.Guid == guid
                            select c).FirstOrDefault();

                if (item == null)
                {
                    return;
                }

                item.NameTranslations = JsonConvert.SerializeObject(request.NameTranslations);
                item.Value            = request.Value;
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public void Post(ProductColourInfo request)
        {
            if (request.ProductGuid == Guid.Empty)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            using (DatabaseContext context = new DatabaseContext())
            {
                ProductColour newColour = new ProductColour
                {
                    Guid             = Guid.NewGuid(),
                    NameTranslations = JsonConvert.SerializeObject(request.NameTranslations),
                    Value            = request.Value,
                    ProductGuid      = request.ProductGuid
                };

                context.ProductColours.Add(newColour);
                context.SaveChanges();
            }
        }