public async Task <ShopBridgeItemModel> Create(ShopBridgeItemModel model) { DBContext.Set <ShopBridgeItemModel>().Add(model); await DBContext.SaveChangesAsync(); return(model); }
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); }
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); }