예제 #1
0
 /// <summary> Create a new recipe table object </summary>
 public RecipeTable()
 {
     RecipeId     = new RecipeId(new NotNull(), new Unique(), new PrimaryKey(true));
     RecipeName   = new RecipeName(new NotNull(), new Unique());
     ProfessionId = new ProfessionId(new NotNull(), new ForeignKey(TableManager.Profession, TableManager.Profession.ProfessionId));
     Grade        = new Grade(new NotNull());
 }
예제 #2
0
 /// <summary> Create a recipe result table object </summary>
 public RecipeResultTable()
 {
     RecipeId   = new RecipeId(new NotNull(), new ForeignKey(TableManager.Recipe, TableManager.Recipe.RecipeId));
     Tier       = new Tier(new NotNull());
     ResourceId = new ResourceId(new NotNull(), new ForeignKey(TableManager.Resource, TableManager.Resource.ResourceId));
     Amount     = new Amount(new NotNull(), new Default <int>(1));
 }
예제 #3
0
        public async Task GetRecipeTest()
        {
            var recipeId = new RecipeId(ArtisanId.Blacksmith, "apprentice-flamberge");
            var recipe   = await DiabloApi.Artisan.GetRecipeAsync(AuthenticationScope, recipeId);

            Assert.IsNotNull(recipe);
        }
예제 #4
0
        //public object id { get; internal set; }

        public string GetFileName()
        {
            string[] files = Directory.GetFiles(Base);
            foreach (string s in files)
            {
                if (Path.GetFileNameWithoutExtension(s) == RecipeId.ToString())
                {
                    return(Path.GetFileName(s));
                }
            }
            return(null);
        }
예제 #5
0
        public void DeleteFav(RecipeId recipeId)
        {
            using (var con = GetConnection())
            {
                var cmd = con.CreateCommand();
                cmd.CommandText = "Delete_Favorite";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@recipeId", recipeId.recipeId);

                cmd.ExecuteNonQuery();
            }
        }
예제 #6
0
        /// <summary> Get the id of a recipe </summary>
        /// <param name="recipe">The name of the recipe to get the id for</param>
        /// <returns>The id of the recipe</returns>
        public long GetRecipeID(string recipe)
        {
            DataTable result = GetDataRows((RecipeName, recipe));

            if (result.Rows.Count == 0)
            {
                throw new ArgumentException("The recipe does not exist in the database");
            }
            else if (result.Rows.Count > 1)
            {
                throw new ArgumentException("There are multiple entries of the recipe in the database");
            }
            return(RecipeId.Parse(result.Rows[0]));
        }
예제 #7
0
        /// <summary> Load all recipe costs from the database </summary>
        public override void LoadData()
        {
            DataTable table = GetAllData();

            foreach (DataRow row in table.Rows)
            {
                long     recipeId   = RecipeId.Parse(row);
                long     resourceId = ResourceId.Parse(row);
                int      amount     = Amount.Parse(row);
                Recipe   recipe     = TableManager.Recipe.GetRecipe(recipeId);
                Resource resource   = TableManager.Resource.GetResource(resourceId);
                recipe.AddConsumed(resource, amount);
            }
        }
예제 #8
0
 public void Favorite(RecipeId recipeId)
 {
     using (var con = GetConnection())
     {
         var cmd = con.CreateCommand();
         cmd.CommandText = "Add_Favorite";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@recipeId", recipeId.recipeId);
         try
         {
             cmd.ExecuteNonQuery();
         }
         catch (SqlException e) when(e.Message.Contains("duplicate"))
         {
         }
     }
 }
예제 #9
0
        public async Task <Recipe> GetRecipeAsync(IAuthenticationScope authenticationScope, RecipeId recipeId)
        {
            var mapper      = new RecipeMapper(recipeId.Id);
            var artisanSlug = EnumConversionHelper.ArtisanIdentifierToString(recipeId.Id);

            using (var client = CreateClient(authenticationScope))
            {
                var recipe = await client.GetRecipeAsync(artisanSlug, recipeId.Slug);

                return(mapper.Map(recipe));
            }
        }
예제 #10
0
 public void DeleteFav(RecipeId recipeId)
 {
     //Need to add HttpResponseMessage
     recipeService.DeleteFav(recipeId);
 }
예제 #11
0
 public void Favorite(RecipeId recipeId)
 {
     //Need to add HttpResponseMessage
     recipeService.Favorite(recipeId);
 }
 public Recipe FindById(RecipeId recipeId)
 {
     return(_context
            .Recipes
            .FirstOrDefault(x => x.RecipeId == recipeId));
 }