Exemple #1
0
        /// <summary>
        /// 建立 SubCategoryUser 個體。
        /// </summary>
        /// <param name="catSub">CatSub 個體</param>
        /// <param name="userMap">User 快查表。</param>
        /// <returns>子站維護人員資訊</returns>
        private CategoryContactModel CreateCategoryContact(CatSub catSub, Dictionary<string, PriUser> userMap)
        {
            var categoryContact = new CategoryContactModel
            {
                Id = catSub.Id,
            };

            categoryContact.Pm = userMap.GetOrDefault(catSub.User.UsrName);

            categoryContact.Manager = userMap.GetOrDefault(catSub.MdyPm);

            categoryContact.Purchaser = userMap.GetOrDefault(catSub.MdyPurher);

            categoryContact.Staff = userMap.GetOrDefault(catSub.MdyStaff);

            return categoryContact;
        }
        /// <summary>
        /// Creates the contact.
        /// </summary>
        /// <param name="model">The sub category user.</param>
        /// <returns>The sub category contact.</returns>
        private CategoryContact CreateContact(CategoryContactModel model)
        {
            var contact = new CategoryContact
            {
                CategoryId = model.Id
            };

            if (model.Pm != null)
            {
                contact.PmBackyardId = model.Pm.BackyardId;
                contact.PmFullName = model.Pm.FullName;
                contact.PmExtNumber = model.Pm.ExtNo;
                contact.PmEmail = model.Pm.Email;
            }

            if (model.Manager != null)
            {
                contact.MgrBackyardId = model.Manager.BackyardId;
                contact.MgrFullName = model.Manager.FullName;
                contact.MgrExtNumber = model.Manager.ExtNo;
                contact.MgrEmail = model.Manager.Email;
            }

            if (model.Purchaser != null)
            {
                contact.PhrBackyardId = model.Purchaser.BackyardId;
                contact.PhrFullName = model.Purchaser.FullName;
                contact.PhrExtNumber = model.Purchaser.ExtNo;
                contact.PhrEmail = model.Purchaser.Email;
            }

            if (model.Staff != null)
            {
                contact.StaffBackyardId = model.Staff.BackyardId;
                contact.StaffFullName = model.Staff.FullName;
                contact.StaffExtNumber = model.Staff.ExtNo;
                contact.StaffEmail = model.Staff.Email;
            }

            return contact;
        }