Exemple #1
0
        public static void AddUser(User user)
        {
            TemperatureConversionDbContext temperatureConversionAppDbContext = new TemperatureConversionDbContext();

            temperatureConversionAppDbContext.Users.Add(user);
            temperatureConversionAppDbContext.SaveChanges();
        }
        public static void RemoveConversion(int conversionId)
        {
            TemperatureConversionDbContext temperatureConversionAppDbContext = new TemperatureConversionDbContext();
            Conversion conversion = temperatureConversionAppDbContext.Conversions.Find(conversionId);

            temperatureConversionAppDbContext.Conversions.Remove(conversion);
            temperatureConversionAppDbContext.SaveChanges();
        }
        public static void AddConversion(Conversion conversion, User user)
        {
            TemperatureConversionDbContext temperatureConversionAppDbContext = new TemperatureConversionDbContext();

            user = temperatureConversionAppDbContext.Users.Where(u => u.Name == user.Name).First();
            conversion.UserId = user.UserId;
            temperatureConversionAppDbContext.Conversions.Add(conversion);
            temperatureConversionAppDbContext.SaveChanges();
        }