Пример #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
        private void FillGrid()
        {
            DataTable dt = ConvertListToDataTable.ConvertTo <User>(_service.GetALL());

            gvResultUsers.DataSource = dt;
            VisualAspectGrid();
        }
Пример #3
0
 protected void Favourite_Click(object sender, EventArgs e)
 {
     _membershipUsername = User.Identity.Name;
     foreach (User user in _uService.GetALL())
     {
         if (_membershipUsername == user.MembershipUsername)
         {
             userId = user.ID;
         }
     }
     favouriteRecipe.UserID      = userId;
     favouriteRecipe.RecipeID    = id;
     favouriteRecipe.IsFavourite = true;
     _frService.Add(favouriteRecipe);
     Response.Redirect("~/receitas/receitasfavoritas.aspx");
 }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _service  = new Recipes_Services();
            _uService = new Users_Services();

            _membershipUsername = User.Identity.Name;
            foreach (User user in _uService.GetALL())
            {
                if (_membershipUsername == user.MembershipUsername)
                {
                    userId = user.ID;
                }
            }
            this.rptRecipe.DataSource = _service.GetRecipeByUserID(userId);
            this.rptRecipe.DataBind();
        }
Пример #5
0
        protected void btnInsertRecibe_Click(object sender, EventArgs e)
        {
            double minutes = double.Parse(tbDuration.Text);

            _membershipUsername = User.Identity.Name;
            foreach (User user in _uService.GetALL())
            {
                if (_membershipUsername == user.MembershipUsername)
                {
                    userId = user.ID;
                }
            }

            recipe.Title        = tbName.Text;
            recipe.CategoryID   = int.Parse(cbCategory.SelectedValue);
            recipe.Difficulty   = (Difficulty)cbDifficulty.SelectedIndex;
            recipe.Duration     = TimeSpan.FromMinutes(minutes);
            recipe.Instructions = tbInstructions.Text;
            recipe.User         = userId;

            _rService.Add(recipe);

            int id = recipe.ID;

            dt = (DataTable)ViewState["Records"];
            foreach (DataRow row in dt.Rows)
            {
                RecipeIngredient recipeIngredient = new RecipeIngredient();
                recipeIngredient.RecipeID     = id;
                recipeIngredient.IngredientID = Convert.ToInt32(row["ID"].ToString());
                recipeIngredient.Quantity     = Convert.ToDecimal(row["Quantidade"].ToString());
                recipeIngredient.Unit         = row["Unidade"].ToString();
                _riService.Add(recipeIngredient);
            }
            Response.Redirect("~/asminhasreceitas.aspx");
        }