예제 #1
0
 public bool CreateUser(DB.User user)
 {
     Trace.Write("Start Create User");
     Trace.Write(string.Format("Data:{0}", JsonConvert.SerializeObject(user)));
     if (user == null || user.Id == Guid.Empty)
     {
         return(false);
     }
     try
     {
         using (var db = new DB.PazzoDatabaseEntities())
         {
             var oldData = db.User.Where(c => c.Id == user.Id).FirstOrDefault();
             if (oldData == null)
             {
                 db.User.Add(user);
             }
             db.SaveChanges();
             Trace.Write("End Create User");
             return(true);
         }
     }
     catch (Exception ex)
     {
         log.Error(ex);
         Trace.Write("End Create User");
         return(false);
     }
 }
예제 #2
0
 public bool DeleteUserById(Guid userId)
 {
     Trace.Write("Start Delete User");
     Trace.Write(string.Format("Data:{0}", userId));
     if (userId == Guid.Empty)
     {
         return(false);
     }
     try
     {
         using (var db = new DB.PazzoDatabaseEntities())
         {
             var oldData = db.User.Where(c => c.Id == userId).FirstOrDefault();
             if (oldData != null)
             {
                 db.User.Remove(oldData);
             }
             db.SaveChanges();
             Trace.Write("End Delete User");
             return(true);
         }
     }
     catch (Exception ex)
     {
         log.Error(ex);
         Trace.Write("End Delete User");
         return(false);
     }
 }
예제 #3
0
 public bool DeleteUsers()
 {
     Trace.Write("Start Delete Users");
     try
     {
         using (var db = new DB.PazzoDatabaseEntities())
         {
             var users = db.User.ToList();
             foreach (var user in users)
             {
                 db.User.Remove(user);
             }
             db.SaveChanges();
             Trace.Write("End Delete Users");
             return(true);
         }
     }
     catch (Exception ex)
     {
         log.Error(ex);
         Trace.Write("End Delete Users");
         return(false);
     }
 }