コード例 #1
0
        public int SaveConfiguration(Configurations body)
        {
            body.CreatedOn = DateTime.Now;
            List <ConfigurationParts> partsIds = body.ConfigurationParts;

            body.CarId               = body.Car.Id;
            body.CreatedBy           = body.CreatedByNavigation.Id;
            body.Car                 = null;
            body.CreatedByNavigation = null;
            body.ConfigurationParts  = null;

            dbContext.Configurations.Add(body);
            dbContext.SaveChanges();

            foreach (ConfigurationParts cp in partsIds)
            {
                ConfigurationParts temp = new ConfigurationParts
                {
                    ConfigurationId = body.Id,
                    PartId          = cp.Id
                };
                dbContext.ConfigurationParts.Add(temp);
            }
            dbContext.SaveChanges();

            return(body.Id);
        }
コード例 #2
0
        public Comments saveComment(CustomRequestBody body)
        {
            Comments              comment       = body.comment;
            Configurations        configuration = body.configuration;
            ConfigurationComments newEntry      = new ConfigurationComments();

            comment.CreatedOn           = DateTime.Now;
            comment.CreatedBy           = comment.CreatedByNavigation.Id;
            comment.CreatedByNavigation = null;

            dbContext.Comments.Add(comment);
            dbContext.SaveChanges();

            newEntry.CommentId       = comment.Id;
            newEntry.ConfigurationId = configuration.Id;

            dbContext.ConfigurationComments.Add(newEntry);
            dbContext.SaveChanges();

            return(comment);
        }
コード例 #3
0
ファイル: UserServices.cs プロジェクト: greviz/CarConfigAPI
 public void CreateUser(Users user)
 {
     dbContext.Users.Add(user);
     dbContext.SaveChanges();
 }