示例#1
0
 public RecipeService()
 {
     rp  = new RecipeRepo();
     irp = new IngredientRepo();
     mrp = new MemberRepo();
     orp = new OthersRepo();
 }
示例#2
0
        public RecipeCreateSelectViewModel GetAll()
        {
            var ingRepo = new IngredientRepo();
            var othRepo = new OthersRepo();

            return(new RecipeCreateSelectViewModel(ingRepo.GetAll(), othRepo.GetAllMeasurements(), othRepo.GetAllBeerTypes()));
        }
示例#3
0
        public ActionResult CreateRecipe(int?recipeID)
        {
            CreateRecipeVM recipeVM = new CreateRecipeVM();

            if (recipeID != null && recipeID != 0)
            {
                var r = rr.GetRecipeByID((int)recipeID);
                recipeVM.RecipeName        = r.RecipeName;
                recipeVM.PrepTime          = r.PrepTime;
                recipeVM.CookTime          = r.CookTime;
                recipeVM.TotalTime         = r.TotalTime;
                recipeVM.RecipeCategoryID  = r.RecipeCategoryID;
                recipeVM.RecipeIngredients = r.RecipeIngredients.ToList();
                recipeVM.RecipeSteps       = r.RecipeSteps.ToList();
            }

            IngredientRepo ingredientRepo       = new IngredientRepo();
            var            ingredientCategories = ingredientRepo.GetIngredientCategories();
            var            listRecipeCategories = rr.GetAllRecipeCategoriesSelect();
            var            listMeasueTypes      = rr.GetAllMeasurmentTypes();

            recipeVM.RecipeCategories     = listRecipeCategories;
            recipeVM.MeasurmentTypes      = listMeasueTypes;
            recipeVM.IngredientCategories = ingredientCategories;
            return(View(recipeVM));
        }
示例#4
0
        public ActionResult ViewIngredients(int category)
        {
            IngredientsVM  ic = new IngredientsVM();
            IngredientRepo ri = new IngredientRepo();

            ic.IngredientCategories = ri.GetIngredientCategories();
            ic.Ingrdients           = ri.GetIngredientsByCategory(category);
            return(View(ic));
        }
示例#5
0
        public ActionResult CreateIngredient()
        {
            CreateIngredientVM ci             = new CreateIngredientVM();
            IngredientRepo     ingredientRepo = new IngredientRepo();
            var listOfCategories = ingredientRepo.GetAllIngredientCategories();

            ci.IngredientCategories = listOfCategories;
            return(View(ci));
        }
示例#6
0
        public int GetByName(string ingredient)
        {
            var ingRepo = new IngredientRepo();
            var ing     = ingRepo.GetByName(ingredient);

            if (ing == null)
            {
                return(-1);
            }
            return(ing.IngredientId);
        }
示例#7
0
        public int CheckAndCreateIngredient(string IngredientName)
        {
            var ingRep  = new IngredientRepo();
            var drivenI = ingRep.GetByName(IngredientName);

            if (drivenI == null)
            {
                return(ingRep.CreateByName(IngredientName));
            }
            return(drivenI.IngredientId);
        }
示例#8
0
        public ActionResult GetIngredientsByCategory(int category)
        {
            IngredientsVM  i  = new IngredientsVM();
            IngredientRepo ir = new IngredientRepo();

            var ingredients = ir.GetIngredientsByCategory(category);

            i.Ingrdients = ingredients;

            return(PartialView("IngredientList", i));
        }
示例#9
0
 private void SetRepo()
 {
     _ingredientRepo  = new IngredientRepo(_context);
     _tableRepo       = new TableRepo(_context);
     _reservationRepo = new ReservationRepo(_context);
     _categoryRepo    = new CategoryRepo(_context);
     _salesRepo       = new SaleRepo(_context);
     _occupancyRepo   = new OccupanciesRepo(_context);
     _recipeRepo      = new RecipeRepo(_context);
     _productRepo     = new ProductRepo(_context);
     _supplierRepo    = new SupplierRepo(_context);
     _subCategoryRepo = new SubCategoryRepo(_context);
     _logRepo         = new LogRepo(_context);
 }
示例#10
0
 public ActionResult ViewIngredient(int IngredientID)
 {
     try
     {
         CreateIngredientVM vm = new CreateIngredientVM();
         IngredientRepo     ri = new IngredientRepo();
         var ingredient        = ri.GetIngredientByID(IngredientID);
         vm.IngredientName     = ingredient.IngredientName;
         vm.IngredientCategory = ingredient.IngredientCategory.IngredientCategory1;
         return(View(vm));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#11
0
 public ActionResult CreateIngredient(CreateIngredientVM model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     try
     {
         IngredientRepo ri = new IngredientRepo();
         Ingredient     i  = new Ingredient();
         i.IngredientName       = model.IngredientName;
         i.IngredientCategoryID = model.IngredientCategoryID;
         i = ri.InsertIngredient(i);
         ModelState.Clear();
         return(RedirectToAction("ViewIngredient", new { i.IngredientID }));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#12
0
 public void TestInit()
 {
     repo = new IngredientRepo();
 }
示例#13
0
        public IngredientViewModel GetRecipeIngredientById(int recipeId, int ingredientId)
        {
            var ingRepo = new IngredientRepo();

            return(ingRepo.GetRecipeIngredientById(recipeId, ingredientId));
        }
示例#14
0
 public Controller()
 {
     recepiesRepo   = new RecepiesRepo();
     ingredientRepo = new IngredientRepo();
     opskriftRepo   = new OpskriftRepo(ingredientRepo);
 }
示例#15
0
 public MemberService()
 {
     mrp = new MemberRepo();
     irp = new IngredientRepo();
 }
示例#16
0
 private Controller()
 {
     ingredientRepo = new IngredientRepo();
     bookRepo       = new CookbookRepo();
 }