Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _service   = new Recipes_Services();
            _riService = new RecipesIngredients_Services();
            _frService = new FavouriteRecipe_Services();
            _uService  = new Users_Services();



            if (!String.IsNullOrEmpty(Session["ID"].ToString()))
            {
                id = int.Parse(Session["ID"].ToString());
            }
            foreach (Recipe recipe in _service.GetByID(id))
            {
                lblTitle.Text        = recipe.Title;
                lblCategoryName.Text = recipe.CategoryName.ToString();
                lblDuration.Text     = TimeSpan.Parse(recipe.Duration.ToString()).TotalMinutes.ToString() + " Minutos";
                lblDifficulty.Text   = recipe.Difficulty.ToString();
                lblRating.Text       = recipe.Rating.ToString();
                lblUser.Text         = recipe.UserName.ToString();
                lblInstructions.Text = recipe.Instructions.ToString();
                {
                }
                CreateDataTable();
                foreach (RecipeIngredient recipeIngredient in _riService.GetById(id))
                {
                    //dt = (DataTable)ViewState["Records"];
                    DataRow row = dt.NewRow();
                    row["Ingrediente"] = recipeIngredient.IngredientName;
                    row["Quantidade"]  = recipeIngredient.Quantity;
                    row["Unidade"]     = recipeIngredient.Unit;
                    dt.Rows.Add(row);
                    gvIngredientsInsert.DataSource = dt;
                    gvIngredientsInsert.DataBind();
                }
            }
            _membershipUsername = User.Identity.Name;
            foreach (User user in _uService.GetALL())
            {
                if (_membershipUsername == user.MembershipUsername)
                {
                    userId = user.ID;
                }
            }
            foreach (FavouriteRecipe favouriteRecipe in _frService.GetALL(userId))
            {
                if (favouriteRecipe.RecipeID == id)
                {
                    if (favouriteRecipe.IsFavourite == true)
                    {
                        btnFavoritos.Visible = false;
                    }
                    else
                    {
                        btnFavoritos.Visible = true;
                    }
                }
            }
        }
Пример #2
0
 public FrmRecipesInsert(bool isInsert, int id = 0)
 {
     InitializeComponent();
     _rService  = new Recipes_Services();
     _cService  = new Categories_Services();
     _iService  = new Ingredients_Services();
     _riService = new RecipesIngredients_Services();
 }
Пример #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _rService  = new Recipes_Services();
     _cService  = new Categories_Services();
     _iService  = new Ingredients_Services();
     _riService = new RecipesIngredients_Services();
     _uService  = new Users_Services();
     FillComboBoxes();
     CreateDataTable();
 }