Example #1
0
        public int?CreateProject(string title, string description, string genre,
                                 string producer, GenderType gender, int attentionRate)
        {
            using (var db = new emotionDb())
            {
                var genreInstance = db.Genres.FirstOrDefault(x => x.Name.Equals(genre));
                if (genreInstance == null)
                {
                    return(null);
                }

                var project = new Project
                {
                    Title         = title,
                    Description   = description,
                    Genre         = genreInstance,
                    ProducerName  = producer,
                    GenderType    = gender,
                    AttentionRate = attentionRate
                };

                db.Add(project);
                db.SaveChanges();

                return(project.Id);
            }
        }
        public void Create(string emotion, int projectId, int timeIndex)
        {
            using (var db = new emotionDb())
            {
                var emotionInstance = db.Emotions.FirstOrDefault(x => x.Name.Equals(emotion));

                var actualResult = new ActualResult
                {
                    ProjectId = projectId,
                    TimeIndex = timeIndex,
                    Emotion   = emotionInstance
                };

                db.Add(actualResult);
                db.SaveChanges();
            }
        }
        public void Create(int projectId, int from, int to, string emotion)
        {
            using (var db = new emotionDb())
            {
                var emotionInstance = db.Emotions.FirstOrDefault(x => x.Name.Equals(emotion));

                var expectedResult = new ExpectedResult
                {
                    ProjectId = projectId,
                    From      = from,
                    To        = to,
                    Emotion   = emotionInstance
                };

                db.ExpectedResults.Add(expectedResult);
                db.SaveChanges();
            }
        }