// Post: Events/Details/5
        public async Task <IActionResult> Detailsubmit(int?id, int?userId = 1)
        {
            if (id == null || userId == null)
            {
                return(NotFound());
            }

            var @event = await _context.Events
                         .Include(e => e.Category)
                         .FirstOrDefaultAsync(m => m.Id == id);

            if (@event == null)
            {
                return(NotFound());
            }

            var @userInEvent = new UserInEvent
            {
                EventId      = Convert.ToInt32(id),
                UserId       = Convert.ToInt32(userId),
                IsApproved   = true,
                EventBarcode = Guid.NewGuid().ToString()
            };

            _context.Add(@userInEvent);
            await _context.SaveChangesAsync();

            int userEventid = @userInEvent.Id;

            return(RedirectToAction("ThankYou", new { id = userEventid }));
        }
Exemplo n.º 2
0
        public void EnsureSeedData()
        {
            _context.Database.EnsureCreated();

            if (!_context.Customers.Any())
            {
                _context.Customers.RemoveRange(_context.Customers);
                _context.SaveChanges();

                Customer customer = new Customer();
                customer.FirstName = "Dimitar";
                customer.LastName  = "Ivanov";
                customer.Age       = 35;

                Customer customer_2 = new Customer();
                customer_2.FirstName = "Alexander";
                customer_2.LastName  = "Yanev";
                customer_2.Age       = 31;

                _context.Add(customer);
                _context.Add(customer_2);

                _context.SaveChanges();
            }
        }
Exemplo n.º 3
0
        public void Diff()
        {
            var dbContextOptionsBuilder = new DbContextOptionsBuilder <CustomDbContext>()
                                          .UseInMemoryDatabase("in-memory-db");

            using var dbContext = new CustomDbContext(dbContextOptionsBuilder.Options);

            var person           = new Person(new PersonName("First", "M", "Last", "First M Last"));
            var permissionType   = new PermissionType(new PermissionTypeData("example permission", 1));
            var personPermission = new PersonPermission(person.Id, permissionType.Id);

            dbContext.Add(person);
            dbContext.Add(personPermission);
            dbContext.Add(permissionType);
            dbContext.SaveChanges();

            var result1 = dbContext.PersonPermissions.Where(e => e.Id == personPermission.Id).Select(MapFromDomain1).FirstOrDefault();
            var result2 = dbContext.PersonPermissions.Where(e => e.Id == personPermission.Id).Select(MapFromDomain2).FirstOrDefault();

            //Fails
            Assert.Equal(result1.PersonFirstName, result2.PersonFirstName);         // result2.PersonFirstName == "First M Last"
            Assert.Equal(result1.PersonLastName, result2.PersonLastName);           // result2.PersonFirstName == "M"
            Assert.Equal(result1.PersonMiddleInitial, result2.PersonMiddleInitial); // result2.PersonFirstName == null
            Assert.Equal(result1.PersonFullName, result2.PersonFullName);           // result2.PersonFirstName == "Last"
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Details,supportType")] request_support request_support)
        {
            if (ModelState.IsValid)
            {
                _context.Add(request_support);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Thankyou)));
            }
            return(View(request_support));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,Details")] Note note)
        {
            if (ModelState.IsValid)
            {
                _context.Add(note);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Thankyou)));
            }
            return(View(note));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,Title,Details,DepartmentId")] Complaint complaint)
        {
            if (ModelState.IsValid)
            {
                _context.Add(complaint);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Thankyou)));
            }
            //ViewData["DepartmentId"] = new SelectList(_context.Departments, "Id", "Id", complaint.DepartmentId);
            ViewData["DepartmentId"] = _context.Departments.Select(c => new SelectListItem
            {
                Text  = c.NameEN,
                Value = Convert.ToString(c.Id)
            });
            return(View(complaint));
        }
Exemplo n.º 7
0
 public void Add(T entity)
 {
     _db.Add(entity);
 }