Exemplo n.º 1
0
 public static void DeleteCrop(Crop crop)
 {
     using (DataContext context = GetContext())
     {
         context.Crops.Attach(crop);
         context.Crops.DeleteOnSubmit(crop);
         context.SubmitChanges();
     }
     // TODO: create logging project that will log events
     // new RecordDeletedEvent("greenhouse", greenhouse.ID, null).Raise();
 }
Exemplo n.º 2
0
        public static void InsertCrop(Crop crop)
        {
            // TODO: sanitize values
            crop.Height = crop.Height;
            crop.Width = crop.Width;
            crop.Length = crop.Length;
            crop.Name = crop.Name;
            crop.MaxTemperature = crop.MaxTemperature;
            crop.MinTemperature = crop.MinTemperature;
            crop.MaxHumidity = crop.MaxHumidity;
            crop.MinHumidity = crop.MinHumidity;

            using (DataContext context = GetContext())
            {
                context.Crops.InsertOnSubmit(crop);
                context.SubmitChanges();
            }
        }
Exemplo n.º 3
0
        public static void UpdateCrop(Crop changedCrop)
        {
            // TODO: sanitize values
            changedCrop.Height = changedCrop.Height;
            changedCrop.Width = changedCrop.Width;
            changedCrop.Length = changedCrop.Length;
            changedCrop.Name = changedCrop.Name;
            changedCrop.MaxTemperature = changedCrop.MaxTemperature;
            changedCrop.MinTemperature = changedCrop.MinTemperature;
            changedCrop.MaxHumidity = changedCrop.MaxHumidity;
            changedCrop.MinHumidity = changedCrop.MinHumidity;

            using (DataContext context = GetContext())
            {
                context.Crops.Attach(changedCrop, true);
                context.SubmitChanges();
            }
        }