Example #1
0
        public bool CreateEmotionDream(EmotionDreamCreate model)
        {
            var entity =
                new EmotionDream()
            {
                OwnerId   = _userId,
                EmotionId = model.EmotionId,
                DreamId   = model.DreamId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.EmotionDreams.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Example #2
0
        public IHttpActionResult Post(EmotionDreamCreate dream)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateEmotionDreamService();

            if (!service.CreateEmotionDream(dream))
            {
                return(InternalServerError());
            }

            return(Ok());
        }