示例#1
0
 public bool MakeGlobal(int recipeId)
 {
     using (var ctx = new BrewAreaEntities())
     {
         var recipe = ctx.Recipes.Where(t => t.RecipeId == recipeId).SingleOrDefault();
         if (recipe != null)
         {
             recipe.IsGlobal = true;
             ctx.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
示例#2
0
 public int Create(Recipe newRecipe)
 {
     using (var ctx = new BrewAreaEntities())
     {
         try
         {
             var newRec = ctx.Recipes.Add(newRecipe);
             ctx.SaveChanges();
             return(newRec.RecipeId);
         }
         catch (Exception e)
         {
             return(-1);
         }
     }
 }
示例#3
0
 public bool Create(Member member)
 {
     using (var ctx = new BrewAreaEntities())
     {
         try
         {
             ctx.Members.Add(member);
             ctx.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
示例#4
0
 public bool Create(Ingredient newIngredient)
 {
     using (var ctx = new BrewAreaEntities())
     {
         try
         {
             ctx.Ingredients.Add(newIngredient);
             ctx.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
示例#5
0
 public bool Delete(int id)
 {
     using (var ctx = new BrewAreaEntities())
     {
         try
         {
             var dbItem = ctx.Recipes.Where(t => t.RecipeId == id).SingleOrDefault();
             dbItem.IsActive = false;
             ctx.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
示例#6
0
 public bool EditIngredientToMember(int memberId, int ingredientIdOld, int ingredientId, int measurementTypeId, double amount)
 {
     using (var ctx = new BrewAreaEntities())
     {
         try
         {
             DeleteIngredientFromMember(memberId, ingredientIdOld);
             AddIngredientToMember(memberId, ingredientId, measurementTypeId, amount);
             ctx.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
示例#7
0
 public int CreateByName(string IngredientName)
 {
     using (var ctx = new BrewAreaEntities())
     {
         try
         {
             var x = ctx.Ingredients.Add(new Ingredient {
                 Name = IngredientName
             });
             ctx.SaveChanges();
             return(x.IngredientId);
         }
         catch (Exception e)
         {
             return(-1);
         }
     }
 }
示例#8
0
 public int AddMeasurement(string MeasurementType)
 {
     using (var ctx = new BrewAreaEntities())
     {
         try
         {
             var x = ctx.MeasurementTypes.Add(new MeasurementType
             {
                 MeasurementType1 = MeasurementType
             });
             ctx.SaveChanges();
             return(x.MeasurementTypeId);
         }
         catch (Exception e)
         {
             return(-1);
         }
     }
 }
示例#9
0
 public int AddBeerType(string BeerType)
 {
     using (var ctx = new BrewAreaEntities())
     {
         try
         {
             var x = ctx.BeerTypes.Add(new BeerType
             {
                 BeerType1 = BeerType
             });
             ctx.SaveChanges();
             return(x.BeerTypeId);
         }
         catch (Exception e)
         {
             return(-1);
         }
     }
 }
示例#10
0
 public bool Edit(Recipe recipe)
 {
     using (var ctx = new BrewAreaEntities())
     {
         try
         {
             var driven = ctx.Recipes.Where(t => t.RecipeId == recipe.RecipeId).SingleOrDefault();
             driven.Name        = recipe.Name;
             driven.Making      = recipe.Making;
             driven.Description = recipe.Description;
             driven.BeerTypeId  = recipe.BeerTypeId;
             ctx.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
示例#11
0
 public bool DeleteIngredientFromMember(int memberId, int ingredientId)
 {
     using (var ctx = new BrewAreaEntities())
     {
         try
         {
             var toDelete = ctx.IngredientMemberRelations.Where(t => t.IngredientId == ingredientId && t.MemberId == memberId).SingleOrDefault();
             if (toDelete != null)
             {
                 ctx.IngredientMemberRelations.Remove(toDelete);
                 ctx.SaveChanges();
             }
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
示例#12
0
 public bool AddIngredientToMember(int memberId, int ingredientId, int measurementTypeId, double amount)
 {
     using (var ctx = new BrewAreaEntities())
     {
         try
         {
             ctx.IngredientMemberRelations.Add(new IngredientMemberRelation
             {
                 MemberId          = memberId,
                 IngredientId      = ingredientId,
                 MeasurementTypeId = measurementTypeId,
                 Amount            = amount
             });
             ctx.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }