Exemplo n.º 1
0
        //gets all contact forms, converts their format and add to the
        //view model to be displayed in the table
        public IEnumerable <ContactFormAng> Get()
        {
            List <ContactForm>    allContactForms = _contactFormRepo.GetAllContactForms();
            List <ContactFormAng> model           = new List <ContactFormAng>();

            foreach (ContactForm form in allContactForms)
            {
                ContactFormAng item = new ContactFormAng
                {
                    Name          = form.Name,
                    Email         = form.Email,
                    FullMessage   = form.Message,
                    ContactFormID = form.ContactFormID
                };

                //cut message (only for display purposes) if it longer than
                //50 chars
                if (form.Message.Length > 50)
                {
                    item.CutMessage = form.Message.Substring(0, 50);
                }
                else
                {
                    item.CutMessage = form.Message;
                }
                model.Add(item);
            }
            return(model);
        }
 public void GetAllContactFormsTest()
 {
     Assert.AreEqual(repo.GetAllContactForms().Count, 3);
 }