示例#1
0
        // GET: InviteeTables/Create
        public async Task <int> RunAlgo()
        {
            if (!isDataValid())
            {
                throw new Exception(" ");
            }

            result = algo.RunAlgo(AlgoDbCreation()).getGens().ToList();

            EventOption eventOption = new EventOption(GetEventByID(MyGlobals.GlobalEventID));

            foreach (var item in result)
            {
                InviteeTable inviteeTable = new InviteeTable(item.invitee, item.table, eventOption, GetEventByID(MyGlobals.GlobalEventID));
                var          result       = _context.Add(inviteeTable);
            }

            var result2 = await _context.SaveChangesAsync();

            ViewData["EventId"]       = new SelectList(_context.Event, "Id", "Name");
            ViewData["EventOptionId"] = new SelectList(_context.EventOption, "Id", "Id");
            ViewData["InviteeId"]     = new SelectList(_context.Invitee, "Id", "FirstName");
            ViewData["TableId"]       = new SelectList(_context.Table, "Id", "Id");
            ViewData["CurrentEvent"]  = MyGlobals.GlobalEventName;

            return(eventOption.Id);
        }
示例#2
0
        public async Task <IActionResult> fromCsv(IList <IFormFile> files)
        {
            using (System.IO.StreamWriter outputFile = new System.IO.StreamWriter(@"csv\inv_tmp.csv"))
            {
                using (var reader = new System.IO.StreamReader(files[0].OpenReadStream()))
                {
                    while (reader.Peek() >= 0)
                    {
                        outputFile.WriteLine(reader.ReadLine());
                    }
                }
            }

            Csv             csv = new Csv();
            Category        cat;
            var             result             = csv.read(@"csv\inv_tmp.csv");
            List <Category> list_of_categories = new List <Category>();

            foreach (var invitee in result)
            {
                var  firstName     = invitee.Item1;
                var  lastName      = invitee.Item2;
                int  numShouldCome = invitee.Item3;
                var  phoneNumber   = invitee.Item4;
                var  address       = invitee.Item5;
                int  numIsComing   = invitee.Item6;
                var  category      = invitee.Item7;
                bool new_cat       = true;

                cat = GetCategoryByName(category);
                Category tmpCat = new Category(category, GetEventByID(MyGlobals.GlobalEventID));
                if (cat == null)
                {
                    foreach (Category existCat in list_of_categories)
                    {
                        if ((existCat.Name == tmpCat.Name) && (existCat.Event.Id == tmpCat.Event.Id))
                        {
                            cat = existCat;
                            break;
                        }
                    }
                    if (cat == null)
                    {
                        cat = tmpCat;
                        list_of_categories.Add(cat);
                    }
                    _context.Add(cat);
                }

                //await _context.SaveChangesAsync();


                Invitee inv = new Invitee(firstName, lastName, phoneNumber, address, numIsComing, GetEventByID(MyGlobals.GlobalEventID), cat);
                _context.Add(inv);
            }
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Invitees"));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,Name,Date")] Event @event)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@event);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(@event));
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("Id,EventId,isFavorite")] EventOption eventOption)
        {
            if (ModelState.IsValid)
            {
                _context.Add(eventOption);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"] = new SelectList(_context.Event, "Id", "Name", eventOption.EventId);
            return(View(eventOption));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("Id,CapacityOfPeople,MinCapacityOfPeople,TableType,EventId")] Table table)
        {
            table.EventId = MyGlobals.GlobalEventID;
            if (ModelState.IsValid)
            {
                _context.Add(table);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"] = new SelectList(_context.Event, "Id", "Name", table.EventId);
            return(View(table));
        }
        public async Task <IActionResult> Create([Bind("Id,MainInviteeId,SecondaryInviteeId,IsSittingTogether,EventId,EventOptionId")] PersonalRestriction personalRestriction)
        {
            personalRestriction.EventId = MyGlobals.GlobalEventID;
            if (ModelState.IsValid)
            {
                _context.Add(personalRestriction);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"]            = new SelectList(_context.Event, "Id", "Name", personalRestriction.EventId);
            ViewData["MainInviteeId"]      = new SelectList(_context.Invitee.OrderBy(x => x.FullName), "Id", "FullName", personalRestriction.MainInviteeId);
            ViewData["SecondaryInviteeId"] = new SelectList(_context.Invitee.OrderBy(x => x.FullName), "Id", "FullName", personalRestriction.SecondaryInviteeId);
            return(View(personalRestriction));
        }
示例#7
0
 public async Task <IActionResult> Create([Bind("Id,Name,EventId")] Category category)
 {
     category.EventId = MyGlobals.GlobalEventID;
     if (ModelState.IsValid)
     {
         if (!CategoryExists(category.Name))
         {
             _context.Add(category);
             await _context.SaveChangesAsync();
         }
         //return RedirectToAction(nameof(Index))
         return(RedirectToAction("Index", "Invitees"));
     }
     //ViewData["EventId"] = new SelectList(_context.Event.OrderBy(x => x.Name), "Id", "Name", category.EventId);
     return(View(category));
 }
示例#8
0
        public async Task <IActionResult> Create([Bind("Id,InviteeId,TableType,IsSittingAtTable,EventId,EventOptionId")] AccessibilityRestriction accessibilityRestriction)
        {
            accessibilityRestriction.EventId = MyGlobals.GlobalEventID;
            if (ModelState.IsValid)
            {
                _context.Add(accessibilityRestriction);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"]   = new SelectList(_context.Event.OrderBy(x => x.Name), "Id", "Name", accessibilityRestriction.EventId);
            ViewData["InviteeId"] = new SelectList(_context.Invitee.Where(t => t.EventId == MyGlobals.GlobalEventID).
                                                   OrderBy(x => x.FullName), "Id", "FullName", accessibilityRestriction.InviteeId);

            return(View(accessibilityRestriction));
        }