public IAdminService GetService(OnlineStoreDbContext dbContext) { var userManger = this.GetUserManager(dbContext); var service = new AdminService(dbContext, userManger); return(service); }
private IndexViewModel CallPrepareIndexModelForEditing(OnlineStoreDbContext dbContext) { var service = this.GetService(dbContext); var model = service.PrepareIndexModelForEditing(); return(model); }
public AdminUsersService( OnlineStoreDbContext dbContext, IMapper mapper, UserManager <User> userManager) : base(dbContext) { this.mapper = mapper; this.userManager = userManager; }
public ProductTest() { var builder = new DbConnection(); _context = new OnlineStoreDbContext((builder.InitConfiguration()).Options); _productRepository = new ProductRepositoryImpl(_context); }
public CouponTest() { var builder = new DbConnection(); _context = new OnlineStoreDbContext((builder.InitConfiguration()).Options); _couponRepository = new CouponRepositoryImpl(_context); }
public UserTest() { var builder = new DbConnection(); _context = new OnlineStoreDbContext((builder.InitConfiguration()).Options); _userRepository = new UserRepository(_context); }
public SellerProfileTest() { var builder = new DbConnection(); _context = new OnlineStoreDbContext((builder.InitConfiguration()).Options); _sellerRepository = new SellerRepositoryImpl(_context); }
private void SeedOrderStatuses(OnlineStoreDbContext dbContext) { dbContext.OrdersStatuses.Add(new OrderStatus() { Name = WebConstants.OrderStatusCanceled }); }
public UserDeliveryInfoService( OnlineStoreDbContext dbContext, IMapper mapper, UserManager <User> userManager) : base(dbContext) { this.mapper = mapper; this.userManager = userManager; }
public OnlineStoreDbContext GetDbContext() { var options = this.InitializeDbContextOptions(); var context = new OnlineStoreDbContext(options); return(context); }
public LoginController( OnlineStoreDbContext context, ILogger <LoginController> logger, ICustomerRepository <Customer> customerRepository) { this._logger = logger; this._context = context; this._customerRepository = customerRepository; }
private async Task <bool> CallDeleteAsync(OnlineStoreDbContext dbContext, Product product) { dbContext.Products.Add(product); dbContext.SaveChanges(); var service = this.GetService(dbContext); var result = await service.DeleteAsync(product.Id); return(result); }
public ProductRepositoryImpl(OnlineStoreDbContext DbContext) { _productRepository = new BaseRepository <Product>(DbContext); __productImageRepository = new BaseRepository <ProductImage>(DbContext); _productSpecHeadingRepository = new BaseRepository <ProductSpecHeading>(DbContext); _categoryRepository = new BaseRepository <Category>(DbContext); _subCategoryRepository = new BaseRepository <SubCategory>(DbContext); _productSpecSubHeading = new BaseRepository <ProductSpecSubHeading>(DbContext); _productInventoryRespository = new BaseRepository <Productinventory>(DbContext); }
private async Task <bool> CallCancelOrderAsync(OnlineStoreDbContext dbContext, Order order) { dbContext.Orders.Add(order); dbContext.SaveChanges(); var service = this.GetService(dbContext); var result = await service.CancelOrderAsync(order.Id); return(result); }
public static IQueryable <Product> GetProducts(this OnlineStoreDbContext dbContext, int?productCategoryID = null) { var query = dbContext.Products.AsQueryable(); if (productCategoryID.HasValue) { query = query.Where(item => item.ProductCategoryID == productCategoryID); } return(query); }
public UserOrderService( OnlineStoreDbContext dbContext, IMapper mapper, IShoppingCartService shoppingCartService, UserManager <User> userManager) : base(dbContext) { this.mapper = mapper; this.shoppingCartService = shoppingCartService; this.userManager = userManager; }
private UserManager <User> GetUserManager(OnlineStoreDbContext dbContext) { var userStore = new Mock <IUserStore <User> >().Object; var mock = new Mock <UserManager <User> >(userStore, null, null, null, null, null, null, null, null); var dbUsers = dbContext.Users; mock.Setup(um => um.Users).Returns(dbUsers); return(mock.Object); }
public FileService(IUserAccess userAccess, OnlineStoreDbContext dbContext, IMapper mapper, ILogger <FileService> logger, IModelValidator validator) { this.userAccess = userAccess; this.dbContext = dbContext; this.mapper = mapper; this.logger = logger; this.validator = validator; }
public CommonRepositoryImpl(OnlineStoreDbContext DbContext) { _categoryRepository = new BaseRepository <Category>(DbContext); _subCategoryRepository = new BaseRepository <SubCategory>(DbContext); _userTypeRepository = new BaseRepository <UserType>(DbContext); _discountTypeRepository = new BaseRepository <DiscountType>(DbContext); _productrepository = new BaseRepository <Product>(DbContext); _specHeadingRepository = new BaseRepository <ProductSpecHeading>(DbContext); _statusRepository = new BaseRepository <StockStatus>(DbContext); _unitRepository = new BaseRepository <UnitMeasurement>(DbContext); _dbContext = DbContext; }
public ApplicationBuilderSeedDbService(OnlineStoreDbContext dbContext) : base(dbContext) { this.paymentsTypesNames = new List <string>(); this.orderStatusesNames = new List <string>(); this.districtsNamesPopulatedPlacesNames = new Dictionary <string, string[]>(); this.rolesNames = new List <string>(); SeedInitialData(); }
public IActionResult OnPostCancelOrder([FromBody] DAL.Data.Entities.Order model) { if (!ModelState.IsValid) { IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); //return new BadRequestObjectResult(allErrors); return(new BadRequestObjectResult("Đã có lỗi xãy ra")); } if (model.Id == 0) { return(new BadRequestObjectResult("Mã đơn hàng không hợp lệ")); } else { using (var context = new OnlineStoreDbContext()) { using (var transaction = context.Database.BeginTransaction()) { try { var order = _orderRepository.Find(model.Id); order.DateModified = DateTime.Now; order.Status = OrderStatus.Canceled; _orderRepository.Update(order); var orderItems = order.OrderItems?.Where(oi => oi.IsDeleted == false); if (orderItems?.Any() == false) { transaction.Rollback(); return(new BadRequestObjectResult("Hủy đơn hàng không thành công")); } foreach (var orderItem in orderItems) { orderItem.Item.Quantity += orderItem.Quantity; _itemRepository.Update(orderItem.Item); } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); return(new BadRequestObjectResult("Hủy đơn hàng không thành công")); } } } } return(new OkObjectResult(model)); }
public OrderController( OnlineStoreDbContext context, IProductRepository<Product> productRepository, ILocationRepository<Location> locationRepository, IOrderRepository<Order> orderRepository, ILogger<Order> logger ) { this._context = context; this._productRepository = productRepository; this._locationRepository = locationRepository; this._orderRepository = orderRepository; this._logger = logger; }
public static void Initialize(OnlineStoreDbContext context) { if (!context.Products.Any()) { context.Products.AddRange( new Product { Name = "iPhone 6S", ImgSrc = "http://brain-images.cdn.dixons.com/5/8/10151585/u_10151585.jpg", Type = ProductType.Phone, Description = "A phone Apple's company.", Cost = 600 }, new Product { Name = "iPhone 8", ImgSrc = "https://www.poloinvest.ru/wp-content/uploads/2017/04/iphone8.jpg", Type = ProductType.Phone, Description = "A phone Apple's company.", Cost = 800 }, new Product { Name = "Xiaomi Mi Notebook Air", ImgSrc = "https://avatars.mds.yandex.net/get-mpic/397397/img_id3038328375620920498.jpeg/orig", Type = ProductType.Notebook, Description = "Very powerful notebook by Xiaomi.", Cost = 1000 }, new Product { Name = "Lenovo IdeaPad", ImgSrc = "https://s3-ap-southeast-2.amazonaws.com/wc-prod-pim/JPEG_1000x1000/SL14I100SS_lenovo_ideapad_100_14_celeron_laptop_100_14iby.jpg", Type = ProductType.Notebook, Description = "Good notebook for working and learning", Cost = 1550 }, new Product { Name = "Nikon D5", ImgSrc = "http://cdn-4.nikon-cdn.com/e/Q5NM96RZZo-YRYNeYvAi9beHK4x3L-8go_p7JUL6JpQMwSj_xzTyyQ==/Views/1557_D5_front.png", Type = ProductType.Camera, Description = "Professional camera.", Cost = 2050 } ); context.SaveChanges(); } }
public static OnlineStoreDbContext SeedLocations(this OnlineStoreDbContext dbContext) { var location = new Location { LocationID = "W01", LocationName = "Warehouse 01", CreationUser = creationUser, CreationDateTime = creationDateTime }; dbContext.Warehouses.Add(location); dbContext.SaveChanges(); return(dbContext); }
internal static void AddRoleToUser(OnlineStoreDbContext dbContext, User user, IdentityRole role) { dbContext.Users.Add(user); dbContext.Roles.Add(role); dbContext.SaveChanges(); var dbUserRole = new IdentityUserRole <string>() { UserId = user.Id, RoleId = role.Id }; dbContext.UserRoles.Add(dbUserRole); dbContext.SaveChanges(); }
public static OnlineStoreDbContext SeedProductCategories(this OnlineStoreDbContext dbContext) { var productCategory = new ProductCategory { ProductCategoryID = 1, ProductCategoryName = "PS4 Games", CreationUser = creationUser, CreationDateTime = creationDateTime }; dbContext.ProductCategories.Add(productCategory); dbContext.SaveChanges(); return(dbContext); }
public static OnlineStoreDbContext SeedCountryCurrencies(this OnlineStoreDbContext dbContext) { var countryCurrency = new CountryCurrency { CountryID = 1, CurrencyID = "USD", CreationUser = creationUser, CreationDateTime = creationDateTime }; dbContext.CountryCurrencies.Add(countryCurrency); dbContext.SaveChanges(); return(dbContext); }
public static OnlineStoreDbContext SeedPaymentMethods(this OnlineStoreDbContext dbContext) { var paymentMethod = new PaymentMethod { PaymentMethodID = Guid.Parse("44C3737C-9993-448A-82F7-75C0E37E5A7F"), PaymentMethodDescription = "Credit Card", CreationUser = creationUser, CreationDateTime = creationDateTime }; dbContext.PaymentMethods.Add(paymentMethod); dbContext.SaveChanges(); return(dbContext); }
public static OnlineStoreDbContext SeedOrderStatuses(this OnlineStoreDbContext dbContext) { var orderStatus = new OrderStatus { OrderStatusID = 100, Description = "Created", CreationUser = creationUser, CreationDateTime = creationDateTime }; dbContext.OrderStatuses.Add(orderStatus); dbContext.SaveChanges(); return(dbContext); }
public static OnlineStoreDbContext SeedCountries(this OnlineStoreDbContext dbContext) { var country = new Country { ID = 1, CountryName = "USA", CreationUser = creationUser, CreationDateTime = creationDateTime }; dbContext.Countries.Add(country); dbContext.SaveChanges(); return(dbContext); }