protected void Page_Load(object sender, EventArgs e)
        {
            string id = Request.QueryString["id"];
            if (id != "00000000-0000-0000-0000-000000000000")
            {
                _emailId = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id);
                dpEmailTypes.Enabled = false;
            }

            systemEmail _emails = new systemEmail();

            Guid _guid = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id);

            _emails = _dal.GetSystemEmails(_guid);

            if (!Page.IsPostBack)
            {
                txtName.Text = _emails.name;
                txtSubject.Text = _emails.subject;
                dpEmailTypes.SelectedValue = _emails.emailType.ToString();
                txtEmailDescription.InnerText = _emails.emailDescription;
                txtEmailMessage.InnerText = _emails.message;

            }

            var dpEmailTypessource = _dal.getAllEmailTypes();
            dpEmailTypes.DataSource = dpEmailTypessource;
            dpEmailTypes.DataValueField = "id";
            dpEmailTypes.DataTextField = "description";
            dpEmailTypes.DataBind();

            dpEmailTypes.Items.Add(new ListItem("Please Select", "0", true));
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Guid _emailId;
                string id = Request.QueryString["id"];
                _emailId = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id);

                systemEmail _emails = new systemEmail();

                _emails = _dal.GetSystemEmails(_emailId);

                _emails.subject = txtSubject.Text;
                 _emails.authUserName = User.Identity.Name;
                _emails.emailType = new Guid(dpEmailTypes.SelectedValue);

                if (id == "00000000-0000-0000-0000-000000000000")
                {
                    _emails.authCreatedDate = DateTime.Now;

                    _dal.SoccerEntities.systemEmails.Add(_emails);
                }

                _dal.SoccerEntities.SaveChanges();
            }

            catch (Exception ex)
            {

                throw new EntityContextException("btnSave_Click failed.", ex);

            }

            Response.Redirect("default.aspx?teamId=00000000-0000-0000-0000-000000000000&id=00000000-0000-0000-0000-000000000000");
        }
 /// <summary>
 /// Create a new systemEmail object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 public static systemEmail CreatesystemEmail(global::System.Guid id)
 {
     systemEmail systemEmail = new systemEmail();
     systemEmail.id = id;
     return systemEmail;
 }
        public systemEmail GetSystemEmails(Guid _emailID)
        {
            try
            {
                if (_emailID == Guid.Empty)
                {
                    systemEmail _systemEmail = new systemEmail();
                    return _systemEmail;
                }
                else
                {
                    var q = SoccerEntities.systemEmails.Where(p => p.id == _emailID);

                    if (q == null)
                        throw new EntityContextException(string.Format("A system email could not be found {0}!", _emailID));
                    else
                        return q.ToList()[0];
                }
            }
            catch (Exception ex)
            {
                throw new EntityContextException("GetSystemEmails failed.", ex);
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the systemEmails EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTosystemEmails(systemEmail systemEmail)
 {
     base.AddObject("systemEmails", systemEmail);
 }