public void CleanupTest()
        {
            this.TestNewsContext.Database.ExecuteSqlCommand("TRUNCATE TABLE NewsStories");

            this.TestNewsContext.SaveChanges();

            this.TestNewsContext = null;

            this.testNewsStories = null;
        }
        public void InitTest()
        {
            this.TestNewsContext = new TestDBContext();

            this.testNewsStories = new List<NewsStory>()
            {
                new NewsStory() {Title = "TestNewsStory1", Content = "TestNewsStory1", PublishDate = DateTime.Now},
                new NewsStory()
                {
                    Title = "TestNewsStory2",
                    Content = "TestNewsStory2",
                    PublishDate = DateTime.Now.AddDays(-6)
                },
                new NewsStory()
                {
                    Title = "TestNewsStory3",
                    Content = "TestNewsStory3",
                    PublishDate = DateTime.Now.AddDays(-2)
                }
            };

            foreach (NewsStory newsStory in this.testNewsStories)
            {
                this.TestNewsContext.News.Add(newsStory);
            }

            this.TestNewsContext.SaveChanges();
        }
Пример #3
0
        public void TestDBContext_Controller_Delete_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    TestDBContextController testDBContextController = new TestDBContextController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(testDBContextController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, testDBContextController.DatabaseType);

                    TestDBContext testDBContextLast = new TestDBContext();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseType))
                    {
                        Query query = new Query();
                        query.Language = LanguageRequest;
                        query.Asc      = "";
                        query.Desc     = "";

                        TestDBContextService testDBContextService = new TestDBContextService(query, db, ContactID);
                        testDBContextLast = (from c in db.TestDBContexts select c).FirstOrDefault();
                    }

                    // ok with TestDBContext info
                    IHttpActionResult jsonRet = testDBContextController.GetTestDBContextWithID(testDBContextLast.TestDBContextID);
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <TestDBContext> Ret = jsonRet as OkNegotiatedContentResult <TestDBContext>;
                    TestDBContext testDBContextRet = Ret.Content;
                    Assert.AreEqual(testDBContextLast.TestDBContextID, testDBContextRet.TestDBContextID);

                    BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest);

                    // Post to return newly added TestDBContext
                    testDBContextRet.TestDBContextID           = 0;
                    testDBContextController.Request            = new System.Net.Http.HttpRequestMessage();
                    testDBContextController.Request.RequestUri = new System.Uri("http://localhost:5000/api/testDBContext");
                    IHttpActionResult jsonRet3 = testDBContextController.Post(testDBContextRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet3);

                    CreatedNegotiatedContentResult <TestDBContext> testDBContextRet3 = jsonRet3 as CreatedNegotiatedContentResult <TestDBContext>;
                    Assert.IsNotNull(testDBContextRet3);
                    TestDBContext testDBContext = testDBContextRet3.Content;

                    BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest3);

                    // Delete to return success
                    IHttpActionResult jsonRet2 = testDBContextController.Delete(testDBContextRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet2);

                    OkNegotiatedContentResult <TestDBContext> testDBContextRet2 = jsonRet2 as OkNegotiatedContentResult <TestDBContext>;
                    Assert.IsNotNull(testDBContextRet2);

                    BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult;
                    Assert.IsNull(badRequest2);

                    // Delete to return CSSPError because TestDBContextID of 0 does not exist
                    testDBContextRet.TestDBContextID = 0;
                    IHttpActionResult jsonRet4 = testDBContextController.Delete(testDBContextRet, LanguageRequest.ToString());
                    Assert.IsNotNull(jsonRet4);

                    OkNegotiatedContentResult <TestDBContext> testDBContextRet4 = jsonRet4 as OkNegotiatedContentResult <TestDBContext>;
                    Assert.IsNull(testDBContextRet4);

                    BadRequestErrorMessageResult badRequest4 = jsonRet4 as BadRequestErrorMessageResult;
                    Assert.IsNotNull(badRequest4);
                }
            }
        }
Пример #4
0
 public ArticleService(TestDBContext context) : base(context)
 {
     _context = context;
 }
Пример #5
0
 public QuestionsController(TestDBContext context)
 {
     this.context = context;
 }
 public TestSuiteRepository(TestDBContext context)
 {
     _context = context;
 }
Пример #7
0
 public Repository(TestDBContext context)
 {
     this.context = context;
     entities     = context.Set <T>();
 }
 public UserDetailsController(TestDBContext context)
 {
     _context = context;
 }
 public ObjectsWithManualExpandingController(TestDBContext database)
 {
     this.objectRepository = new ObjectRepository(database);
 }
Пример #10
0
 public GenericService(TestDBContext context)
 {
     _context = context;
     _dbSet   = _context.Set <T>();
 }
Пример #11
0
 public HomeController(TestDBContext db)
 {
     _dbContext = db;
 }
Пример #12
0
 public DataRepository(TestDBContext _db)
 {
     db = _db;
 }
Пример #13
0
 public void Initialize()
 {
     db          = new TestDBContext();
     unitOfWork  = new UnitOfWork(db);
     userService = new UserService(unitOfWork);
 }
Пример #14
0
 public ObjectRepository(TestDBContext database)
 {
     this.database = database;
 }
Пример #15
0
 public PostController(ILogger <PostController> logger, TestDBContext testDBContext)
 {
     _testDBContext = testDBContext;
     _logger        = logger;
 }
Пример #16
0
 public CategoryService(TestDBContext context) : base(context)
 {
     _context = context;
 }
Пример #17
0
 public RegController(TestDBContext context)
 {
     _context = context;
 }
        public ScheduleInfoesController(SchedulerDbContext context, ILogger <HomeController> logger, ISchedulerFactory schedulerFactory, IOptions <BASE_PATHS> settings, TestDBContext testDBContext)
        {
            _context          = context;
            JobCenter.Manager = new ScheduleManager(_context);

            _logger           = logger;
            _schedulerFactory = schedulerFactory;

            _BASE_PATHS         = settings.Value;
            TaskJob.BASE_PATH   = _BASE_PATHS.MedicalHealth;
            TaskJobS1.BASE_PATH = _BASE_PATHS.MedicalHealthS1;
            TaskJobSY.BASE_PATH = _BASE_PATHS.MedicalHealthSY;

            var users = testDBContext.Users.Where(a => a.Id < 10).ToList();

            foreach (var item in users)
            {
                Console.Write(item.Id.ToString() + ", " + item.DisplayName);
                Console.WriteLine();
            }
            User addone = new User()
            {
                DisplayName  = "Admin",
                CreationDate = DateTime.Now,
                DownVotes    = 100,
                UpVotes      = 1000
            };

            testDBContext.Users.Add(addone);
            testDBContext.SaveChanges();//自增主键在插入成功后,会自动赋值过去
            var delone = testDBContext.Users.FirstOrDefault(a => a.Id == addone.Id);

            if (delone != null)
            {
                testDBContext.Users.Remove(delone);
                testDBContext.SaveChanges();//本身就是一个事务
            }
        }
 public CommonRepository(TestDBContext ObjContext)
 {
     _ObjContext = ObjContext;
 }
Пример #20
0
 public CategoriesController(TestDBContext context, ICategoryService categoryService)
 {
     _context         = context;
     _categoryService = categoryService;
 }
Пример #21
0
        public object findWsInfo()
        {
            StuInfoDBContext stuContext  = new StuInfoDBContext();
            TestDBContext    testContext = new TestDBContext();
            var wsList            = testContext.T_WS.Where(t => t.IsValid != 0).OrderByDescending(o => new { o.City, o.WSCompany, o.goLiveDate }).ToList();
            var implementItemList = testContext.T_ImplementPersonnel.Where(t => t.IsValid != 0).ToList();
            var statusItemList    = testContext.T_Status.Where(t => 1 == 1).ToList();

            foreach (var item in wsList)
            {
                var implementItem1 = implementItemList.Where(t => t.T_Id == item.Personnel1).FirstOrDefault();
                var implementItem2 = implementItemList.Where(t => t.T_Id == item.Personnel2).FirstOrDefault();
                var statusItem     = statusItemList.Where(t => t.Id == item.status).FirstOrDefault();

                item.Personnel1Name   = implementItem1 == null ? "" : implementItem1.T_Name;
                item.Personnel1Email  = implementItem1 == null ? "" : implementItem1.T_Email;
                item.Personnel1Mobile = implementItem1 == null ? "" : implementItem1.T_Mobile;
                item.Personnel2Name   = implementItem2 == null ? "" : implementItem2.T_Name;
                item.Personnel2Email  = implementItem2 == null ? "" : implementItem2.T_Email;
                item.Personnel2Mobile = implementItem2 == null ? "" : implementItem2.T_Mobile;
                item.statusName       = statusItem == null ? "" : statusItem.name;
                item.sszStatus        = item.researchBeginDate.Value.CompareTo(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) <= 0 && item.goLiveDate.Value.CompareTo(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) > 0 ? 1 : 0;
                item.ysxStatus        = item.goLiveDate.Value.CompareTo(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) <= 0 ? 1 : 0;
                item.wsxStatus        = item.goLiveDate.Value.CompareTo(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) > 0 ? 1 : 0;
                item.planStatus       = 1;
                ////获取工作日
                //if(DateTime.Now.ToString("yyyy-MM")== item.goLiveDate.Value.ToString("yyyy-MM"))
                //{
                //    string str1 = DateTime.Now.ToString("yyyy-MM-dd");
                //    string str2 = item.goLiveDate.Value.ToString("yyyy-MM-dd");
                //    DateTime d1 = Convert.ToDateTime(str1);
                //    DateTime d2 = Convert.ToDateTime(str2);
                //    DateTime d3 = Convert.ToDateTime(string.Format("{0}-{1}-{2}", d1.Year, d1.Month, d1.Day));
                //    DateTime d4 = Convert.ToDateTime(string.Format("{0}-{1}-{2}", d2.Year, d2.Month, d2.Day));
                //    int days = (d3 - d4).Days;
                //    item.gzrCount = days;
                //}else
                //{
                //    item.gzrCount = 30;
                //}
            }

            var sszWsNumber  = wsList.Where(t => t.researchBeginDate.Value.CompareTo(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) <= 0 && t.goLiveDate.Value.CompareTo(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) > 0).Count();
            var ysxWsNumber  = wsList.Where(t => t.goLiveDate.Value.CompareTo(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) <= 0).Count();
            var wsxWsNumber  = wsList.Where(t => t.goLiveDate.Value.CompareTo(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) > 0).Count();
            var planWsNumber = wsList.Count();

            //获取正式库销量数据
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"
                            select 
                            a.WSID,
                            b.WSName,
                            (select count(0) from Bas_Customer where isnull(isvalid,1)=1 and wsid=a.wsid) as custCount,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}01'then CONVERT(char(10),a.OrderDate,120) end) as xsCount1,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}02'then CONVERT(char(10),a.OrderDate,120) end) as xsCount2,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}03'then CONVERT(char(10),a.OrderDate,120) end) as xsCount3,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}04'then CONVERT(char(10),a.OrderDate,120) end) as xsCount4,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}05'then CONVERT(char(10),a.OrderDate,120) end) as xsCount5,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}06'then CONVERT(char(10),a.OrderDate,120) end) as xsCount6,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}07'then CONVERT(char(10),a.OrderDate,120) end) as xsCount7,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}08'then CONVERT(char(10),a.OrderDate,120) end) as xsCount8,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}09'then CONVERT(char(10),a.OrderDate,120) end) as xsCount9,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}10'then CONVERT(char(10),a.OrderDate,120) end) as xsCount10,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}11'then CONVERT(char(10),a.OrderDate,120) end) as xsCount11,
                            count(distinct case when convert(varchar(6),a.OrderDate,112)='{1}12'then CONVERT(char(10),a.OrderDate,120) end) as xsCount12
                            from SFA_Order_Header a 
                            left join Bas_WS b 
                            on a.WSID=b.WSID and isnull(b.isvalid,1)=1 
                            where a.OrderType='51' and  (a.status=3 or a.status=4) and a.wsid in ({0}) 
                            group by a.WSID,b.WSName
                           ");
            List <string> list = new List <string>();

            foreach (var item in wsList)
            {
                list.Add(item.WSID);
            }
            var    whereStr   = string.Join(",", list.ToArray());
            string str        = String.Format(strSql.ToString(), whereStr.ToString(), DateTime.Now.ToString("yyyy"));
            var    wsinfoTemp = stuContext.Database.SqlQuery <T_WS>(str).ToList();

            foreach (var item in wsList)
            {
                var wsItem = wsinfoTemp.Where(w => w.WSID == item.WSID).FirstOrDefault();
                if (wsItem != null)
                {
                    item.WSName        = wsItem.WSName;
                    item.custCount     = wsItem.custCount;
                    item.xsCount1Name  = wsItem.xsCount1 == 0 || item.goLiveDate.Value.Month > 1 ? "-" : wsItem.xsCount1.ToString() + " / " + getDays(item.goLiveDate, 1);
                    item.xsCount2Name  = wsItem.xsCount2 == 0 || item.goLiveDate.Value.Month > 2 ? "-" : wsItem.xsCount2.ToString() + " / " + getDays(item.goLiveDate, 2);
                    item.xsCount3Name  = wsItem.xsCount3 == 0 || item.goLiveDate.Value.Month > 3 ? "-" : wsItem.xsCount3.ToString() + " / " + getDays(item.goLiveDate, 3);
                    item.xsCount4Name  = wsItem.xsCount4 == 0 || item.goLiveDate.Value.Month > 4 ? "-" : wsItem.xsCount4.ToString() + " / " + getDays(item.goLiveDate, 4);
                    item.xsCount5Name  = wsItem.xsCount5 == 0 || item.goLiveDate.Value.Month > 5 ? "-" : wsItem.xsCount5.ToString() + " / " + getDays(item.goLiveDate, 5);
                    item.xsCount6Name  = wsItem.xsCount6 == 0 || item.goLiveDate.Value.Month > 6 ? "-" : wsItem.xsCount6.ToString() + " / " + getDays(item.goLiveDate, 6);
                    item.xsCount7Name  = wsItem.xsCount7 == 0 || item.goLiveDate.Value.Month > 7 ? "-" : wsItem.xsCount7.ToString() + " / " + getDays(item.goLiveDate, 7);
                    item.xsCount8Name  = wsItem.xsCount8 == 0 || item.goLiveDate.Value.Month > 8 ? "-" : wsItem.xsCount8.ToString() + " / " + getDays(item.goLiveDate, 8);
                    item.xsCount9Name  = wsItem.xsCount9 == 0 || item.goLiveDate.Value.Month > 9 ? "-" : wsItem.xsCount9.ToString() + " / " + getDays(item.goLiveDate, 9);
                    item.xsCount10Name = wsItem.xsCount10 == 0 || item.goLiveDate.Value.Month > 10 ? "-" : wsItem.xsCount10.ToString() + " / " + getDays(item.goLiveDate, 10);
                    item.xsCount11Name = wsItem.xsCount11 == 0 || item.goLiveDate.Value.Month > 11 ? "-" : wsItem.xsCount11.ToString() + " / " + getDays(item.goLiveDate, 11);
                    item.xsCount12Name = wsItem.xsCount12 == 0 || item.goLiveDate.Value.Month > 12 ? "-" : wsItem.xsCount12.ToString() + " / " + getDays(item.goLiveDate, 12);
                }
            }

            var obj = new { rows = wsList, sszWsNumber = sszWsNumber, ysxWsNumber = ysxWsNumber, wsxWsNumber = wsxWsNumber, planWsNumber = planWsNumber };

            return(Json(obj));
        }
Пример #22
0
 public HomeController(TestDBContext context)
 {
     db = context;
 }
Пример #23
0
 public MoviesController(TestDBContext context)
 {
     _context = context;
 }
Пример #24
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="mapper"></param>
 /// <param name="testDB"></param>
 /// <param name="encryptUtil"></param>
 public UserSvc(IMapper mapper, TestDBContext testDB, IEncryptUtil encryptUtil) : base(mapper, testDB)
 {
     _encryptUtil = encryptUtil;
 }
Пример #25
0
 public ArticleTypeSvc(TestDBContext testDB, IDbContextExtendSvc dbContextExtendSvc) : base(testDB)
 {
     _dbContextExtendSvc = dbContextExtendSvc;
 }
Пример #26
0
 public UsersController(TestDBContext context)
 {
     this.context = context;
 }
Пример #27
0
 public RepositoryBase(TestDBContext context)
 {
     this.context = context;
 }
Пример #28
0
 public AppUserService(TestDBContext context) : base(context)
 {
     _context = context;
 }
Пример #29
0
        public void TestDBContext_Controller_GetTestDBContextList_Test()
        {
            foreach (LanguageEnum LanguageRequest in AllowableLanguages)
            {
                foreach (int ContactID in new List <int>()
                {
                    AdminContactID
                })                                                             //, TestEmailValidatedContactID, TestEmailNotValidatedContactID })
                {
                    TestDBContextController testDBContextController = new TestDBContextController(DatabaseTypeEnum.SqlServerTestDB);
                    Assert.IsNotNull(testDBContextController);
                    Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, testDBContextController.DatabaseType);

                    TestDBContext testDBContextFirst = new TestDBContext();
                    int           count = -1;
                    Query         query = new Query();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                    {
                        TestDBContextService testDBContextService = new TestDBContextService(query, db, ContactID);
                        testDBContextFirst = (from c in db.TestDBContexts select c).FirstOrDefault();
                        count = (from c in db.TestDBContexts select c).Count();
                        count = (query.Take > count ? count : query.Take);
                    }

                    // ok with TestDBContext info
                    IHttpActionResult jsonRet = testDBContextController.GetTestDBContextList();
                    Assert.IsNotNull(jsonRet);

                    OkNegotiatedContentResult <List <TestDBContext> > ret = jsonRet as OkNegotiatedContentResult <List <TestDBContext> >;
                    Assert.AreEqual(testDBContextFirst.TestDBContextID, ret.Content[0].TestDBContextID);
                    Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count);

                    List <TestDBContext> testDBContextList = new List <TestDBContext>();
                    count = -1;
                    query = new Query();
                    using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB))
                    {
                        TestDBContextService testDBContextService = new TestDBContextService(query, db, ContactID);
                        testDBContextList = (from c in db.TestDBContexts select c).OrderBy(c => c.TestDBContextID).Skip(0).Take(2).ToList();
                        count             = (from c in db.TestDBContexts select c).Count();
                    }

                    if (count > 0)
                    {
                        query.Skip = 0;
                        query.Take = 5;
                        count      = (query.Take > count ? query.Take : count);

                        // ok with TestDBContext info
                        jsonRet = testDBContextController.GetTestDBContextList(query.Language.ToString(), query.Skip, query.Take);
                        Assert.IsNotNull(jsonRet);

                        ret = jsonRet as OkNegotiatedContentResult <List <TestDBContext> >;
                        Assert.AreEqual(testDBContextList[0].TestDBContextID, ret.Content[0].TestDBContextID);
                        Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count);

                        if (count > 1)
                        {
                            query.Skip = 1;
                            query.Take = 5;
                            count      = (query.Take > count ? query.Take : count);

                            // ok with TestDBContext info
                            IHttpActionResult jsonRet2 = testDBContextController.GetTestDBContextList(query.Language.ToString(), query.Skip, query.Take);
                            Assert.IsNotNull(jsonRet2);

                            OkNegotiatedContentResult <List <TestDBContext> > ret2 = jsonRet2 as OkNegotiatedContentResult <List <TestDBContext> >;
                            Assert.AreEqual(testDBContextList[1].TestDBContextID, ret2.Content[0].TestDBContextID);
                            Assert.AreEqual((count > query.Take ? query.Take : count), ret2.Content.Count);
                        }
                    }
                }
            }
        }
 public WorksiteController(TestDBContext context)
 {
     _context = context;
 }
 public SessionAttendeesController(TestDBContext context)
 {
     _context = context;
 }
Пример #32
0
 public ValuesController(TestDBContext context)
 {
     _context = context;
 }