public void UpdateHouse(House house)
        {
            if (string.IsNullOrEmpty(house.ID))
            {
                house.ID = Guid.NewGuid().ToString();
                _model.House.Add(house);
                _model.SaveChanges();
            }
            else
            {
                House original = _model.House.Find(house.ID);
                if (original != null)
                {
                    original.Name = house.Name;
                    original.TypeID = house.TypeID;
                    original.Description = house.Description;
                    original.Image = house.Image;
                    _model.SaveChanges();
                }

            }
        }
        public void Init()
        {
            service = new BusinessService();

            ticket1 = new Ticket()
            {

                Name = "orla runge",
                E_mail = "*****@*****.**",
                Phone = "31213820",
                HouseID = "1",
                UserText = "jeg er Orla the viking"
            };
            ticket2 = new Ticket()
            {

                Name = "Wang",
                E_mail = "*****@*****.**",
                Phone = "31213820",
                HouseID = "1",
                UserText = "test 2",
                Solved =  true,
                SolvedBy = "1"
            };

            ticket3 = new Ticket()
            {

                Name = "hui",
                E_mail = "*****@*****.**",
                Phone = "23456",
                HouseID = "3",
                UserText = "test",

            };
            ticket4 = new Ticket()
            {
                Name = "Daniel",
                E_mail = "*****@*****.**",
                Phone = "6651354",
                HouseID = "1",
                UserText = "test three"
            };
            house1 = new DAL.House()
            {
                ID = "20",
                TypeID = "3",
                Name = "SM-L2",
                Description = "aaaaaaa",
                Image = "sm-l/2.jpg"

            };
            house2 = new DAL.House()
            {

                TypeID = "3",
                Name = "SM-L24",
                Description = "aaaaaaatest",
                Image = "sm-l/2.jpg"

            };

            service.NewTicket(ticket1);
            service.NewTicket(ticket2);
            service.NewTicket(ticket3);
        }
 // Delete House
 public void Delete(House house)
 {
     using (RentalContext db = new RentalContext())
     {
     }
 }
 private HouseSerializable TranslateHouses(House old)
 {
     return new HouseSerializable
     {
         Id = old.ID,
         Name = old.Name,
         TypeId = old.TypeID,
         Description = old.Description,
         Image = old.Image
     };
 }
 public void UpdateHouse(House house)
 {
     _rep.UpdateHouse(house);
 }
Esempio n. 6
0
        public async Task Initialize()
        {
            //_context.Database.EnsureCreated();

            await _context.Database.MigrateAsync().ConfigureAwait(false);

            if (!await _context.Houses.AnyAsync() && !await _context.Meters.AnyAsync())
            {
                House house_1 = new House
                {
                    FiasGuid   = "fias_example_value_1",
                    Region     = "Rostov area",
                    District   = "Neklinovskiy",
                    City       = "Taganrog",
                    Street     = "Chekhova",
                    Appartment = "32",
                    MeterGiud  = "meter_example_value_1",
                    Meters     = new List <Meter>()
                    {
                        new Meter {
                            DateMeter = DateTime.Now,
                            Quantity  = 34.33
                        },
                        new Meter {
                            DateMeter = DateTime.Now,
                            Quantity  = 3455.4
                        },
                        new Meter {
                            DateMeter = DateTime.Now,
                            Quantity  = 99.30
                        },
                    }
                };

                House house_2 = new House
                {
                    FiasGuid   = "fias_example_value_2",
                    Region     = "Rostov area",
                    District   = "Neklinovskiy",
                    City       = "Taganrog",
                    Street     = "Petrovskaya",
                    Appartment = "43",
                    MeterGiud  = "meter_example_value_2",
                    Meters     = new List <Meter>()
                    {
                        new Meter {
                            DateMeter = DateTime.Now,
                            Quantity  = 55.66
                        },
                        new Meter {
                            DateMeter = DateTime.Now,
                            Quantity  = 98.03
                        }
                    }
                };

                House house_3 = new House
                {
                    FiasGuid   = "fias_example_value_3",
                    Region     = "Rostov area",
                    District   = "Neklinovskiy",
                    City       = "Taganrog",
                    Street     = "Lenina",
                    Appartment = "666",
                    MeterGiud  = "meter_example_value_3",
                    Meters     = new List <Meter>()
                    {
                        new Meter {
                            DateMeter = DateTime.Now,
                            Quantity  = 70.98
                        }
                    }
                };



                var newHouse_1 = _context.Houses.Add(house_1);
                var newHouse_2 = _context.Houses.Add(house_2);
                var newHouse_3 = _context.Houses.Add(house_3);
                //await _context.SaveChangesAsync();

                //Meter meter_1 = new Meter
                //{
                //    HouseId = newHouse_1.Entity.Id,
                //    DateMeter = DateTime.Now,
                //    Quantity = 34.33
                //};

                //Meter meter_2 = new Meter
                //{
                //    HouseId = newHouse_1.Entity.Id,
                //    DateMeter = DateTime.Now,
                //    Quantity = 444.2
                //};
                //Meter meter_3 = new Meter
                //{
                //    HouseId = newHouse_1.Entity.Id,
                //    DateMeter = DateTime.Now,
                //    Quantity = 113.21
                //};
                //Meter meter_4 = new Meter
                //{
                //    HouseId = newHouse_2.Entity.Id,
                //    DateMeter = DateTime.Now,
                //    Quantity = 422.78
                //};
                //Meter meter_5 = new Meter
                //{
                //    HouseId = newHouse_3.Entity.Id,
                //    DateMeter = DateTime.Now,
                //    Quantity = 55.99
                //};

                //Meter meter_6 = new Meter
                //{
                //    HouseId = newHouse_3.Entity.Id,
                //    DateMeter = DateTime.Now,
                //    Quantity = 212.34
                //};

                //var newMeter_1 = _context.Meters.Add(meter_1);
                //var newMeter_2 = _context.Meters.Add(meter_2);
                //var newMeter_3 = _context.Meters.Add(meter_3);
                //var newMeter_4 = _context.Meters.Add(meter_4);
                //var newMeter_5 = _context.Meters.Add(meter_5);
                //var newMeter_6 = _context.Meters.Add(meter_6);

                await _context.SaveChangesAsync();

                _logger.LogInformation("Seeding initial data completed");
            }
        }