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

            return(metrics);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public static void AddUser(User user)
        {
            TemperatureConversionDbContext temperatureConversionAppDbContext = new TemperatureConversionDbContext();

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

            return(users);
        }
Exemplo n.º 5
0
        public static void RemoveConversion(int conversionId)
        {
            TemperatureConversionDbContext temperatureConversionAppDbContext = new TemperatureConversionDbContext();
            Conversion conversion = temperatureConversionAppDbContext.Conversions.Find(conversionId);

            temperatureConversionAppDbContext.Conversions.Remove(conversion);
            temperatureConversionAppDbContext.SaveChanges();
        }
Exemplo n.º 6
0
        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();
        }