Ejemplo n.º 1
0
        public async Task <ShopBridgeItemModel> Create(ShopBridgeItemModel model)
        {
            DBContext.Set <ShopBridgeItemModel>().Add(model);
            await DBContext.SaveChangesAsync();

            return(model);
        }
Ejemplo n.º 2
0
        public async Task <bool> Update(ShopBridgeItemModel model, int key)
        {
            var exist = await DBContext.Set <ShopBridgeItemModel>().FindAsync(key);

            if (exist != null)
            {
                DBContext.Entry(exist).CurrentValues.SetValues(model);
                await DBContext.SaveChangesAsync();
            }
            return(true);
        }
Ejemplo n.º 3
0
        public async Task <ShopBridgeItemUIModel> Create(ShopBridgeItemUIModel uiModel)
        {
            if (string.IsNullOrEmpty(uiModel.Name))
            {
                throw new ApplicationException("Name is required");
            }

            try {
                var dataModel = new ShopBridgeItemModel {
                    Name        = uiModel.Name,
                    Description = uiModel.Description,
                    Price       = uiModel.Price,
                    ImagePath   = uiModel.ImagePath,
                    CreatedBy   = uiModel.CreatedByUserId,
                    CreatedOn   = DateTime.Now
                };
                dataModel = await ShopBridgeItemRepository.Create(dataModel);

                uiModel.Id = dataModel.Id;
            } catch (Exception ex) {
                throw ex;
            }
            return(uiModel);
        }