Пример #1
0
        public async Task <IActionResult> Create(EventCreateViewModel newEvent)
        {
            ViewData["StaffId"] = new SelectList(_context.Student.Where(s => s.InternalRankId != 1), "Id", "FullName", newEvent.Event.StaffId);
            ViewData["Style"]   = new SelectList(_context.Style, "Id", "Name", newEvent.EventStyle);

            if (ModelState.IsValid)
            {
                _context.Add(newEvent.Event);

                foreach (int styleid in newEvent.EventStyle)
                {
                    EventStyle styleForEvent = new EventStyle
                    {
                        StyleId = styleid,
                        EventId = newEvent.Event.Id
                    };
                    _context.EventStyle.Add(styleForEvent);
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(newEvent));
        }
Пример #2
0
 public DroneEvent(int _length, int _transpose, EventStyle style)
 {
     length    = _length;
     transpose = _transpose;
     thisStyle = style;
     name      = "Drone_" + EventManager.EventIndex.ToString();
     thisType  = EventType.drone;
     MonoBehaviour.print("MADE A DRONE EVENT:" + name);
     int test = GeneratingAValue();
 }
Пример #3
0
 public MountainEvent(int _length, int _transpose, EventStyle style)
 {
     length    = _length;
     transpose = _transpose;
     thisStyle = style;
     name      = "Mountain_" + EventManager.EventIndex.ToString();
     thisType  = EventType.mountain;
     MonoBehaviour.print("MADE A MOUNTAIN EVENT:" + name);
     int test = GeneratingAValue();
 }
Пример #4
0
        public async Task <IActionResult> Edit(int id, EventCreateViewModel updateEvent)
        {
            if (id != updateEvent.Event.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    List <EventStyle> StyleList = _context.EventStyle.Where(e => e.EventId == id).ToList();
                    _context.Update(updateEvent.Event);

                    foreach (EventStyle item in StyleList)
                    {
                        _context.EventStyle.Remove(item);
                    }
                    foreach (int styleid in updateEvent.EventStyle)
                    {
                        EventStyle styleForEvent = new EventStyle
                        {
                            StyleId = styleid,
                            EventId = updateEvent.Event.Id
                        };
                        _context.EventStyle.Add(styleForEvent);
                    }

                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventExists(updateEvent.Event.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StaffId"] = new SelectList(_context.Student.Where(s => s.InternalRankId != 1), "Id", "FullName", updateEvent.Event.StaffId);
            ViewData["Style"]   = new SelectList(_context.Style, "Id", "Name", updateEvent.EventStyle);
            return(View(updateEvent));
        }
Пример #5
0
        public void SaveEventStyle_SaveNewEvent_ShouldSaveSuccessfully(string name, string description)
        {
            using (var scope = _iContainer.BeginLifetimeScope(AppContextType.UnitTest.ToString()))
            {
                _iEventStyleDal = scope.Resolve <IEventStyleDal>();

                var currency = new EventStyle
                {
                    Name        = name,
                    Description = description
                };

                var currencyResult = _iEventStyleDal.SaveEventStyle(currency);

                Assert.True(currencyResult != null);
            }
        }