예제 #1
0
        public void UpdateItemCat(ModelLibrary.ItemCat beforeItemCat, ModelLibrary.ItemCat afterItemCat)
        {
            JustFeastDbDataContext db = new JustFeastDbDataContext();
            ItemCtrl itemCtrl         = new ItemCtrl();

            itemCtrl.UpdateItemCat(beforeItemCat, afterItemCat);
        }
        private bool ValidateCat(ModelLibrary.ItemCat itemCat)
        {
            var context = new ValidationContext(itemCat, null, null);
            var result  = new List <System.ComponentModel.DataAnnotations.ValidationResult>();

            return(Validator.TryValidateObject(itemCat, context, result, true));
        }
예제 #3
0
        public ModelLibrary.ItemCat ConvertItemCatToModel(DatabaseAccessLibrary.ItemCat dbItemCat)
        {
            var modelItemCat = new ModelLibrary.ItemCat();
            List <ModelLibrary.Item> itemList = new List <ModelLibrary.Item>();
            ItemCtrl itemCtrl = new ItemCtrl();

            if (dbItemCat == null)
            {
                return(modelItemCat);
            }

            foreach (var Item in dbItemCat.Items)
            {
                itemList.Add(itemCtrl.ConvertItemToModel(Item));
            }
            if (itemList.Count > 0)
            {
                modelItemCat.Name  = dbItemCat.name;
                modelItemCat.Id    = dbItemCat.id;
                modelItemCat.Items = itemList;

                return(modelItemCat);
            }
            modelItemCat.Name = dbItemCat.name;
            modelItemCat.Id   = dbItemCat.id;

            return(modelItemCat);
        }
예제 #4
0
        public void UpdateItemCat(ModelLibrary.ItemCat beforeItemCat, ModelLibrary.ItemCat afterItemCat)
        {
            var itemCatDb = new ItemCatDb();

            var beforeDbItemCat = ConvertItemCatToDb(beforeItemCat);
            var afterDbItemCat  = ConvertItemCatToDb(afterItemCat);

            itemCatDb.UpdateItemCat(beforeDbItemCat, afterDbItemCat);
        }
예제 #5
0
        public DatabaseAccessLibrary.ItemCat ConvertItemCatToDb(ModelLibrary.ItemCat modelItemCat)
        {
            if (modelItemCat == null)
            {
                return(null);
            }
            var itemCat = new DatabaseAccessLibrary.ItemCat
            {
                id   = modelItemCat.Id,
                name = modelItemCat.Name,
            };

            return(itemCat);
        }
예제 #6
0
        public ModelLibrary.ItemCat CreateItemCat(ModelLibrary.ItemCat itemCat)
        {
            var itemCatDb = new ItemCatDb();

            var returnItemCat = new ModelLibrary.ItemCat
            {
                Name = itemCat.Name,
            };
            var dbItemCat = new DatabaseAccessLibrary.ItemCat
            {
                name = itemCat.Name
            };

            itemCatDb.AddItemCat(dbItemCat);

            return(returnItemCat);
        }
예제 #7
0
        public void Create_Item_Service()
        {
            ItemCtrl itemCtrl = new ItemCtrl();
            //Setup
            var menu = new ModelLibrary.Menu
            {
                Active       = false,
                Id           = 1000000,
                Name         = "newName",
                RestaurantId = 1000000,
            };
            var itemCat = new ModelLibrary.ItemCat
            {
                Id   = 1000000,
                Name = "Soup"
            };
            var price = new ModelLibrary.Price
            {
                StartDate = DateTime.Now.Date,
                EndDate   = new DateTime(9999, 12, 31),
                VarPrice  = 12.5
            };
            var item = new ModelLibrary.Item
            {
                Id          = 1000000,
                Name        = "Controllerforabi",
                Description = "Totallynotadescription",
                Price       = price,
            };

            //Act
            var itemdb = itemCtrl.CreateItem(item, menu.Id, itemCat.Id);

            //Assert
            Assert.AreEqual(item.Name, itemdb.Name);
        }
예제 #8
0
 public void CreateItemCat(ModelLibrary.ItemCat itemCat)
 {
     itemCtrl.CreateItemCat(itemCat);
 }