public int Add(ContactBo contactBo)
        {
            var contact = _mapper.Map <Contact>(contactBo);

            _context.Contact.Add(contact);
            return(_context.SaveChanges());
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (web.Language == 1033)
                {
                    btnSubmit.Text = "Send";
                }
                ContactBo contactBo = new ContactBo(web);
                var       pageTitle = "Contacts";
                var       id        = Request.QueryString["Id"];
                var       items     = contactBo.get_ContactInfo(web, id);
                if (items.Count > 0)
                {
                    if (string.IsNullOrEmpty(id))
                    {
                        var currrentItem = items[0];
                        ltContact.Text = currrentItem.Title;
                        ltContent.Text = currrentItem.Content;
                        pageTitle      = currrentItem.Title;
                    }
                    else
                    {
                        int contactId = 0;
                        if (int.TryParse(id, out contactId))
                        {
                            var contact = items.First(c => c.Id == contactId);
                            ltContact.Text = contact.Title;
                            ltContent.Text = contact.Content;
                            pageTitle      = contact.Title;
                        }
                    }
                }

                SetPageTitles(pageTitle);

                rpContact.DataSource = items;
                rpContact.DataBind();
            }
        }