protected void SaveBtn_Click(object sender, EventArgs e)
        {
            FeedbackModelContainer model = new FeedbackModelContainer();
            Guid id   = (Guid)Session["UserID"];
            User user =
                (from п in model.UserSet
                 where п.Id == id
                 select п).First();

            user.LastName = LastNameTxt.Text.Trim();
            user.Name     = NameTxt.Text.Trim();
            user.SureName = SurenameTxt.Text.Trim();
            model.SaveChanges();
            Page.Response.Redirect("/");
        }
 protected void FeedbackGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         FeedbackModelContainer model = new FeedbackModelContainer();
         Guid     DeleteId            = new Guid((string)e.CommandArgument);
         Guid     id       = (Guid)Session["UserID"];
         Feedback feedback = (from u in model.FeedbackSet
                              where u.Id == DeleteId
                              select u).First();
         model.FeedbackSet.Remove(feedback);
         model.SaveChanges();
         Response.Redirect("/EditUser.aspx?Id=" + id.ToString());
     }
 }
Exemple #3
0
        protected void AddBtn_Click(object sender, EventArgs e)
        {
            FeedbackModelContainer model = new FeedbackModelContainer();
            User user = new User();

            user.Id       = Guid.NewGuid();
            user.LastName = LastNameTxt.Text.Trim();
            user.Name     = NameTxt.Text.Trim();
            user.SureName = SurenameTxt.Text.Trim();
            user.Phone    = PhoneTxt.Text.Trim();

            model.UserSet.Add(user);
            model.SaveChanges();

            Page.Response.Redirect("/");
        }
        protected void ConfirmBtn_Click(object sender, EventArgs e)
        {
            FeedbackModelContainer model = new FeedbackModelContainer();
            Guid id   = (Guid)Session["UserID"];
            User user = (from u in model.UserSet
                         where u.Id == id
                         select u).First();
            IQueryable <Feedback> feedbacks =
                from f in model.FeedbackSet
                where f.User.Id == id
                select f;

            foreach (Feedback feedback in feedbacks)
            {
                model.FeedbackSet.Remove(feedback);
            }
            model.UserSet.Remove(user);
            model.SaveChanges();
            Response.Redirect("/");
        }
        protected void AddFeedbackBtn_Click(object sender, EventArgs e)
        {
            FeedbackModelContainer model = new FeedbackModelContainer();
            Guid id   = (Guid)Session["UserID"];
            User user = (from u in model.UserSet
                         where u.Id == id
                         select u).First();
            Feedback feedback = new Feedback
            {
                Id        = Guid.NewGuid(),
                ShortDesc = ShortDescTxt.Text.Trim(),
                LongDesc  = LongDescTxt.Text.Trim(),
                Date      = DateTime.Now.ToString("g"),
                Positive  = Negative.Checked
            };

            user.Feedback.Add(feedback);

            model.SaveChanges();
            Response.Redirect("/EditUser.aspx?Id=" + id.ToString());
        }