Exemplo n.º 1
0
 public PersonController(IHostingEnvironment hostingEnvironment)
 {
     _hostingEnvironment = hostingEnvironment;
     personService       = new PersonService();
     userService         = new UserService();
     detailService       = new DetailService();
 }
Exemplo n.º 2
0
        public bool Put(DetailService detail)
        {
            try
            {
                var _detail = db.DetailServices.Where(a => a.BookingID == detail.BookingID && a.ServiceID == detail.ServiceID).FirstOrDefault <DetailService>();
                if (_detail != null)
                {
                    _detail.BookingID = detail.BookingID;
                    _detail.ServiceID = detail.ServiceID;
                    _detail.Quantity  = detail.Quantity;
                    _detail.Total     = detail.Total;
                    _detail.Status    = detail.Status;


                    db.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public void TestDetail_Get_Post()
        {
            IDetailService <BloggingContext, Post> detailService = new DetailService <BloggingContext, Post>(this._context);
            var result = detailService.Get <PostDto>(1);

            Assert.Equal(1, result.Result.PostId);
            Assert.Null(result.Result.NumberOfBlogsBelongTo);
        }
Exemplo n.º 4
0
 // GET: Detail
 public ActionResult Index(int id)
 {
     //khởi tạo service
     detailService = new DetailImplement();
     //gán giá trị cho ViewModel
     detailViewModel.product = detailService.GetProductByID(id);
     //gửi ViewModel ra View
     return(View(detailViewModel));
 }
Exemplo n.º 5
0
        public void TestDetail_Blog_Check_CanCall_Reference()
        {
            IDetailService <BloggingContext, Blog> detailService = new DetailService <BloggingContext, Blog>(this._context);
            var result = detailService.Get <BlogDto>(1);

            Assert.True(result.IsValid);
            Assert.Equal("Dummy Blog #1", result.Result.Name);
            Assert.Equal("John Doe", result.Result.Author.Name);
            Assert.Equal(1, result.Result.Tags.Count);
            Assert.Equal(1, result.Result.Tags.First().BlogId2);
            Assert.Null(result.Result.Posts.First().NumberOfBlogsBelongTo);
        }
Exemplo n.º 6
0
        public void TestDetail_Blog()
        {
            IDetailService <BloggingContext, Blog> detailService = new DetailService <BloggingContext, Blog>(this._context);
            var result = detailService.Get <BlogDto>(2);

            Assert.True(result.IsValid);
            Assert.Equal("Dummy Blog #2", result.Result.Name);
            Assert.Equal("http://google.com", result.Result.Url);
            Assert.Equal(2, result.Result.Posts.Count());
            Assert.Equal(2, result.Result.NumberOfPosts);
            Assert.Equal(3, result.Result.PostIds[0]);
            Assert.Equal(4, result.Result.PostIds[1]);
        }
Exemplo n.º 7
0
        public void Check01ReferenceOk()
        {
            //SETUP

            //ATTEMPT
            ICreateService <Post, SimplePostDto> createService = new CreateService <Post, SimplePostDto>(null);
            IDetailService <Post, SimplePostDto> detailService = new DetailService <Post, SimplePostDto>(null);
            IListService <Post, SimplePostDto>   listService   = new ListService <Post, SimplePostDto>(null);
            IUpdateService <Post, SimplePostDto> updateService = new UpdateService <Post, SimplePostDto>(null);

            //VERIFY
            (listService is IListService <Post, SimplePostDto>).ShouldEqual(true);
        }
Exemplo n.º 8
0
 public bool Delete(DetailService detail)
 {
     try
     {
         db.DetailServices.Remove(detail);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 9
0
        public void Check01DirectReferenceOk()
        {
            //SETUP

            //ATTEMPT
            ICreateService <Post> createService = new CreateService <Post>(null);
            IDetailService <Post> detailService = new DetailService <Post>(null);
            IListService <Post>   listService   = new ListService <Post>(null);
            IUpdateService <Post> updateService = new UpdateService <Post>(null);

            //VERIFY
            (listService is IListService <Post>).ShouldEqual(true);
        }
        /// <summary>
        /// 删除一个明细
        /// </summary>
        /// <param name="id">明细id</param>
        /// <returns></returns>
        public bool Delete(string id)
        {
            bool result = DetailService.Remove(id);

            if (!result)
            {
                throw new Exception("删除明细失败");
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 11
0
 public bool Post(DetailService detail)
 {
     try
     {
         db.DetailServices.Add(detail);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public void Check01ReferencesOk()
        {

            //SETUP    

            //ATTEMPT
            ICreateService<Post, DetailPostDto> createService = new CreateService<Post, DetailPostDto>(null);
            IDetailService<Post, DetailPostDto> detailService = new DetailService<Post, DetailPostDto>(null);
            IListService<Post, DetailPostDto> listService = new ListService<Post, DetailPostDto>(null);
            IUpdateService<Post, DetailPostDto> updateService = new UpdateService<Post, DetailPostDto>(null);

            //VERIFY
            (listService is ListService<Post, DetailPostDto>).ShouldEqual(true);
        }
        public void Test01DirectReferenceOk()
        {

            //SETUP    

            //ATTEMPT
            ICreateService<Post> createService = new CreateService<Post>(null);
            IDetailService<Post> detailService = new DetailService<Post>(null);
            IListService<Post> listService = new ListService<Post>(null);
            IUpdateService<Post> updateService = new UpdateService<Post>(null);

            //VERIFY
            (listService is IListService<Post>).ShouldEqual(true);
        }
Exemplo n.º 14
0
        public void Test02AddressDetailViaServiceOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service = new DetailService(db);
                var customerWithAddresses = db.Customers.Include(x => x.CustomerAddresses).First(x => x.CustomerAddresses.Count > 1);

                //ATTEMPT
                var status = service.GetDetail <CrudCustomerAddressDto>(customerWithAddresses.CustomerID, customerWithAddresses.CustomerAddresses.First().AddressID);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.Result.Address.ShouldNotEqualNull();
            }
        }
        public void Test02AddressDetailViaServiceOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service = new DetailService(db);
                var customerWithAddresses = db.Customers.Include( x => x.CustomerAddresses).First(x => x.CustomerAddresses.Count > 1);

                //ATTEMPT
                var status = service.GetDetail<CrudCustomerAddressDto>(customerWithAddresses.CustomerID, customerWithAddresses.CustomerAddresses.First().AddressID);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.Result.Address.ShouldNotEqualNull();
            }
        }
        public void Check01DetailFlowOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service  = new DetailService <Tag, SimpleTagDto>(db);
                var firstTag = db.Tags.First();

                //ATTEMPT
                var status = service.GetDetailUsingWhere(x => x.TagId == firstTag.TagId);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.Result.FunctionsCalledCommaDelimited.ShouldEqual("DetailDtoFromDataIn");
            }
        }
        public void Test05DetailSalesOrderViaServiceOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service          = new DetailService(db);
                var firstOrderHeader = db.SalesOrderHeaders.First();

                //ATTEMPT
                var status = service.GetDetail <CrudSalesOrderDto>(firstOrderHeader.SalesOrderID);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.Result.SalesOrderDetails.Count().ShouldBeGreaterThan(0);
            }
        }
        public void Check01DetailFlowOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DetailService<Tag, SimpleTagDto>(db);
                var firstTag = db.Tags.First();

                //ATTEMPT
                var status = service.GetDetailUsingWhere(x => x.TagId == firstTag.TagId);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.Result.FunctionsCalledCommaDelimited.ShouldEqual("DetailDtoFromDataIn");
            }
        }
Exemplo n.º 19
0
        public void Check06DetailComputedFailDelegateDecompilerTurnedOff()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                GenericServicesConfig.UseDelegateDecompilerWhereNeeded = false;
                var service   = new DetailService <Post, DelegateDecompilePostDto>(db);
                var firstPost = db.Posts.Include(x => x.Tags).First();

                //ATTEMPT
                var ex = Assert.Throws <NotSupportedException>(() => service.GetDetail(firstPost.PostId));

                //VERIFY
                ex.Message.ShouldEqual("The specified type member 'BloggerNameAndEmail' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.");
            }
        }
        public void Test11DetailCrudCustomersViaServiceAddressOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service            = new DetailService(db);
                var customerWithOrders = db.Customers.First(x => x.CustomerAddresses.Any());

                //ATTEMPT
                var status = service.GetDetail <CrudCustomerDto>(customerWithOrders.CustomerID);

                //VERIFY
                status.ShouldBeValid();
                status.Result.CustomerAddresses.Count().ShouldBeGreaterThan(0);
            }
        }
        public void Test05DetailSalesOrderViaServiceOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service = new DetailService(db);
                var firstOrderHeader = db.SalesOrderHeaders.First();

                //ATTEMPT
                var status = service.GetDetail<CrudSalesOrderDto>(firstOrderHeader.SalesOrderID);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.Result.SalesOrderDetails.Count().ShouldBeGreaterThan(0);
            }
        }
        public void Test10DetailCrudCustomersViaServiceHasSalesOrdersOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service            = new DetailService(db);
                var customerWithOrders = db.Customers.Include(x => x.SalesOrderHeaders).First(x => x.SalesOrderHeaders.Any());
                //db.Database.Log = Console.WriteLine;

                //ATTEMPT
                var status = service.GetDetail <CrudCustomerDto>(customerWithOrders.CustomerID);

                //VERIFY
                status.ShouldBeValid();
                status.Result.HasBoughtBefore.ShouldEqual(true);
            }
        }
Exemplo n.º 23
0
        public void Check04DetailDirectPostNotFoundBad()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DetailService <Post, SimplePostDto>(db);

                //ATTEMPT
                var status = service.GetDetail(0);

                //VERIFY
                status.IsValid.ShouldEqual(false, status.Errors);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEqual("We could not find an entry using that filter. Has it been deleted by someone else?");
                status.Result.ShouldNotEqualNull();
            }
        }
Exemplo n.º 24
0
        public void Check03DetailDirectPostWhereOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service   = new DetailService <Post>(db);
                var firstPost = db.Posts.First();

                //ATTEMPT
                var status = service.GetDetailUsingWhere(x => x.PostId == firstPost.PostId);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.Result.PostId.ShouldEqual(firstPost.PostId);
                status.Result.Title.ShouldEqual(firstPost.Title);
            }
        }
Exemplo n.º 25
0
        public void Check03DetailPostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service   = new DetailService(db);
                var firstPost = db.Posts.First();

                //ATTEMPT
                var status = service.GetDetail <Post>(firstPost.PostId);

                //VERIFY
                status.IsValid.ShouldEqual(true);
                status.Result.PostId.ShouldEqual(firstPost.PostId);
                status.Result.Title.ShouldEqual(firstPost.Title);
            }
        }
        /// <summary>
        /// 创建一个明细
        /// </summary>
        /// <param name="detail">(ignore:ID,AddDateTime,TagInfo,AccountName)</param>
        /// <returns></returns>
        public Detail Post(Detail detail)
        {
            var tag = TagService.Get(d => d.ID == detail.TagID);

            if (tag == null)
            {
                throw new Exception("TagID 不存在");
            }

            var account = AccountService.Get(a => a.ID == detail.AccountID);

            if (account == null)
            {
                throw new Exception("AccountID 不存在");
            }

            //将金额改为正数
            if (detail.Amount < 0)
            {
                detail.Amount = Math.Abs(detail.Amount);
            }

            var newDetail = new Detail()
            {
                AccountID   = account.ID,
                AccountName = account.AccountName,
                TagID       = tag.ID,
                TagInfo     = tag.TagInfo,
                Type        = detail.Type,
                Date        = detail.Date.Date,
                Amount      = detail.Amount,
                Note        = detail.Note
            };

            bool result = DetailService.Add(newDetail);

            if (!result)
            {
                throw new Exception("数据创建失败");
            }
            else
            {
                return(newDetail);
            }
        }
Exemplo n.º 27
0
        public async static Task <string> GetDetail(string code, DetailService detailService, IConfiguration _configuration)
        {
            string returnValue = string.Empty;

            switch (detailService)
            {
            case DetailService.Category:
                ServiceCategories serviceCategories = new ServiceCategories(_configuration);

                var Category = await serviceCategories.GetCategory(int.Parse(code));

                returnValue = Category.CategoryName;

                break;

            case DetailService.Customer:
                ServiceCustomers serviceCustomers = new ServiceCustomers(_configuration);

                var Customer = await serviceCustomers.GetCustomer(code);

                returnValue = Customer.ContactName;

                break;

            case DetailService.Employee:
                ServiceEmployees serviceEmployees = new ServiceEmployees(_configuration);

                var Employee = await serviceEmployees.GetEmployee(int.Parse(code));

                returnValue = Employee.FirstName + ' ' + Employee.LastName;

                break;

            case DetailService.Region:
                ServiceRegion serviceRegion = new ServiceRegion(_configuration);

                var Region = await serviceRegion.GetRegion(int.Parse(code));

                returnValue = Region.RegionDescription;

                break;
            }
            return(returnValue);
        }
        public void Perf01DetailPostOk()
        {
            int postId;
            using (var db = new SampleWebAppDb())
                postId = db.Posts.Include(x => x.Tags).AsNoTracking().First().PostId;

            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DetailService<Post, SimplePostDto>(db);

                //ATTEMPT
                var status = service.GetDetailUsingWhere(x => x.PostId == postId);
                status.Result.LogSpecificName("End");

                //VERIFY
                foreach (var log in status.Result.LogOfCalls) { Console.WriteLine(log); }
            }
        }
        public void Check02DetailOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service    = new DetailService <PostTagGrade, SimplePostTagGradeDto>(db);
                var firstGrade = db.PostTagGrades.Include(x => x.TagPart).Include(x => x.PostPart).First();

                //ATTEMPT
                var status = service.GetDetailUsingWhere(x => x.PostId == firstGrade.PostId && x.TagId == firstGrade.TagId);
                status.Result.LogSpecificName("End");

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.Result.PostId.ShouldEqual(firstGrade.PostId);
                status.Result.TagPartName.ShouldEqual(firstGrade.TagPart.Name);
                status.Result.PostPartTitle.ShouldEqual(firstGrade.PostPart.Title);
            }
        }
Exemplo n.º 30
0
        static void Main(string[] args)
        {
            var connection = Connection.DetabaseConnection();

            ICarRepository    car    = new CarRepository(connection);
            IDetailRepository detail = new DetailRepository(connection);

            ICarService    carModel    = new CarService(car);
            IDetailService detailModel = new DetailService(detail);

            ICarController    carViewModel    = new CarController(carModel);
            IDetailController detailViewModel = new DetailController(detailModel);

            var detaildetail = detailViewModel.GetCar(3);

            var carCar = carViewModel.GetDetails(1);

            Console.ReadKey();
        }
Exemplo n.º 31
0
        public void Check02DetailPostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service   = new DetailService <Post, SimplePostDto>(db);
                var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First();

                //ATTEMPT
                var status = service.GetDetail(firstPost.PostId);
                status.Result.LogSpecificName("End");

                //VERIFY
                status.Result.PostId.ShouldEqual(firstPost.PostId);
                status.Result.BloggerName.ShouldEqual(firstPost.Blogger.Name);
                status.Result.Title.ShouldEqual(firstPost.Title);
                CollectionAssert.AreEqual(firstPost.Tags.Select(x => x.TagId), status.Result.Tags.Select(x => x.TagId));
            }
        }
Exemplo n.º 32
0
        //-----------------

        public static void UpdatePostGSelectDirect(this SampleWebAppDb db, int postId)
        {
            var setupService = new DetailService(db);
            var setupStatus  = setupService.GetDetail <Post>(postId);

            setupStatus.IsValid.ShouldEqual(true, setupStatus.Errors);

            var guidString = Guid.NewGuid().ToString("N");

            setupStatus.Result.Title   = guidString;
            setupStatus.Result.Content = guidString;
            setupStatus.Result.Tags    = new Collection <Tag> {
                db.Tags.First()
            };

            var service = new UpdateService(db);
            var status  = service.Update(setupStatus.Result);

            status.IsValid.ShouldEqual(true, status.Errors);
        }
Exemplo n.º 33
0
 //Chi tiết dich vu
 public static DetailService Detail_Service(int id)
 {
     using (var db = new MyDbDataContext())
     {
         Service service = db.Services.FirstOrDefault(a => a.ID == id && a.Status) ?? new Service();
         List <ServiceGallery> restaurantGalleries = db.ServiceGalleries.Where(a => a.ServiceID == service.ID).ToList();
         List <Service>        restaurants         = db.Services.Where(a => a.Status && a.ID != service.ID).OrderBy(a => a.Index).ToList();
         foreach (var item in restaurants)
         {
             item.MenuAlias = service.Alias;
         }
         DetailService detailRestaurant = new DetailService()
         {
             Service          = service,
             ServiceGalleries = restaurantGalleries,
             Services         = restaurants
         };
         return(detailRestaurant);
     }
 }
Exemplo n.º 34
0
        public void Check06DetailComputedOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                GenericServicesConfig.UseDelegateDecompilerWhereNeeded = true;
                var service   = new DetailService <Post, DelegateDecompilePostDto>(db);
                var firstPost = db.Posts.Include(x => x.Tags).First();

                //ATTEMPT
                var status = service.GetDetail(firstPost.PostId);

                //VERIFY
                status.ShouldBeValid();
                status.Result.Title.ShouldEqual(firstPost.Title);
                status.Result.BloggerNameAndEmail.ShouldEndWith("nospam.com)");
                status.Result.TagNames.ShouldNotEqualNull();
                CollectionAssert.AreEqual(firstPost.Tags.Select(x => x.Name), status.Result.TagNames);
            }
        }
        public void Check03DetailPostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service   = new DetailService <Post, DetailPostDto>(db);
                var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First();

                //ATTEMPT
                var status = service.GetDetailUsingWhere(x => x.PostId == firstPost.PostId);

                //VERIFY
                status.IsValid.ShouldEqual(true);
                status.Result.PostId.ShouldEqual(firstPost.PostId);
                status.Result.BlogId.ShouldEqual(firstPost.BlogId);
                status.Result.BloggerName.ShouldEqual(firstPost.Blogger.Name);
                status.Result.Title.ShouldEqual(firstPost.Title);
                status.Result.Content.ShouldEqual(firstPost.Content);
                CollectionAssert.AreEqual(firstPost.Tags.Select(x => x.TagId), status.Result.Tags.Select(x => x.TagId));
            }
        }
Exemplo n.º 36
0
        static void Main(string[] args)
        {
            IRepository <Car>    car    = new CarRepository();
            IRepository <Detail> detail = new DetailRepository();

            ICarService    carService    = new CarService(car);
            IDetailService detailService = new DetailService(detail);

            ICarController    carController    = new CarController(carService);
            IDetailController detailController = new DetailController(detailService);

            var allCars = carController.GetAll();

            var carDetails = carController.GetCarDetailsById(1);

            var detailCar = carController.GetDetailCar(1);

            var allDetails = detailController.GetAll();

            Console.ReadKey();
        }
        public void Test11DetailDirectPostWhereOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DetailService<Post>(db);
                var firstPost = db.Posts.First();

                //ATTEMPT
                var status = service.GetDetailUsingWhere(x => x.PostId == firstPost.PostId);

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.Result.PostId.ShouldEqual(firstPost.PostId);
                status.Result.Title.ShouldEqual(firstPost.Title);
            }
        }
        public void Check06DetailComputedFailDelegateDecompilerTurnedOff()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                GenericServicesConfig.UseDelegateDecompilerWhereNeeded = false;
                var service = new DetailService<Post, DelegateDecompilePostDto>(db);
                var firstPost = db.Posts.Include(x => x.Tags).First();

                //ATTEMPT
                var ex = Assert.Throws<NotSupportedException>( () => service.GetDetail(firstPost.PostId));

                //VERIFY
                ex.Message.ShouldEqual("The specified type member 'BloggerNameAndEmail' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.");
            }
        }
        public void Check06DetailComputedOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                GenericServicesConfig.UseDelegateDecompilerWhereNeeded = true;
                var service = new DetailService<Post, DelegateDecompilePostDto>(db);
                var firstPost = db.Posts.Include(x => x.Tags).First();

                //ATTEMPT
                var status = service.GetDetail(firstPost.PostId);

                //VERIFY
                status.ShouldBeValid();
                status.Result.Title.ShouldEqual(firstPost.Title);
                status.Result.BloggerNameAndEmail.ShouldEndWith("nospam.com)");
                status.Result.TagNames.ShouldNotEqualNull();
                CollectionAssert.AreEqual(firstPost.Tags.Select(x => x.Name), status.Result.TagNames);
            }
        }
        public void Check02DetailOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DetailService<PostTagGrade, SimplePostTagGradeDto>(db);
                var firstGrade = db.PostTagGrades.Include(x => x.TagPart).Include(x => x.PostPart).First();

                //ATTEMPT
                var status = service.GetDetailUsingWhere(x => x.PostId == firstGrade.PostId && x.TagId == firstGrade.TagId);
                status.Result.LogSpecificName("End");

                //VERIFY
                status.IsValid.ShouldEqual(true, status.Errors);
                status.Result.PostId.ShouldEqual(firstGrade.PostId);
                status.Result.TagPartName.ShouldEqual(firstGrade.TagPart.Name);
                status.Result.PostPartTitle.ShouldEqual(firstGrade.PostPart.Title);
            }
        }
        public void Test10DetailCrudCustomersViaServiceHasSalesOrdersOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service = new DetailService(db);
                var customerWithOrders = db.Customers.Include(x => x.SalesOrderHeaders).First(x => x.SalesOrderHeaders.Any());
                //db.Database.Log = Console.WriteLine;

                //ATTEMPT
                var status = service.GetDetail<CrudCustomerDto>(customerWithOrders.CustomerID);

                //VERIFY
                status.ShouldBeValid();
                status.Result.HasBoughtBefore.ShouldEqual(true);
            }
        }
        public void Test11DetailCrudCustomersViaServiceAddressOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service = new DetailService(db);
                var customerWithOrders = db.Customers.First(x => x.CustomerAddresses.Any());

                //ATTEMPT
                var status = service.GetDetail<CrudCustomerDto>(customerWithOrders.CustomerID);

                //VERIFY
                status.ShouldBeValid();
                status.Result.CustomerAddresses.Count().ShouldBeGreaterThan(0);
            }
        }
        public void Check04DetailDirectPostNotFoundBad()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DetailService<Post, SimplePostDto>(db);

                //ATTEMPT
                var status = service.GetDetail(0);

                //VERIFY
                status.IsValid.ShouldEqual(false, status.Errors);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEqual("We could not find an entry using that filter. Has it been deleted by someone else?");
                status.Result.ShouldNotEqualNull();
            }
        }
        public void Check02DetailPostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DetailService<Post, SimplePostDto>(db);
                var firstPost = db.Posts.Include(x => x.Tags).AsNoTracking().First();

                //ATTEMPT
                var status = service.GetDetail(firstPost.PostId);
                status.Result.LogSpecificName("End");

                //VERIFY
                status.Result.PostId.ShouldEqual(firstPost.PostId);
                status.Result.BloggerName.ShouldEqual(firstPost.Blogger.Name);
                status.Result.Title.ShouldEqual(firstPost.Title);
                CollectionAssert.AreEqual(firstPost.Tags.Select(x => x.TagId), status.Result.Tags.Select(x => x.TagId));
            }
        }
        public void Check03DetailPostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DetailService(db);
                var firstPost = db.Posts.First();

                //ATTEMPT
                var status = service.GetDetail<Post>(firstPost.PostId);

                //VERIFY
                status.IsValid.ShouldEqual(true);
                status.Result.PostId.ShouldEqual(firstPost.PostId);
                status.Result.Title.ShouldEqual(firstPost.Title);
            }
        }
        public void Test12EditLineItemCheckHeaderOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var newOrder = AddLineItem(db, 2);
                var detailStatus = new DetailService(db).GetDetail<CrudSalesOrderDetailDto>(newOrder.SalesOrderID, newOrder.SalesOrderDetailID);
                detailStatus.ShouldBeValid();
                var service = new UpdateService(db);

                //ATTEMPT
                detailStatus.Result.UnitPrice = 10000;
                detailStatus.Result.OrderQty = 10;
                var status = service.Update(detailStatus.Result);

                //VERIFY
                status.ShouldBeValid();
                db.SalesOrderDetails.Single(x => x.SalesOrderDetailID == newOrder.SalesOrderDetailID).UnitPrice.ShouldEqual(10000);
                CheckTotals(db);
            }
        }
        public void Check03DetailPostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new DetailService<Post, DetailPostDto>(db);
                var firstPost = db.Posts.Include( x => x.Tags).AsNoTracking().First();

                //ATTEMPT
                var status = service.GetDetailUsingWhere(x => x.PostId == firstPost.PostId);

                //VERIFY
                status.IsValid.ShouldEqual(true);
                status.Result.PostId.ShouldEqual(firstPost.PostId);
                status.Result.BlogId.ShouldEqual(firstPost.BlogId);
                status.Result.BloggerName.ShouldEqual(firstPost.Blogger.Name);
                status.Result.Title.ShouldEqual(firstPost.Title);
                status.Result.Content.ShouldEqual(firstPost.Content);
                CollectionAssert.AreEqual(firstPost.Tags.Select(x => x.TagId), status.Result.Tags.Select(x => x.TagId));
            }
        }