Ejemplo n.º 1
0
        public bool CreateUserProfile(UserProfileDAO s)
        {
            UserProfile userProfile = new UserProfile
            {
                UserId = s.UserId,
                UserName = s.UserName
            };

            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                db.UserProfiles.InsertOnSubmit(userProfile);

                try
                {
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
                }
            }

            return true;
        }
Ejemplo n.º 2
0
        public IList<UserProfileDAO> GetUserProfiles()
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    IList<UserProfile> userProfiles = (from userProfile in db.UserProfiles select userProfile).OrderBy(o => o.UserId).ToList();
                    List<UserProfileDAO> result = new List<UserProfileDAO>();

                    foreach (var userProfile in userProfiles)
                    {
                        UserProfileDAO temp = new UserProfileDAO
                        {
                            ID = userProfile.UserId,
                            UserId = userProfile.UserId,
                            UserName = userProfile.UserName
                        };

                        result.Add(temp);
                    }

                    return (result != null ? result : null);
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }
Ejemplo n.º 3
0
        public bool UpdateUserProfile(UserProfileDAO newUserProfile)
        {
            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                UserProfile userProfile = db.UserProfiles.Single(s => s.UserId == newUserProfile.UserId);
                userProfile.UserId = newUserProfile.UserId;
                userProfile.UserName = newUserProfile.UserName;

                try
                {
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
                }
            }

            return true;
        }
Ejemplo n.º 4
0
 public UserProfileDAO GetUserProfileByID(int id)
 {
     try
     {
         using (AESDatabaseDataContext db = new AESDatabaseDataContext())
         {
             UserProfile userProfile = (from uspro in db.UserProfiles where uspro.UserId == id select uspro).FirstOrDefault();
             UserProfileDAO result = new UserProfileDAO
             {
                 ID = userProfile.UserId,
                 UserId = userProfile.UserId,
                 UserName = userProfile.UserName
             };
             return (result != null ? result : null);
         }
     }
     catch (Exception e)
     {
         throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
     }
 }