コード例 #1
0
        public async Task <IActionResult> ItemCategory([FromBody] GetChangesModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var Inserted = await _Context.Set <ItemCategory>().Where(x => x.CreationDate >= model.LastUpdate).Select(x =>
                                                                                                                     new ItemCategoryModel
            {
                Description = x.Description,
                ImagePath   = x.ImagePath,
                Name        = x.Name
            }).ToListAsync();

            var Updated = await _Context.Set <ItemCategory>().Where(x => x.UpdatedDate >= model.LastUpdate && x.CreationDate <= model.LastUpdate).Select(x =>
                                                                                                                                                         new ItemCategoryModel
            {
                Description = x.Description,
                ImagePath   = x.ImagePath,
                Name        = x.Name
            }).ToListAsync();

            var IDs = await _Context.Set <ItemCategory>().Select(x => x.ID).ToListAsync();

            var Deleted = model.RecoredIDs.Where(x => !IDs.Contains(x)).ToList();

            return(Json(new
            {
                Inserted,
                Updated,
                Deleted
            }));
        }
コード例 #2
0
        public async Task <IActionResult> OfferItem([FromBody] GetChangesModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var Inserted = await _Context.Set <OfferItem>().Where(x => x.CreationDate >= model.LastUpdate).Select(x =>
                                                                                                                  new OfferItemModel
            {
                ItemID   = x.ItemID,
                Quantity = x.Quantity,
                OfferID  = x.OfferID
            }).ToListAsync();

            var Updated = await _Context.Set <OfferItem>().Where(x => x.UpdatedDate >= model.LastUpdate && x.CreationDate <= model.LastUpdate).Select(x =>
                                                                                                                                                      new OfferItemModel
            {
                ItemID   = x.ItemID,
                Quantity = x.Quantity,
                OfferID  = x.OfferID
            }).ToListAsync();

            var IDs = await _Context.Set <OfferItem>().Select(x => x.ID).ToListAsync();

            var Deleted = model.RecoredIDs.Where(x => !IDs.Contains(x)).ToList();

            return(Json(new
            {
                Inserted,
                Updated,
                Deleted
            }));
        }
コード例 #3
0
        public async Task <IActionResult> Offer([FromBody] GetChangesModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var Inserted = await _Context.Set <Offer>().Include(x => x.Item).Where(x => x.CreationDate >= model.LastUpdate).Select(x =>
                                                                                                                                   new OfferModel
            {
                Description        = x.Description,
                Discount           = x.Discount,
                IsActive           = x.IsActive,
                OfferType          = x.OfferType,
                ItemID             = x.ItemID,
                ItemName           = x.Item.Name,
                Price              = x.Price,
                ShortDescription   = x.Description,
                ThumbnailImagePath = x.ThumbnailImagePath,
                Title              = x.Title
            }).ToListAsync();

            var Updated = await _Context.Set <Offer>().Where(x => x.UpdatedDate >= model.LastUpdate && x.CreationDate <= model.LastUpdate).Select(x =>
                                                                                                                                                  new OfferModel
            {
                Description        = x.Description,
                Discount           = x.Discount,
                IsActive           = x.IsActive,
                OfferType          = x.OfferType,
                ItemID             = x.ItemID,
                ItemName           = x.Item.Name,
                Price              = x.Price,
                ShortDescription   = x.Description,
                ThumbnailImagePath = x.ThumbnailImagePath,
                Title              = x.Title
            }).ToListAsync();

            var IDs = await _Context.Set <Offer>().Select(x => x.ID).ToListAsync();

            var Deleted = model.RecoredIDs.Where(x => !IDs.Contains(x)).ToList();

            return(Json(new
            {
                Inserted,
                Updated,
                Deleted
            }));
        }
コード例 #4
0
        public async Task <IActionResult> Item([FromBody] GetChangesModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var Inserted = await _Context.Set <Item>().Where(x => x.CreationDate >= model.LastUpdate).Select(x =>
                                                                                                             new ItemModel
            {
                Description        = x.Description,
                Quantity           = x.Quantity,
                IsEnable           = x.IsEnable,
                ItemCategoryID     = x.ItemCategoryID,
                Name               = x.Name,
                Price              = x.Price,
                ShortDescription   = x.ShortDescription,
                ThumbnailImagePath = x.ThumbnailImagePath
            }).ToListAsync();

            var Updated = await _Context.Set <Item>().Where(x => x.UpdatedDate >= model.LastUpdate && x.CreationDate <= model.LastUpdate).Select(x =>
                                                                                                                                                 new ItemModel
            {
                Description        = x.Description,
                Quantity           = x.Quantity,
                IsEnable           = x.IsEnable,
                ItemCategoryID     = x.ItemCategoryID,
                Name               = x.Name,
                Price              = x.Price,
                ShortDescription   = x.ShortDescription,
                ThumbnailImagePath = x.ThumbnailImagePath
            }).ToListAsync();

            var IDs = await _Context.Set <Item>().Select(x => x.ID).ToListAsync();

            var Deleted = model.RecoredIDs.Where(x => !IDs.Contains(x)).ToList();

            return(Json(new
            {
                Inserted,
                Updated,
                Deleted
            }));
        }
コード例 #5
0
        private async Task <IActionResult> GetChanges <table>(GetChangesModel model) where table : DatabaseObject
        {
            if (model == null)
            {
                return(null);
            }
            var Inserted = await _Context.Set <table>().Where(x => x.CreationDate >= model.LastUpdate).ToListAsync();

            var Updated = await _Context.Set <table>().Where(x => x.UpdatedDate >= model.LastUpdate && x.CreationDate <= model.LastUpdate).ToListAsync();

            var IDs = await _Context.Set <table>().Select(x => x.ID).ToListAsync();

            var Deleted = model.RecoredIDs.Where(x => !IDs.Contains(x)).ToList();

            return(Json(new
            {
                Inserted,
                Updated,
                Deleted
            }));
        }