Esempio n. 1
0
        public static List <string> GetMetrics()
        {
            TemperatureConversionDbContext temperatureConversionAppDbContext = new TemperatureConversionDbContext();
            List <string> metrics = temperatureConversionAppDbContext.Metrics.Select(m => m.Title).ToList();

            return(metrics);
        }
        public static List <Conversion> GetConversions(User user)
        {
            TemperatureConversionDbContext temperatureConversionAppDbContext = new TemperatureConversionDbContext();
            List <Conversion> conversions = temperatureConversionAppDbContext.Conversions.Where(c => c.User.Name == user.Name).ToList();

            return(conversions);
        }
Esempio n. 3
0
        public static void AddUser(User user)
        {
            TemperatureConversionDbContext temperatureConversionAppDbContext = new TemperatureConversionDbContext();

            temperatureConversionAppDbContext.Users.Add(user);
            temperatureConversionAppDbContext.SaveChanges();
        }
Esempio n. 4
0
        public static List <User> GetUsers()
        {
            TemperatureConversionDbContext temperatureConversionAppDbContext = new TemperatureConversionDbContext();
            List <User> users = temperatureConversionAppDbContext.Users.ToList();

            return(users);
        }
        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();
        }