public static void Seed()
        {
            using var _ctx = new Context();
            _ctx.Database.EnsureDeleted();
            _ctx.Database.EnsureCreated();
            var comp1 = new Company("pingo ácido", 123456789);
            var reg1  = new Region("Covilhã");
            var est1  = new Establishment("rua das papoilas", "09h00", "20h00", "sundays and holidays", reg1.Id, comp1.Id);
            var reQ1  = new ReservedQueue(est1.Id);
            var stQ1  = new StoreQueue(12, est1.Id);

            var cat1 = new Category("Non-Alcoholic Beverages");
            var bra1 = new Brand("Luso");
            var eg1  = new EssentialGood("Água", false, "560-3187-922", 0.39, 0.5);
            var spb1 = new ShoppingBasket(est1.Id);


            _ctx.Companies.AddRange(comp1);
            _ctx.Regions.AddRange(reg1);
            _ctx.Establishments.AddRange(est1);
            _ctx.ReservedQueues.AddRange(reQ1);
            _ctx.StoreQueues.AddRange(stQ1);
            _ctx.ShoppingBaskets.AddRange(spb1);
            _ctx.SaveChanges();
        }
Example #2
0
        public void TestCreateAndReadEssentialGoodAsync()
        {
            ContextSeeder.Seed();
            var bo        = new EssentialGoodBusinessObject();
            var reg       = new EssentialGood("Lisboa");
            var resCreate = bo.CreateAsync(reg).Result;
            var resGet    = bo.ReadAsync(reg.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
 public OperationResult Create(EssentialGood item)
 {
     try
     {
         _dao.Create(item);
         return(new OperationResult()
         {
             Success = true
         });
     }
     catch (Exception e)
     {
         return(new OperationResult()
         {
             Success = false, Exception = e
         });
     }
 }
        public async Task <OperationResult> CreateAsync(EssentialGood item)
        {
            try
            {
                await _dao.CreateAsync(item);

                return(new OperationResult()
                {
                    Success = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult()
                {
                    Success = false, Exception = e
                });
            }
        }
Example #5
0
 public async Task DeleteAsync(EssentialGood region)
 {
     region.IsDeleted = true;
     await UpdateAsync(region);
 }
Example #6
0
 public void Delete(EssentialGood region)
 {
     region.IsDeleted = true;
     Update(region);
 }
Example #7
0
 public async Task UpdateAsync(EssentialGood region)
 {
     _context.Entry(region).State = EntityState.Modified;
     await _context.SaveChangesAsync();
 }
Example #8
0
 public void Update(EssentialGood region)
 {
     _context.Entry(region).State = EntityState.Modified;
     _context.SaveChanges();
 }
Example #9
0
        public async Task CreateAsync(EssentialGood region)
        {
            await _context.EssentialGoods.AddAsync(region);

            await _context.SaveChangesAsync();
        }
Example #10
0
 public void Create(EssentialGood region)
 {
     _context.EssentialGoods.Add(region);
     _context.SaveChanges();
 }