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); }
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); }
public void CreateUser(Users user) { dbContext.Users.Add(user); dbContext.SaveChanges(); }