public UniqueRouteNumberAttribute(string routeId)
        {
            var context = new TrainBookingContext();
            _routeLogic = new RouteLogic(new RouteRepository(context));

            RouteId = routeId;
        }
        public NotRepeatWayStationAttribute(string routeId)
        {
            RouteId = routeId;
            var context = new TrainBookingContext();

            _routeLogic = new RouteLogic(new RouteRepository(context));
        }
            public SimpleMembershipInitializer()
            {
                //Database.SetInitializer<UsersContext>(null);
                Database.SetInitializer<TrainBookingContext>(null);

                try
                {
                    using (var context = new TrainBookingContext())
                    {
                        if (!context.Database.Exists())
                        {
                            // Create the SimpleMembership database without Entity Framework migration schema
                            ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                        }
                    }

                    WebSecurity.InitializeDatabaseConnection("TrainBookingContext", "User", "UserId", "UserName",
                        autoCreateTables: true);

                    if (!_roles.RoleExists("Admin"))
                    {
                        _roles.CreateRole("Admin");
                    }
                    if (!_roles.RoleExists("User"))
                    {
                        _roles.CreateRole("User");
                    }

                    if (_membership.GetUser("admin1", false) == null)
                    {
                        WebSecurity.CreateUserAndAccount("admin1", "123456",
                            new
                            {
                                FirstName = "admin",
                                MidName = "admin",
                                LastName = "admin",
                                BirthDate = 01 / 01 / 1985
                            });
                        _roles.AddUsersToRoles(new[] { "admin1" }, new[] { "Admin" });
                    }

                    if (_membership.GetUser("user", false) == null)
                    {
                        WebSecurity.CreateUserAndAccount("user", "123456",
                            new
                            {
                                FirstName = "user",
                                MidName = "user",
                                LastName = "user",
                                BirthDate = 01 / 01 / 1985
                            });
                        _roles.AddUsersToRoles(new[] { "user" }, new[] { "User" });
                    }
                }
                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 StationRouteController()
        {
            var context = new TrainBookingContext();

            _stationRouteLogic = new StationRouteLogic(new StationRouteRepository(context));
            _routeLogic = new RouteLogic(new RouteRepository(context));
            _stationLogic = new StationLogic(new StationRepository(context));
        }
        public CorrectDepatureDateAttribute(string routeId, string depatureDateTime)
        {
            RouteId = routeId;
            DepatureDateTime = depatureDateTime;

            var context = new TrainBookingContext();

            _routeLogic = new RouteLogic(new RouteRepository(context));
        }
        public CorrectArrivalDateAttribute(string routeId, string arrivalDateTime)
        {
            RouteId = routeId;
            ArrivalDateTime = arrivalDateTime;

            var context = new TrainBookingContext();

            _routeLogic = new RouteLogic(new RouteRepository(context));
        }
示例#7
0
        //git commit
        public RouteController()
        {
            var context = new TrainBookingContext();

            _routeLogic = new RouteLogic(new RouteRepository(context));
            _stationLogic = new StationLogic(new StationRepository(context));
            _stationRouteLogic = new StationRouteLogic(new StationRouteRepository(context));
            _wagonTypeLogic = new WagonTypeLogic(new WagonTypeRepository(context));
            _ticketLogic = new TicketLogic(new TicketRepository(context));
        }
示例#8
0
 public StationRepository(TrainBookingContext context)
     : base(context)
 {
 }
        public WagonTypeController()
        {
            var context = new TrainBookingContext();

            _wagonTypeLogic = new WagonTypeLogic(new WagonTypeRepository(context));
        }
示例#10
0
 public RouteRepository(TrainBookingContext context)
     : base(context)
 {
 }
示例#11
0
 public Repository(TrainBookingContext context)
 {
     db = context;
 }
示例#12
0
        public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl)
        {
            string provider = null;
            string providerUserId = null;

            if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId))
            {
                return RedirectToAction("Manage");
            }

            if (ModelState.IsValid)
            {
                using (TrainBookingContext db = new TrainBookingContext())
                {
                    User user = db.User.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower());
                    // Check if user already exists
                    if (user == null)
                    {
                        // Insert name into the profile table
                        db.User.Add(new User { UserName = model.UserName });
                        db.SaveChanges();

                        OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
                        OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false);

                        return RedirectToLocal(returnUrl);
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name.");
                    }
                }
            }

            ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName;
            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }
 public UniqueStationAttribute(string lastStation)
 {
     LastStation = lastStation;
     var context = new TrainBookingContext();
     _stationLogic = new StationLogic(new StationRepository(context));
 }
示例#14
0
 public TicketRepository(TrainBookingContext context)
     : base(context)
 {
 }
示例#15
0
 public UserRepository(TrainBookingContext context)
     : base(context)
 {
 }
示例#16
0
 public WagonTypeRepository(TrainBookingContext context)
     : base(context)
 {
 }