private IDictionary <string, string> ValidateModel <T>(T model, HttpPostedFileBase image, UmbracoHelper helper) where T : MemberModel, IMemberPictureUpload
        {
            Dictionary <string, string> messages = new Dictionary <string, string>();

            if (helper == null)
            {
                return(messages);
            }

            IEnumerable <KeyValuePair <int, string> > knittingExperienceOptions = helper.GetKnittingExperienceOptions();

            if (!knittingExperienceOptions.Any(x => x.Value == model.KnittingExperience))
            {
                messages.Add(nameof(model.KnittingExperience), "Knitting know-how required");
            }

            if (model.KnittingExperience == knittingExperienceOptions.Last().Value&& string.IsNullOrWhiteSpace(model.KnittingExperienceOther))
            {
                messages.Add(nameof(model.KnittingExperienceOther), "Knitting know-how 'other' required");
            }

            if (image != null && !image.ContentType.StartsWith("image/"))
            {
                messages.Add(nameof(model.UploadedPicture), "File type not allowed. Please upload an image.");
            }

            return(messages);
        }
        private static void UpdateMemberProperties(IMember member, MemberModel model, UmbracoHelper helper, IMedia picture)
        {
            IEnumerable <KeyValuePair <int, string> > knittingExperienceOptions = helper.GetKnittingExperienceOptions();

            member.SetValue(MemberPropertyNames.EmailOptIn, model.EmailOptIn);
            member.SetValue(MemberPropertyNames.FacebookProfile, model.FacebookProfile);
            member.SetValue(MemberPropertyNames.FavouriteBeverage, model.FavouriteBeverage);
            member.SetValue(MemberPropertyNames.FirstName, model.FirstName);
            member.SetValue(MemberPropertyNames.Hometown, model.Hometown);
            member.SetValue(MemberPropertyNames.KnittingExperience, knittingExperienceOptions.First(x => x.Value == model.KnittingExperience).Key);
            member.SetValue(MemberPropertyNames.KnittingExperienceOther, model.KnittingExperienceOther);
            member.SetValue(MemberPropertyNames.LastName, model.LastName);
            member.SetValue(MemberPropertyNames.Neighbourhood, model.Neighbourhood);
            member.SetValue(MemberPropertyNames.Reason, model.Reason);

            if (picture != null)
            {
                member.SetValue(MemberPropertyNames.Picture, picture.ToPropertyValue());
            }
        }