コード例 #1
0
        /// <summary>
        /// Delete a client from the database
        /// </summary>
        /// <param name="clientId">The client's Id to delete</param>
        /// <returns>the deleted client</returns>
        public Client Delete(int clientId)
        {
            var client = m_context.Clients.Find(clientId);

            if (client != null)
            {
                // Remove the found client from the context.
                m_context.Clients.Remove(client);
                m_context.SaveChanges();
            }

            return(client);
        }
コード例 #2
0
        /// <summary>
        /// Save a meeting
        /// </summary>
        /// <param name="meetingToSave">The meeting to save</param>
        /// <returns>true if saved false if not</returns>
        public bool Save(Meeting meetingToSave)
        {
            var retVal = true;

            // Doesn't already exist - Insert
            if (meetingToSave.MeetingId == 0)
            {
                m_context.Meetings.Add(meetingToSave);
            }
            else
            {
                // Already exists - update
                var meetingEntry = m_context.Meetings.Find(meetingToSave.MeetingId);
                if (meetingEntry != null)
                {
                    meetingEntry.MeetingDate = meetingToSave.MeetingDate;
                    meetingEntry.ClientId    = meetingToSave.ClientId;
                }
                else
                {
                    retVal = false;
                }
            }

            m_context.SaveChanges();
            return(retVal);
        }