Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dao"></param>
        /// <param name="obj"></param>
        public static void CloneTo(this DAO.Contact dao, Contact obj)
        {
            #region Validate parameters
            if (dao == null)
            {
                throw new ArgumentNullException("dao");
            }

            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            #endregion

            //obj.AccessMode = dao.AccessMode;
            obj.Address    = dao.Address;
            obj.Comment    = dao.Comment;
            obj.Enabled    = (dao.Enabled == null ? false : dao.Enabled.Value);
            obj.IsMyself   = (dao.IsMyself == null ? false : dao.IsMyself.Value);
            obj.IsService  = (dao.IsService == null ? false : dao.IsService.Value);
            obj.LINK       = dao.LINK;
            obj.Name       = dao.Name;
            obj.Online     = dao.Online;
            obj.Opened     = (dao.Opened == null ? false : dao.Opened.Value);
            obj.Properties = dao.Properties.Select(cont => cont.ToObj()).ToArray();
            obj.Type       = dao.Type;
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static DAO.Contact ToDao(this Contact obj)
        {
            if (obj == null)
            {
                return(null);
            }

            var dao = new DAO.Contact();

            //dao.AccessMode = (String.IsNullOrEmpty(obj.AccessMode) ? null : obj.AccessMode);
            dao.Address    = obj.Address;
            dao.Comment    = (String.IsNullOrEmpty(obj.Comment) ? null : obj.Comment);
            dao.ContactID  = obj.ContactID;
            dao.Enabled    = (obj.Enabled == false ? new Nullable <bool>() : obj.Enabled);
            dao.IsMyself   = (obj.IsMyself == false ? new Nullable <bool>() : obj.IsMyself);
            dao.IsService  = (obj.IsService == false ? new Nullable <bool>() : obj.IsService);
            dao.LINK       = obj.LINK;
            dao.Name       = (String.IsNullOrEmpty(obj.Name) ? null : obj.Name);
            dao.Online     = obj.Online;
            dao.Opened     = (obj.Opened == false ? new Nullable <bool>() : obj.Opened);
            dao.Properties = obj.Properties.Select(prop => prop.ToDao(dao)).ToList();
            dao.Type       = obj.Type;

            return(dao);
        }
Beispiel #3
0
        /// <summary>
        /// Сохранить контакт.
        /// </summary>
        /// <param name="contact"></param>
        public void SaveContact(Contact contact)
        {
            #region Validate parameters
            if (contact == null)
            {
                throw new ArgumentNullException("contact");
            }
            #endregion

            DAO.Contact dao = contact.ToDao();

            using (UnitOfWork work = BeginWork())
            {
                if (contact.LINK == 0)
                {
                    work.Save(dao);
                }
                else
                {
                    work.Update <DAO.Contact>(ref dao);
                }

                work.End();
            }

            dao.CloneTo(contact);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dao"></param>
        /// <returns></returns>
        public static Contact ToObj(this DAO.Contact dao)
        {
            if (dao == null)
            {
                return(null);
            }

            var obj = new Contact();

            dao.CloneTo(obj);

            return(obj);
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contact"></param>
        public void DeleteContact(Contact contact)
        {
            #region Validate parameters
            if (contact == null)
            {
                throw new ArgumentNullException("contact");
            }
            #endregion

            DAO.Contact dao = contact.ToDao();

            using (UnitOfWork work = BeginWork())
            {
                work.Delete(dao);
                work.End();
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="contact"></param>
        /// <returns></returns>
        public static DAO.ContactProperty ToDao(this ContactProperty obj, DAO.Contact contact)
        {
            if (obj == null)
            {
                return(null);
            }

            var dao = new DAO.ContactProperty();

            dao.Comment = (String.IsNullOrEmpty(obj.Comment) ? null : obj.Comment);
            dao.Contact = contact;
            dao.Format  = (String.IsNullOrEmpty(obj.Format) ? null : obj.Format);
            dao.LINK    = obj.LINK;
            dao.Name    = obj.Name;
            dao.Type    = (String.IsNullOrEmpty(obj.Type) ? null : obj.Type);
            dao.Value   = obj.Value;

            return(dao);
        }