コード例 #1
0
        public IActionResult Create()
        {
            List <OrderProduct> OP = new List <OrderProduct> ();

            OP.Add(new OrderProduct {
                Order = DBContext.Orders.Find((long)1)
            });
            Product product = new Product
            {
                Name        = "Test",
                Description = "Tasty",
                Price       = 10,
                Type        = "T",
                CreateTime  = DateTime.Now,
                UpdateTime  = DateTime.Now,
                Orders      = OP
            };

            DBContext.Products.Add(product);
            DBContext.SaveChanges();

            return(Json(new
            {
                success = true
            }));
        }
コード例 #2
0
        public ActionResult Post([FromBody] ChatHistory chatHistory)
        {
            var newConversation = new ChatHistory
            {
                UserName   = chatHistory.UserName,
                Message    = chatHistory.Message,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now
            };

            DBContext.ChatHistories.Add(newConversation);
            DBContext.SaveChanges();
            //_chatHub.Clients.All.InvokeAsync("Send", "<h3> Name: " + name + "</h3>" + message);
            //_chatHub.Send("<h3> Name: " + name + "</h3>" + message);
            return(Json(new
            {
                success = true
            }));
        }
コード例 #3
0
        public void Setup()
        {
            _contextOptions = DbContextShared.CreateContextOptions();

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                _pageId = Guid.NewGuid();

                context.Pages.AddRange(
                    new Page
                {
                    Id     = _pageId,
                    Name   = "Page 1",
                    Status = PageStatus.Active
                }
                    );

                context.SaveChanges();
            }
        }
コード例 #4
0
        public void Setup()
        {
            _contextOptions = DbContextShared.CreateContextOptions();

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                _moduleTypeId = Guid.NewGuid();

                context.ModuleTypes.AddRange(
                    new ModuleType
                {
                    Id     = _moduleTypeId,
                    Name   = "ModuleType 1",
                    Status = ModuleTypeStatus.Active
                }
                    );

                context.SaveChanges();
            }
        }
コード例 #5
0
        public void Setup()
        {
            _contextOptions = DbContextShared.CreateContextOptions();

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                _siteId         = Guid.NewGuid();
                _emailAccountId = Guid.NewGuid();

                context.EmailAccounts.AddRange(
                    new EmailAccount
                {
                    SiteId = _siteId,
                    Id     = _emailAccountId,
                    Status = EmailAccountStatus.Active
                }
                    );

                context.SaveChanges();
            }
        }
コード例 #6
0
        public void SetUp()
        {
            _contextOptions = DbContextShared.CreateContextOptions();

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                _siteId            = Guid.NewGuid();
                _languageId1       = Guid.NewGuid();
                _languageId2       = Guid.NewGuid();
                _deletedLanguageId = Guid.NewGuid();

                context.Languages.AddRange(
                    new LanguageDbEntity
                {
                    SiteId      = _siteId,
                    Id          = _languageId1,
                    Name        = "Language Name 1",
                    CultureName = "ab1",
                    Url         = "ab1",
                    Status      = LanguageStatus.Active
                },
                    new LanguageDbEntity
                {
                    SiteId      = _siteId,
                    Id          = _languageId2,
                    Name        = "Language Name 2",
                    CultureName = "ab2",
                    Url         = "ab2",
                    Status      = LanguageStatus.Hidden
                },
                    new LanguageDbEntity
                {
                    Id     = _deletedLanguageId,
                    Status = LanguageStatus.Deleted
                }
                    );

                context.SaveChanges();
            }
        }
コード例 #7
0
        public void SetUp()
        {
            _contextOptions = DbContextShared.CreateContextOptions();

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                _siteId          = Guid.NewGuid();
                _moduleId1       = Guid.NewGuid();
                _moduleId2       = Guid.NewGuid();
                _moduleTypeId1   = Guid.NewGuid();
                _moduleTypeId2   = Guid.NewGuid();
                _deletedModuleId = Guid.NewGuid();

                context.Modules.AddRange(
                    new ModuleDbEntity
                {
                    SiteId       = _siteId,
                    Id           = _moduleId1,
                    ModuleTypeId = _moduleTypeId1,
                    Title        = "Title 1",
                    Status       = ModuleStatus.Active
                },
                    new ModuleDbEntity
                {
                    SiteId       = _siteId,
                    Id           = _moduleId2,
                    ModuleTypeId = _moduleTypeId2,
                    Title        = "Title 2",
                    Status       = ModuleStatus.Active
                },
                    new ModuleDbEntity
                {
                    Id     = _deletedModuleId,
                    Status = ModuleStatus.Deleted
                }
                    );

                context.SaveChanges();
            }
        }
コード例 #8
0
ファイル: MenuFacadeTests.cs プロジェクト: MtnTsn/Weapsy
        public void Setup()
        {
            _contextOptions = DbContextShared.CreateContextOptions();

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                _siteId = Guid.NewGuid();
                _menuId = Guid.NewGuid();

                context.Menus.AddRange(
                    new Menu
                {
                    SiteId = _siteId,
                    Id     = _menuId,
                    Name   = "Menu Name 1",
                    Status = MenuStatus.Active
                }
                    );

                context.SaveChanges();
            }
        }
コード例 #9
0
        public void SetUp()
        {
            _contextOptions = DbContextShared.CreateContextOptions();

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                _themeId1       = Guid.NewGuid();
                _themeId2       = Guid.NewGuid();
                _deletedThemeId = Guid.NewGuid();

                context.Themes.AddRange
                (
                    new ThemeDbEntity
                {
                    Id          = _themeId1,
                    Name        = "Name 1",
                    Description = "Description 1",
                    Folder      = "Folder 1",
                    Status      = ThemeStatus.Active
                },
                    new ThemeDbEntity
                {
                    Id          = _themeId2,
                    Name        = "Name 2",
                    Description = "Description 2",
                    Folder      = "Folder 2",
                    Status      = ThemeStatus.Active
                },
                    new ThemeDbEntity
                {
                    Id     = _deletedThemeId,
                    Status = ThemeStatus.Deleted
                }
                );

                context.SaveChanges();
            }
        }
コード例 #10
0
        public void SetUp()
        {
            _contextOptions = DbContextShared.CreateContextOptions();

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                _siteId1       = Guid.NewGuid();
                _siteId2       = Guid.NewGuid();
                _deletedSiteId = Guid.NewGuid();

                context.Sites.AddRange(
                    new SiteDbEntity
                {
                    Id     = _siteId1,
                    Name   = "Name 1",
                    Title  = "Title 1",
                    Url    = "Url 1",
                    Status = SiteStatus.Active
                },
                    new SiteDbEntity
                {
                    Id     = _siteId2,
                    Name   = "Name 2",
                    Title  = "Title 2",
                    Url    = "Url 2",
                    Status = SiteStatus.Active
                },
                    new SiteDbEntity
                {
                    Id     = _deletedSiteId,
                    Status = SiteStatus.Deleted
                }
                    );

                context.SaveChanges();
            }
        }
コード例 #11
0
        public void Setup()
        {
            _contextOptions = DbContextShared.CreateContextOptions();

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                _siteId     = Guid.NewGuid();
                _languageId = Guid.NewGuid();

                context.Languages.AddRange(
                    new Language
                {
                    SiteId      = _siteId,
                    Id          = _languageId,
                    Name        = "Language Name 1",
                    CultureName = "ab1",
                    Url         = "ab1",
                    Status      = LanguageStatus.Active
                }
                    );

                context.SaveChanges();
            }
        }
コード例 #12
0
        public bool Add(DeviceLog device)
        {
            _context.DeviceLogs.Add(device);

            return(_context.SaveChanges() > 0);
        }
コード例 #13
0
        public void SetUp()
        {
            _contextOptions = DbContextShared.CreateContextOptions();

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                _siteId        = Guid.NewGuid();
                _menuId1       = Guid.NewGuid();
                _menuId2       = Guid.NewGuid();
                _menuItemId1   = Guid.NewGuid();
                _menuItemId2   = Guid.NewGuid();
                _language1     = Guid.NewGuid();
                _deletedMenuId = Guid.NewGuid();

                context.Menus.AddRange(
                    new MenuDbEntity
                {
                    SiteId    = _siteId,
                    Id        = _menuId1,
                    Name      = "Menu 1",
                    Status    = MenuStatus.Active,
                    MenuItems = new List <MenuItemDbEntity>
                    {
                        new MenuItemDbEntity
                        {
                            MenuId = _menuId1,
                            Id     = _menuItemId1,
                            Text   = "Menu Item 1",
                            Status = MenuItemStatus.Active,
                            MenuItemLocalisations = new List <MenuItemLocalisationDbEntity>
                            {
                                new MenuItemLocalisationDbEntity
                                {
                                    MenuItemId = _menuItemId1,
                                    LanguageId = _language1,
                                    Text       = "Menu Item 1 Localisation 1"
                                },
                                new MenuItemLocalisationDbEntity
                                {
                                    MenuItemId = _menuItemId1,
                                    LanguageId = Guid.NewGuid(),
                                    Text       = "Menu Item 1 Localisation 2"
                                }
                            }
                        },
                        new MenuItemDbEntity
                        {
                            MenuId = _menuId1,
                            Id     = _menuItemId2,
                            Text   = "Menu Item 2",
                            Status = MenuItemStatus.Deleted
                        }
                    }
                },
                    new MenuDbEntity
                {
                    SiteId = _siteId,
                    Id     = _menuId2,
                    Name   = "Menu 2",
                    Status = MenuStatus.Active
                },
                    new MenuDbEntity
                {
                    Id     = _deletedMenuId,
                    Status = MenuStatus.Deleted
                }
                    );

                context.SaveChanges();
            }
        }
コード例 #14
0
        public void SetUp()
        {
            _contextOptions = DbContextShared.CreateContextOptions();

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                _siteId        = Guid.NewGuid();
                _pageId1       = Guid.NewGuid();
                _pageId2       = Guid.NewGuid();
                _moduleId1     = Guid.NewGuid();
                _pageModuleId1 = Guid.NewGuid();
                _languageId1   = Guid.NewGuid();
                _deletedPageId = Guid.NewGuid();

                context.Pages.AddRange(
                    new PageDbEntity
                {
                    SiteId      = _siteId,
                    Id          = _pageId1,
                    Name        = "Name 1",
                    Url         = "Url 1",
                    Status      = PageStatus.Active,
                    PageModules = new List <PageModuleDbEntity>
                    {
                        new PageModuleDbEntity
                        {
                            PageId   = _pageId1,
                            ModuleId = _moduleId1,
                            Id       = _pageModuleId1,
                            Title    = "Title 1",
                            Status   = PageModuleStatus.Active,
                            PageModuleLocalisations = new List <PageModuleLocalisationDbEntity>
                            {
                                new PageModuleLocalisationDbEntity
                                {
                                    PageModuleId = _pageModuleId1,
                                    LanguageId   = _languageId1
                                },
                                new PageModuleLocalisationDbEntity
                                {
                                    PageModuleId = _pageModuleId1,
                                    LanguageId   = Guid.NewGuid()
                                }
                            }
                        },
                        new PageModuleDbEntity
                        {
                            PageId   = _pageId1,
                            ModuleId = Guid.NewGuid(),
                            Id       = Guid.NewGuid(),
                            Title    = "Title 2",
                            Status   = PageModuleStatus.Deleted
                        }
                    },
                    PageLocalisations = new List <PageLocalisation>
                    {
                        new PageLocalisation
                        {
                            PageId     = _pageId1,
                            LanguageId = _languageId1,
                            Url        = "localised-url-1"
                        }
                    }
                },
                    new PageDbEntity
                {
                    SiteId = _siteId,
                    Id     = _pageId2,
                    Name   = "Name 2",
                    Url    = "Url 2",
                    Status = PageStatus.Active
                },
                    new PageDbEntity
                {
                    Id     = _deletedPageId,
                    Status = PageStatus.Deleted
                }
                    );

                context.SaveChanges();
            }
        }