public ActionResult Index()
        {
            VolunteerContext volunteerContext = new VolunteerContext();
            List <Volunteer> volunteers       = volunteerContext.Volunteers.ToList();

            return(View(volunteers));
        }
        public ActionResult Details(int Id)
        {
            VolunteerContext volunteerContext = new VolunteerContext();
            Volunteer        volunteer        = volunteerContext.Volunteers.Single(vol => vol.Id == Id);

            return(View(volunteer));
        }
        public ActionResult Edit(Volunteer volunteer)
        {
            VolunteerContext volunteerContext = new VolunteerContext();

            volunteerContext.Entry(volunteer).State = System.Data.Entity.EntityState.Modified;
            volunteerContext.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(Volunteer volunteer)
        {
            VolunteerContext volunteerContext = new VolunteerContext();

            volunteerContext.Volunteers.Add(volunteer);
            volunteerContext.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int Id)
        {
            VolunteerContext volunteerContext = new VolunteerContext();
            Volunteer        volunteer        = volunteerContext.Volunteers.Single(vol => vol.Id == Id);

            volunteerContext.Volunteers.Remove(volunteer);
            volunteerContext.SaveChanges();

            return(RedirectToAction("Index"));
        }
예제 #6
0
        public JwtProvider(RequestDelegate next, VolunteerContext db, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager)
        {
            _next = next;

            this.db       = db;
            UserManager   = userManager;
            SignInManager = signInManager;

            //Configure JWT Token settings
            TokenExpiration    = TimeSpan.FromMinutes(10);
            SigningCredentials =
                new SigningCredentials(SecurityKey, SecurityAlgorithms.HmacSha256);
        }
예제 #7
0
        public void Adding_a_project()
        {
            using (VolunteerContext context = new VolunteerContext())
            {
                Project project = new Project();
                project.Name = "test";
                project.Description = " some decription ";
                project.State = ProjectState.Open;

                context.Projects.Add(project);

                context.SaveChanges();
            }
        }
예제 #8
0
        public void Adding_a_project()
        {
            using (VolunteerContext context = new VolunteerContext())
            {
                Project project = new Project();
                project.Name        = "test";
                project.Description = " some decription ";
                project.State       = ProjectState.Open;

                context.Projects.Add(project);

                context.SaveChanges();
            }
        }
예제 #9
0
        private void InitializeContext()
        {
            //This is a 'Global' Arrange.
            var builder = new DbContextOptionsBuilder <VolunteerContext>()
                          .UseInMemoryDatabase();

            var context = new VolunteerContext(builder.Options);

            var listings = Enumerable.Range(1, 10)
                           .Select(i => new Listing {
                Id = i, EventName = $"Outreach{i}", ProducerName = "United"
            });

            context.Listings.AddRange(listings);

            int changed = context.SaveChanges();

            Db = context;
        }
 public ListingsController(VolunteerContext context)
 {
     this.db = context;
 }
예제 #11
0
파일: UnitOfWork.cs 프로젝트: azori3/DotVal
 public UnitOfWork(IDatabaseFactory dbFactory)
 {
     this.dbFactory = dbFactory;
     dataContext    = dbFactory.DataContext;
 }
 public UserController(VolunteerContext context)
 {
     _context    = context;
     _controller = "Home";
     _action     = "AllEvents";
 }
예제 #13
0
 public DatabaseFactory()
 {
     dataContext = new VolunteerContext();
 }
 public DetailsController(VolunteerContext context)
 {
     _context    = context;
     _controller = "User";
     _action     = "Login";
 }
예제 #15
0
 public VolunteerCrudController(VolunteerContext context)
 {
     _context = context;
 }
예제 #16
0
 public CreateController(VolunteerContext context)
 {
     _context    = context;
     _controller = "User";
     _action     = "Login";
 }
예제 #17
0
 public MyAccountController(VolunteerContext context)
 {
     this.db = context;
 }