コード例 #1
0
        public static void AddClient(string name, string email)
        {
            var c = new Client {
                Name = name, Email = email
            };

            using (var context = new MyBase())
            {
                context.Client.Add(c);
                context.SaveChanges();
            }
            string message = "Add Client. name: " + name + "; email: " + email;

            Log.Info(message);
        }
コード例 #2
0
        public static void DeleteClient(int id)
        {
            string name, email;

            using (var context = new MyBase())
            {
                var c = context.Client.SingleOrDefault(x => x.Id == id);
                name  = c.Name;
                email = c.Email;
                context.Client.Remove(c);
                context.SaveChanges();
            }
            string message = "Delete Client. name: " + name + "; email: " + email;

            Log.Info(message);
        }
コード例 #3
0
        public static void UpdateClient(int id, string name, string email)
        {
            string oldName, oldEmail;

            using (var context = new MyBase())
            {
                var c = context.Client.SingleOrDefault(x => x.Id == id);
                oldName  = c.Name;
                oldEmail = c.Email;
                c.Name   = name;
                c.Email  = email;
                context.SaveChanges();
            }
            string message = "Update Client. name " + oldName + " -> " + name + "; email: " + oldEmail + " -> " + email;

            Log.Info(message);
        }