コード例 #1
0
ファイル: ShippingHandler.cs プロジェクト: karthicktv/Blog
        public void Handle(IOrderAcceptedEvent message)
        {
            MusicStoreEntities storeDB = new MusicStoreEntities();

            var order = storeDB.Orders.Single(o => o.OrderId == message.OrderId);

            var shipNote = new ShippingNote
            {
                FirstName  = order.FirstName,
                LastName   = order.LastName,
                Address    = order.Address,
                City       = order.City,
                State      = order.State,
                PostalCode = order.PostalCode
            };

            foreach (var detail in order.OrderDetails)
            {
                var inventoryPosition = storeDB.InventoryPositions.Single(p => p.Album.AlbumId == detail.AlbumId);

                if (inventoryPosition.BalanceOnHand >= detail.Quantity)
                {
                    inventoryPosition.BalanceOnHand -= detail.Quantity;
                    shipNote.ShippedQuantity        += detail.Quantity;
                }
                else
                {
                    shipNote.BackOrderQuantity = detail.Quantity - shipNote.ShippedQuantity;
                }
            }

            storeDB.AddToShippingNotes(shipNote);

            storeDB.SaveChanges();
        }
コード例 #2
0
    void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext)


    {
        // TODO: Add your acction filter's tasks here

        // Log Action Filter Call
        MusicStoreEntities storeDB = new MusicStoreEntities();

        ActionLog log = new ActionLog()
        {
            Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
            Action     = filterContext.ActionDescriptor.ActionName + " (Logged By: Custom 
    
    Action Filter)",
            IP         = filterContext.HttpContext.Request.UserHostAddress,
            DateTime   = filterContext.HttpContext.Timestamp
        };

        storeDB.ActionLogs.Add(log);
        storeDB.SaveChanges();

        this.OnActionExecuting(filterContext);
    }
}
コード例 #3
0
        // GET: StoreManage
        public ActionResult Index()
        {
            SampleData sample = new SampleData();

            objMusicStore = sample.Seed();
            return(View(objMusicStore));
        }
コード例 #4
0
ファイル: OrderService.cs プロジェクト: sebastiandymel/SEDY
 public Task <List <OrderDetail> > GetNotOrderedCDs(MusicStoreEntities _storeContext)
 {
     return(_storeContext
            .OrderDetails
            .Where(a => a.ShipmentId == null && a.Order.Status == OrderStatus.New)
            .ToListAsync());
 }
コード例 #5
0
        protected override void Initialize(HttpControllerContext controllerContext)
        {
            base.Initialize(controllerContext);

            MusicStoreEntities storeDB = new MusicStoreEntities();

            DomainManager = new MusicStoreDomainManager <GenreDto, Genre>(storeDB, controllerContext.Request);
        }
コード例 #6
0
 private void ReCreateDatabaseForTesting()
 {
     Database.SetInitializer(new DatabaseSeedingInitializer());
     using (var context = new MusicStoreEntities())
     {
         context.Database.Initialize(true);
     }
 }
コード例 #7
0
        public ActionResult Details(int id)
        {
            Album      album  = new Album();
            SampleData sample = new SampleData();

            storeDB = sample.Seed();
            album   = storeDB.GetAlbums().Find(x => x.AlbumId == id);
            return(View(album));
        }
コード例 #8
0
        // GET: Store
        public ActionResult Index()
        {
            SampleData sample = new SampleData();

            storeDB = sample.Seed();
            var genres = storeDB.GetGenres().ToList();

            return(View(genres));
        }
コード例 #9
0
        private void SetValue(bool toggleValue)
        {
            MusicStoreEntities db = new MusicStoreEntities();
            var featureToggle     = db.FeatureToggles.FindAsync(_id).Result;

            featureToggle.Enabled         = toggleValue;
            db.Entry(featureToggle).State = EntityState.Modified;
            db.SaveChangesAsync();
        }
コード例 #10
0
        private async Task MigrateShoppingCart(string userName)
        {
            using (var storeContext = new MusicStoreEntities())
            {
                var cart = ShoppingCart.GetCart(storeContext, this);
                await cart.MigrateCart(userName);

                Session[ShoppingCart.CartSessionKey] = userName;
            }
        }
コード例 #11
0
 public AccountController(
     SignInManager <ApplicationUser> _signInManager,
     ILogger <AccountController> _logger,
     MusicStoreEntities _storeDB
     )
 {
     signInManager = _signInManager;
     logger        = _logger;
     storeDB       = _storeDB;
 }
コード例 #12
0
        // GET: StoreManage/Details/5
        public ActionResult Details(int id)
        {
            SampleData sample = new SampleData();

            objMusicStore = sample.Seed();
            Album AlbumDetails = new Album();

            AlbumDetails = objMusicStore.GetAlbums().Find(x => x.AlbumId == id);
            return(View(AlbumDetails));
        }
コード例 #13
0
        protected void Session_Start()
        {
            // Clean up Logs Table
            MusicStoreEntities storeDB = new MusicStoreEntities();

            foreach (var log in storeDB.ActionLogs.ToList())
            {
                storeDB.ActionLogs.Remove(log);
            }

            storeDB.SaveChanges();
        }
コード例 #14
0
        protected void Application_Start()
        {
            MusicStoreEntities db = new MusicStoreEntities();
            var genres            = db.Genres.ToList();

            #region Simple MemberShip Adimlari
            #endregion
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
コード例 #15
0
        private void MigrateShoppingCart(string UserName)
        {
            var storeDb = new MusicStoreEntities();

            // Associate shopping cart items with logged-in user
            var cart = ShoppingCart.GetCart(storeDb, this.HttpContext);

            cart.MigrateCart(UserName);
            storeDb.SaveChanges();

            Session[ShoppingCart.CartSessionKey] = UserName;
        }
コード例 #16
0
ファイル: Startup.App.cs プロジェクト: evgen10/LoginMon
        public void ConfigureApp(IAppBuilder app)
        {
            using (var context = new MusicStoreEntities())
            {
                context.Database.Delete();
                context.Database.Create();

                new SampleData().Seed(context);
            }

            CreateAdminUser().Wait();
        }
コード例 #17
0
        private async Task MigrateShoppingCart(string userName)
        {
            logger.Debug("Entered into MigrateShoppingCart method");

            using (var storeContext = new MusicStoreEntities())
            {
                var cart = ShoppingCart.GetCart(storeContext, this);

                await cart.MigrateCart(userName);

                Session[ShoppingCart.CartSessionKey] = userName;
            }
        }
コード例 #18
0
        // GET: Store
        public ActionResult Index()
        {
            //var genres = new List<Genre>
            //{
            //    new Genre { Name = "Disco"},
            //    new Genre { Name = "Jazz"},
            //    new Genre { Name = "Rock"}
            //};
            MusicStoreEntities dbStore = new MusicStoreEntities();
            var genres = dbStore.Genres.ToList();

            return(View(genres));
        }
コード例 #19
0
ファイル: AddToCartHandler.cs プロジェクト: karthicktv/Blog
        public void Handle(IAddToCartCommand message)
        {
            MusicStoreEntities storeDB = new MusicStoreEntities();

            // Retrieve the album from the database
            var addedAlbum = storeDB.Albums
                             .Single(album => album.AlbumId == message.AlbumId);

            // Add it to the shopping cart
            var cart = new ShoppingCart(message.CartId);

            cart.AddToCart(addedAlbum);
        }
コード例 #20
0
        protected void Application_Start()
        {
            MusicStoreEntities db = new MusicStoreEntities();

            db.Genres.ToList();


            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            //Bundle ı elle ekleme işlemi
            //Bu işlem için using e web.optimization ekleniyor ve app_start ekleniyor.
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
コード例 #21
0
        public void Handle()
        {
            ReCreateDatabaseForTesting();

            using (var context = new MusicStoreEntities())
            {
                var handler = new ChangeTaskStatusCommandHandler(new EntityRepository <Task>(context));

                var command = _fixture.Create <ChangeTaskStatusCommand>();

                handler.Handle(command);
            }
        }
コード例 #22
0
 public void ConfigureApp(IAppBuilder app)
 {
     using (var context = new MusicStoreEntities())
     {
         //This is the original code, works fine on localdb but not a real-world scenario to deploy your db
         //on every app start
         //Currently the deployment template creates a db and sources the data from a bacpac so none of this is needed
         //context.Database.Delete();
         //context.Database.Create();
         //new SampleData().Seed(context);
     }
     //remove this for the demo so no one has unexpected admin access to the test app
     //uncomment and update web.config if you need to use the admin features, they aren't needed for the demo
     //CreateAdminUser().Wait();
 }
コード例 #23
0
 public override IEnumerable <DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
 {
     using (var storeDB = new MusicStoreEntities())
     {
         // Create a node for each album
         foreach (var album in storeDB.Albums.Include("Genre"))
         {
             DynamicNode dynamicNode = new DynamicNode();
             dynamicNode.Title     = album.Title;
             dynamicNode.ParentKey = "Genre_" + album.Genre.Name;
             dynamicNode.RouteValues.Add("id", album.AlbumId);
             yield return(dynamicNode);
         }
     }
 }
コード例 #24
0
        //
        // GET: /Store/Browse
        public ActionResult Browse(string genre)
        {
            List <Album> genreModel = new List <Album>();

            try
            {
                SampleData sample = new SampleData();
                storeDB    = sample.Seed();
                genreModel = storeDB.GetAlbums().FindAll(x => x.Genre.Name == genre);
                return(View(genreModel));
            }
            catch (Exception ex)
            {
            }
            return(View(genreModel));
        }
コード例 #25
0
        protected void Application_Start()
        {
            MusicStoreEntities db = new MusicStoreEntities();
            var genres            = db.Genres.ToList();



            #region Simple Membership Adimlari
            //1.WebMatrix.Data ve WebMatrix.WebData 2. verisyonlarini ekleme(copy local=true)
            //2.Yoksa connection stringi olusturma
            //3.appsettingse simplemembership olusturma icin gerekli degeri ekleme
            //4.Membership provideri duzenleme
            //5.RoleManageri duzenleme(enabled=true)
            //6.Tablolarin veritabaninda olusturulmasi icin kod ile tetikleme islemi
            #endregion

            if (!WebSecurity.Initialized)
            {
                WebSecurity.InitializeDatabaseConnection("MusicStoreCon", "UserDetails", "Id", "UserName", autoCreateTables: true);

                if (!WebSecurity.UserExists(ConfigurationManager.AppSettings["DefaultAdminName"]))
                {
                    WebSecurity.CreateUserAndAccount(ConfigurationManager.AppSettings["DefaultAdminName"], ConfigurationManager.AppSettings["DefaultAdminPassword"], new
                    {
                        FirstName   = ConfigurationManager.AppSettings["DefaultAdminName"],
                        Email       = "*****@*****.**",
                        BirthDate   = DateTime.Now,
                        Phone       = "3534554",
                        IsLocked    = false,
                        IsDeleted   = false,
                        CreatedDate = DateTime.Now
                    });
                    if (!Roles.RoleExists("admin"))
                    {
                        Roles.CreateRole("admin");
                    }
                    Roles.AddUserToRole(ConfigurationManager.AppSettings["DefaultAdminName"], "admin");
                }
            }

            AreaRegistration.RegisterAllAreas();
            ViewEngines.Engines.Add(new MyViewEngine());
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
コード例 #26
0
        public void ConfigureApp(IAppBuilder app)
        {
            using (var context = new MusicStoreEntities())
            {
                context.Database.Delete();
                context.Database.Create();

                new SampleData().Seed(context);
            }

            CreateAdminUser().Wait();

            var kernel = new StandardKernel();

            kernel.Bind <ILogger>().ToConstant(LogManager.GetCurrentClassLogger());
            DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));
        }
コード例 #27
0
ファイル: Startup.App.cs プロジェクト: sebastiandymel/SEDY
        public async Task ConfigureApp(IAppBuilder app)
        {
            using (var context = new MusicStoreEntities())
            {
                context.Database.Delete();
                context.Database.Create();

                new SampleData().Seed(context);
            }
            using (var context = new ApplicationDbContext())
            {
                context.Database.Delete();
                context.Database.Create();
            }

            await CreateAdminUser();
        }
コード例 #28
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            MusicStoreEntities storeDB = new MusicStoreEntities();

            ActionLog log = new ActionLog()
            {
                Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
                Action     = filterContext.ActionDescriptor.ActionName,
                IP         = filterContext.HttpContext.Request.UserHostAddress,
                DateTime   = filterContext.HttpContext.Timestamp
            };

            storeDB.ActionLogs.Add(log);
            storeDB.SaveChanges();

            base.OnActionExecuting(filterContext);
        }
コード例 #29
0
        public void ConfigureApp(IAppBuilder app)
        {
            var logger = new LoggerConfiguration()
                         .ReadFrom.AppSettings()
                         .CreateLogger();

            Log.Logger = logger;

            using (var context = new MusicStoreEntities())
            {
                context.Database.Delete();
                context.Database.Create();

                new SampleData().Seed(context);
            }

            CreateAdminUser().Wait();
        }
コード例 #30
0
            public SimpleMembershipInitializer()
            {
                Database.SetInitializer(new MigrateDatabaseToLatestVersion <MusicStoreEntities, SampleData>());

                try
                {
                    using (var context = new MusicStoreEntities())
                    {
                        context.Database.Initialize(true);
                    }

                    WebSecurity.InitializeDatabaseConnection("MusicStoreEntities", "UserProfile", "UserId", "UserName", autoCreateTables: true);
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
                }
            }
        public IEnumerable<ISiteMapNodeToParentRelation> GetSiteMapNodes(ISiteMapNodeHelper helper)
        {
            // Try the API! Let us know if there is something we can do to make it better.

            // This is a replacement for all of the DynamicNodeProvider implementations within
            // the MvcMusicStore demo, to show how this could be done. Note that in a real-world scenario
            // you would need to remove all of the DynamicNodeProvider declarations in the SemanticSiteMapNodeProvider
            // because they would be completely unnecessary.

            // Be sure to try adding nodes yourself to see if you can suggest ways to make this
            // more intuitive, easier to read, or easier to write.

            using (var storeDB = new MusicStoreEntities())
            {
                // Create a node for each genre
                foreach (var genre in storeDB.Genres)
                {
                    // This is the original dynamic node definition

                    //DynamicNode dynamicNode = new DynamicNode("Genre_" + genre.Name, genre.Name);
                    //dynamicNode.RouteValues.Add("genre", genre.Name);

                    //yield return dynamicNode;

                    // This is the fluent API version.

                    // Note that because there is no inheritance when we do it this way, we are specifying controller and action here, too.

                    yield return helper.RegisterNode()
                        .MatchingRoute(x => x.WithController("Store").WithAction("Browse").AlwaysMatchingKey("browse").WithValue("genre", genre.Name))
                        .WithDisplayValues(x => x.WithTitle(genre.Name))
                        .WithKey("Genre_" + genre.Name)
                        .Single();
                }

                // Create a node for each album
                foreach (var album in storeDB.Albums.Include("Genre"))
                {
                    // This is the original dynamic node definition

                    //DynamicNode dynamicNode = new DynamicNode();
                    //dynamicNode.Title = album.Title;
                    //dynamicNode.ParentKey = "Genre_" + album.Genre.Name;
                    //dynamicNode.RouteValues.Add("id", album.AlbumId);

                    //if (album.Title.Contains("Hit") || album.Title.Contains("Best"))
                    //{
                    //    dynamicNode.Attributes.Add("bling", "<span style=\"color: Red;\">hot!</span>");
                    //}

                    //yield return dynamicNode;

                    // This is the fluent API version.

                    // Note that because there is no inheritance when we do it this way, we are specifying controller and action here, too.

                    var customAttributes = new Dictionary<string, object>();
                    if (album.Title.Contains("Hit") || album.Title.Contains("Best"))
                    {
                        customAttributes.Add("bling", "<span style=\"color: Red;\">hot!</span>");
                    }

                    yield return helper.RegisterNode()
                        .MatchingRoute(x => x.WithController("Store").WithAction("Details").WithValue("id", album.AlbumId))
                        .WithDisplayValues(x => x.WithTitle(album.Title))
                        .WithParentKey("Genre_" + album.Genre.Name)
                        .WithCustomAttributes(customAttributes)
                        .Single();
                }
            }
        }