/// <summary>
 /// Deprecated Method for adding a new object to the Contacts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContacts(Contact contact)
 {
     base.AddObject("Contacts", contact);
 }
        public virtual ActionResult UpdateProfile(UpdateProfileModel model, Contact contact)
        {
            var userModel = new User() {
                UserName = this.UserName(),
                FirstName = model.FirstName,
                LastName = model.LastName,
                Signature = model.Signature,
                AppendSignatureToTitle = model.AppendSignatureToTitle,
                HasAllowedCommunication = model.HasAllowedCommunication
            };

            //var contact = model.Contact;

            //var session = SessionService.Session();
            var currentUser = Account.User();//session.User(User.Identity.Name);
            model.ShowSignatureField = currentUser.IsAtLeastInCatalogRole(Roles.Plugger);
            model.ShowContactInfo = currentUser.PricingPlan.CustomContactUs && currentUser.IsAtLeastInCatalogRole(Roles.Admin);

            //update the user's profile in the database
            try {
                var contactList = AccountService.UpdateProfile(userModel, new List<Contact>() { contact });

                UserEventLogService.LogUserEvent(UserActions.UpdateProfile);

                // UpdateModelWith the user dataSession cached in dataSession
                SessionService.Session().InitializeSession(true);
                CacheService.CacheUpdate(CacheService.CacheKeys.SiteProfile);

                var friendly = userModel.FullName();
                SetFriendlyNameCookie(friendly);

                this.FeedbackInfo("Successfully updated your profile");

                model.Contact = contactList.FirstOrDefault();

                ViewData["PasswordLength"] = AccountService.MinPasswordLength;

            }
            catch (Exception ex){
                Log.Error(ex);
                //model.ShowSignatureField = user.IsAtLeastInCatalogRole(Roles.Plugger);

                ModelState.AddModelError("",
                    SystemErrors.PasswordChangeFailed);
                this.FeedbackError("There was an error updating your profile");
            }

            model.NavigationLocation = new string[] { "Account", "Profile" };
            model.PageTitle = "Update Profile";
            model.PageMessage = "My Profile";
            return View(model);
        }
 /// <summary>
 /// Create a new Contact object.
 /// </summary>
 /// <param name="contactId">Initial value of the ContactId property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="contactTypeId">Initial value of the ContactTypeId property.</param>
 /// <param name="isDefault">Initial value of the IsDefault property.</param>
 /// <param name="createdOn">Initial value of the CreatedOn property.</param>
 public static Contact CreateContact(global::System.Int32 contactId, global::System.Int32 userId, global::System.Int32 contactTypeId, global::System.Boolean isDefault, global::System.DateTime createdOn)
 {
     Contact contact = new Contact();
     contact.ContactId = contactId;
     contact.UserId = userId;
     contact.ContactTypeId = contactTypeId;
     contact.IsDefault = isDefault;
     contact.CreatedOn = createdOn;
     return contact;
 }