static void Main(string[] args)
        {
            MercuryContext mercury = new MercuryContext();

            foreach (var product in mercury.Products.Include("HistoricalPrices"))
            {
                Console.WriteLine(product);

                foreach (var price in product.HistoricalPrices.OrderByDescending(hp => hp.ChangeDate))
                {
                    Console.WriteLine($"\t{price.OldPrice}");
                }

                Console.WriteLine("----------------------------------------------");
            }
        }
        static void Main(string[] args)
        {
            MercuryContext mercury = new MercuryContext();

            //Product product = new Product()
            //{
            //    ProductName = "ETTAN",
            //    Price = 51.0m
            //};

            //mercury.Products.Add(product);
            //mercury.SaveChanges();


            var productToUpdate = mercury.Products
                                  .FirstOrDefault(o => o.ProductName.ToLower() == "ettan");

            //if(productToUpdate != null)
            //{
            //productToUpdate.Price *= 0.9m;
            //mercury.SaveChanges();
            //}

            bool done = false;

            while (!done)
            {
                HistoricalPrice hp = mercury
                                     .HistoricalPrices
                                     .FirstOrDefault(p => p.ProductsId == productToUpdate.Id);

                done = hp == null;

                if (!done)
                {
                    mercury.HistoricalPrices.Remove(hp);
                    mercury.SaveChanges();
                }
            }

            mercury.Products.Remove(productToUpdate);
            mercury.SaveChanges();
        }
Example #3
0
 public TaxrateController(MercuryContext context)
 {
     _context = context;
 }
Example #4
0
 public HomeController(ILogger <HomeController> logger, MercuryContext context)
 {
     _logger  = logger;
     _context = context;
 }
Example #5
0
 public ClientController(MercuryContext context)
 {
     _context = context;
 }
Example #6
0
 public ConfigController(MercuryContext context)
 {
     _context = context;
 }
 public CustomersService(MercuryContext context)
 {
     this.context = context;
 }
Example #8
0
 public EmployeeController(MercuryContext context)
 {
     _context = context;
 }
 public MainService(MercuryContext context)
 {
     this.context = context;
 }
Example #10
0
 public AllocationController(MercuryContext context)
 {
     _context = context;
 }
Example #11
0
 public EmployeeHelper(MercuryContext context)
 {
     _context = context;
 }
Example #12
0
 public ConfigHelper(MercuryContext context)
 {
     _context = context;
 }
Example #13
0
 public SalarypackageController(MercuryContext context)
 {
     _context = context;
 }
 public Authentication(MercuryContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #15
0
 public FinantialconditionController(MercuryContext context)
 {
     _context = context;
 }
Example #16
0
 public SalaryitemController(MercuryContext context)
 {
     _context = context;
 }