public EmailGroup Save(EmailGroup model)
        {
            using (LoanPriceEntities context = new LoanPriceEntities())
            {
                if (model.ID <= 0)
                {
                    context.EmailGroups.AddObject(model);
                }
                else
                {
                    context.EmailGroups.Attach(model);
                    context.ObjectStateManager.ChangeObjectState(model, System.Data.EntityState.Modified);
                }

                context.SaveChanges();
                return model;
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the EmailGroups EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEmailGroups(EmailGroup emailGroup)
 {
     base.AddObject("EmailGroups", emailGroup);
 }
 /// <summary>
 /// Create a new EmailGroup object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="groupName">Initial value of the GroupName property.</param>
 public static EmailGroup CreateEmailGroup(global::System.Int32 id, global::System.String name, global::System.String groupName)
 {
     EmailGroup emailGroup = new EmailGroup();
     emailGroup.ID = id;
     emailGroup.Name = name;
     emailGroup.GroupName = groupName;
     return emailGroup;
 }
 /// <summary>
 /// Create a new EmailGroup object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="emailID">Initial value of the EmailID property.</param>
 /// <param name="groupID">Initial value of the GroupID property.</param>
 public static EmailGroup CreateEmailGroup(global::System.Int32 id, global::System.Int32 emailID, global::System.Int32 groupID)
 {
     EmailGroup emailGroup = new EmailGroup();
     emailGroup.ID = id;
     emailGroup.EmailID = emailID;
     emailGroup.GroupID = groupID;
     return emailGroup;
 }
        protected void btnSaveEmail_Click(object sender, EventArgs e)
        {
            EmailGroup model = new EmailGroup();
            if (!string.IsNullOrEmpty(hfEmailGroupId.Value))
            {
                model.ID = Convert.ToInt32(hfEmailGroupId.Value);
                LogActivity("Email Updated", "Email has been updated", string.Empty);
            }
            else
            {
                LogActivity("Email Created", "Email has been created", string.Empty);
            }
            model.GroupName = ddlGroups.SelectedItem.Text;
            model.Name = txtEmail.Text;

            EmailGroupsBL bl = new EmailGroupsBL();
            bl.Save(model);
            BindEmails();
            hfEmailGroupId.Value = string.Empty;
        }