private void Save()
        {
            Messages.Clear();
            contactDBContext dc = new contactDBContext();

            try
            {
                //============================================
                //http://patrickdesjardins.com/blog/entity-framework-ef-modifying-an-instance-that-is-already-in-the-context
                // you have to detach the local version and set to modify the entity you are modifying
                //we first verify if the entity is present inside the DbSet. If it is NOT null, than we detach the local entity.
                //This scenario is pretty common if you receive the object from a web request and you want to save the entity.

                var local = dc.Set <T003TelephoneContact>()
                            .Local
                            .FirstOrDefault(s => s.T003Pk == ContactRecord.T003Pk);
                if (local != null)
                {
                    dc.Entry(local).State = EntityState.Detached;
                }
                //=============================================
                // Either Update or Insert child
                if (PageMode == PageConstants.EDIT)
                {
                    dc.Entry(ContactRecord).State = EntityState.Modified;
                    //by setting the state, then the 'SaveChanges' is able to save it's changes
                    dc.SaveChanges();


                    LogTheAction(eNums.eReadUpdateCreateDelete.Update);
                }
                else if (PageMode == PageConstants.ADD)
                {
                    dc.T003TelephoneContact.Add(ContactRecord);
                    dc.SaveChanges();

                    LogTheAction(eNums.eReadUpdateCreateDelete.Create);
                }
                // Get all the data again in case anything changed
                Get();
            }
            catch (DbEntityValidationException ex)
            {
                IsValid = false;
                // Validation errors
                foreach (var errors in ex.EntityValidationErrors)
                {
                    foreach (var item in errors.ValidationErrors)
                    {
                        Messages.AddModelError(item.PropertyName, item.ErrorMessage);
                    }
                }
            }
            // Set page state
            SetUIState(PageMode);
        }
        private void LogTheAction(eNums.eReadUpdateCreateDelete actionType)
        {
            //START LOGGING ================================================================================================================<<<
            string sX = ContactRecord.GetStringWith_RecordProperties();

            contactDBContext dcLog = new contactDBContext();

            T000MvcLogging logRecord = new T000MvcLogging();

            logRecord.ApplicationAssemblyName = General_Application_Extensions.fn_ReturnApplicationName();
            logRecord.Browser = Browser;
            logRecord.CreateUpdateDeleteRead = actionType.ToString();
            if (actionType != eNums.eReadUpdateCreateDelete.Read)
            {
                logRecord.Note = sX; //need to add serialized values
            }
            else
            {
                actionType.ToString();
            }

            logRecord.UserLogIn = General_ActiveDirectory_Extensions.fn_sUser();
            string localIP = "";

            localIP = IP;
            logRecord.ComputerName = General_String_Extensions.General_functions.fn_ComputerName(localIP);
            dcLog.T000MvcLogging.Add(logRecord);
            dcLog.SaveChanges();

            //END LOGGING ================================================================================================================<<<
        }
        public void Delete(int serverPK)
        {
            contactDBContext db = new contactDBContext();

            T003TelephoneContact server = db.T003TelephoneContact.Find(serverPK);

            if (server != null)
            {
                db.T003TelephoneContact.Remove(server);
            }

            db.SaveChanges();

            LogTheAction(eNums.eReadUpdateCreateDelete.Delete);


            Get();
        }