Example #1
0
        public void AddPropertyToItem(int itemId, int propertyId, string propertyInfo)
        {
            using (var dbContextScope = _dbContextScopeFactory.Create())
            {
                var itemObject     = _ItemRepository.GetItem(itemId);
                var propertyObject = _IPropertyControl.GetProperty(propertyId);

                if (itemObject == null)
                {
                    throw new ArgumentException($"Preke su tokiu Id nebuvo rasta");
                }

                if (propertyObject == null)
                {
                    throw new ArgumentException($"Preke su tokia savybe nebuvo rasta");
                }

                var itemProperty = new ItemProperty
                {
                    ItemId     = itemId,
                    PropertyId = propertyId,
                    Value      = propertyInfo
                };

                itemObject.ItemProperties.Add(itemProperty);
                dbContextScope.SaveChanges();
            }
        }
        // GET: Admin/ModifyProperty
        public ActionResult ModifyProperty(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            try
            {
                Property category = _propertyControl.GetProperty(id.Value);
                return(View(category));
            }
            catch (ArgumentException)
            {
                return(HttpNotFound());
            }
        }