Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool   errorType, errorLink;
            string errormsg = "";

            //Validate data exists
            errorType = ValidateType(cmbSMTypes, out errormsg);
            ep.SetError(cmbSMTypes, errormsg);

            errorLink = ValidateLink(txtLink.Text, out errormsg);
            ep.SetError(txtLink, errormsg);

            if (!errorType || !errorLink)
            {
                return;
            }

            if (null == cmbSMTypes.SelectedItem)
            {
                cmbSMTypes.SelectedIndex = cmbSMTypes.FindStringExact(cmbSMTypes.Text);
            }

            SocialMediaLink sml = new SocialMediaLink(txtName.Text.Length != 0 ?
                                                      txtName.Text : cmbSMTypes.Text, txtLink.Text)
            {
                SMType = (cmbSMTypes.SelectedItem as sm_types).sm_type_id
            };

            Panel.Controls.Add(sml);

            this.Dispose();
        }
Ejemplo n.º 2
0
 public void AddSocialMediaLink(SocialMediaLink socialmedialink)
 {
     using (var dbcontext = new EntityContext())
     {
         dbcontext.SocialMediaLinks.Add(socialmedialink);
         dbcontext.SaveChanges();
     }
 }
Ejemplo n.º 3
0
        //SocialMediaLink ViewModel

        public static SocialMediaLinkViewModel ToSocialMediaLinkViewModel(this SocialMediaLink socialmedialink)
        {
            var model = new SocialMediaLinkViewModel();

            model.id         = socialmedialink.id;
            model.facebook   = socialmedialink.facebook;
            model.twitter    = socialmedialink.twitter;
            model.instagram  = socialmedialink.instagram;
            model.googleplus = socialmedialink.googleplus;
            model.youtube    = socialmedialink.youtube;
            return(model);
        }
Ejemplo n.º 4
0
        public void UpdateSocialMediaLink(int id, SocialMediaLink socialmedialink)
        {
            using (var dbcontext = new EntityContext())
            {
                var found = (from a in dbcontext.SocialMediaLinks
                             where a.id == id
                             select a).FirstOrDefault();

                found.facebook   = socialmedialink.facebook;
                found.twitter    = socialmedialink.twitter;
                found.instagram  = socialmedialink.instagram;
                found.googleplus = socialmedialink.googleplus;
                found.youtube    = socialmedialink.youtube;
                dbcontext.SaveChanges();
            }
        }
        public ActionResult Save(SocialMediaLink model)
        {
            repo.Save(model);

            return(RedirectToAction("Index"));
        }