예제 #1
0
        public override Task <Detail> InsertAsync(Detail t)
        {
            var task = base.InsertAsync(t);

            var pr = new PriceHistoryRepository();

            pr.InsertAsync(new PriceHistory
            {
                Date      = DateTime.UtcNow,
                DetailId  = t.Id,
                Price     = t.Price ?? 0,
                Operation = Operation.Create
            }).Wait();

            return(task);
        }
예제 #2
0
        public override Task UpdateAsync(Detail t)
        {
            var price = GetByIdAsync(t.Id).Result.Price;
            var task  = base.UpdateAsync(t);


            if (price != t.Price)
            {
                var pr = new PriceHistoryRepository();
                pr.InsertAsync(new PriceHistory
                {
                    Date      = DateTime.UtcNow,
                    DetailId  = t.Id,
                    Price     = t.Price ?? 0,
                    Operation = Operation.Update
                }).Wait();
            }

            return(task);
        }