Example #1
0
        public void Add(int ideaId, Feature feature)
        {
            var idea = db.Ideas.FirstOrDefault(i => i.Id == ideaId);
            if (idea == null)
                throw new KeyNotFoundException("Idea not found.");

            idea.Features.Add(feature);
            db.SaveChanges();
        }
Example #2
0
        public bool Add(int ideaid, Feature feature)
        {
            var idea = db.Ideas.FirstOrDefault(i => i.Id == ideaid);
            if (idea == null)
                return false;

            if (idea.Features == null)
                idea.Features = new Collection<Feature>();

            idea.Features.Add(feature);
            db.SaveChanges();
            return true;
        }
Example #3
0
        public FeatureModule(IIdeaRepository ideas, IFeatureRepository features)
            : base("/idea")
        {
            _ideas = ideas;
            _features = features;

            Post["/{idea}/feature"] = _ =>
            {
                int id = _.Idea;
                var feature = new Feature
                                {
                                    Time = DateTime.UtcNow,
                                    Text = Request.Form.feature
                                };
                _features.Add(id, feature);

                return Response.AsRedirect(string.Format("/idea/{0}#{1}", id, feature.Id));
            };
        }
Example #4
0
        public FeatureModule(IFeatureRepository features, IUserRepository users)
            : base("/idea")
        {
            _features = features;

            this.RequiresAuthentication();

            Post["/{idea}/feature"] = _ =>
            {
                int id = _.Idea;
                var feature = new Feature
                                {
                                    Time = DateTime.UtcNow,
                                    Text = Request.Form.feature,
                                    User = Context.GetCurrentUser(users)
                                };
                _features.Add(id, feature);

                return Response.AsRedirect(string.Format("/idea/{0}#{1}", id, feature.Id));
            };
        }