예제 #1
0
        /// <summary>
        /// Gets the responsible.
        /// </summary>
        /// <param name="siteId">The site id.</param>
        /// <param name="contactRoleId">The contact role id.</param>
        /// <param name="contactId">The contact id.</param>
        /// <param name="workflowId">The workflow id.</param>
        /// <returns></returns>
        public tbl_Contact GetResponsible(Guid siteId, Guid contactRoleId, Guid contactId, Guid?workflowId = null)
        {
            var         dataManager        = new DataManager();
            tbl_Contact responsibleContact = null;

            var responsible = dataManager.Responsible.Select(contactRoleId, contactId, workflowId);

            if (responsible == null)
            {
                responsibleContact = dataManager.Responsible.GetResponsible(siteId, contactRoleId);
                if (responsibleContact != null)
                {
                    responsible = new tbl_Responsible {
                        ContactRoleID = contactRoleId, ContactID = contactId, ResponsibleID = responsibleContact.ID
                    };
                    if (workflowId != null)
                    {
                        responsible.WorkflowID = workflowId;
                    }
                    dataManager.Responsible.Add(responsible);
                }
            }
            else
            {
                responsibleContact = dataManager.Contact.SelectById(siteId, responsible.ResponsibleID);
            }

            return(responsibleContact);
        }
예제 #2
0
        /// <summary>
        /// Adds the specified responsible.
        /// </summary>
        /// <param name="responsible">The responsible.</param>
        /// <returns></returns>
        public tbl_Responsible Add(tbl_Responsible responsible)
        {
            if (responsible.ID == Guid.Empty)
            {
                responsible.ID = Guid.NewGuid();
            }
            _dataContext.tbl_Responsible.AddObject(responsible);
            _dataContext.SaveChanges();

            return(responsible);
        }