Ejemplo n.º 1
0
 public void Insert(Member member)
 {
     using (SqlConnection connection = new SqlConnection(GetConnection()))
     {
         connection.Execute(
             @"INSERT INTO Member (FirstName,Surname,MemberNumber,DateCreated) VALUES(@FirstName,@Surname,@MemberNumber,@DateCreated)",
             new { member.FirstName, member.Surname, member.MemberNumber, member.DateCreated });
     };
 }
Ejemplo n.º 2
0
        public void Update(Member member)
        {
            using (SqlConnection connection = new SqlConnection(GetConnection()))
            {
                connection.Execute(
                    @"Update Member SET [FirstName] = @FirstName,[Surname] = @Surname WHERE Member.Id = @Id",
                    new { @FirstName = member.FirstName, @Surname = member.Surname, @Id = member.Id });

            };

            //            public void Update(Movie movie)
            //{
            //  var sql = "UPDATE myDB.movies set title=@param1, genre=@param2 where ID=@param3";
            //  db.Execute(sql, new { param1 = movie.Title, param2 = movie.Genre, param3 = movie.ID });
            //}
        }
Ejemplo n.º 3
0
        public ActionResult Create(Member member)
        {
            try
            {
                Repository repo = new Repository();
                if (ModelState.IsValid)
                {
                    repo.Insert(member);
                }

                return RedirectToAction("Index");
            }
            catch(Exception ex)
            {
                return View();
            }
        }
Ejemplo n.º 4
0
        public ActionResult Edit(int id, Member member)
        {
            try
            {
             Repository repo = new Repository();
             repo.Update(member);

                return RedirectToAction("Index");
            }
            catch(Exception ex)
            {
                return View();
            }
        }