public ActionResult DeleteConfirmed(int id)
        {
            ClubEvent clubEvent = db.ClubEvents.Find(id);

            db.ClubEvents.Remove(clubEvent);
            db.SaveChanges();
            return(RedirectToAction("Details", "Clubs", new { id = clubEvent.ClubId }));
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ClubEvent clubEvent = db.ClubEvents.Find(id);

            db.ClubEvents.Remove(clubEvent);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            ClubEvent clubEvent = await db.ClubEvents.FindAsync(id);

            db.ClubEvents.Remove(clubEvent);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #4
0
 public ActionResult Edit([Bind(Include = "Id,Venue,Location,ClubId,StartDateTime,EndDateTime")] ClubEvent clubEvent)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clubEvent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClubId = new SelectList(db.Clubs, "ClubId", "ClubName", clubEvent.ClubId);
     return(View(clubEvent));
 }
        public ActionResult Create([Bind(Include = "EventId,Venue,Location,StartDateTime,EndDateTime,ClubId")] ClubEvent clubEvent)
        {
            if (ModelState.IsValid)
            {
                db.ClubEvents.Add(clubEvent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ClubId = new SelectList(db.Clubs, "ClubId", "ClubName", clubEvent.ClubId);
            return(View(clubEvent));
        }
Пример #6
0
        // GET: ClubEvents/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClubEvent clubEvent = db.ClubEvents.Find(id);

            if (clubEvent == null)
            {
                return(HttpNotFound());
            }
            return(View(clubEvent));
        }
Пример #7
0
        // GET: ClubEvents/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClubEvent clubEvent = await db.ClubEvents.FindAsync(id);

            if (clubEvent == null)
            {
                return(HttpNotFound());
            }
            return(View(clubEvent));
        }
Пример #8
0
        public async Task <ActionResult> _Create([Bind(Include = "EventID,Venue,Location,ClubId,StartDateTime,EndDateTime")] ClubEvent clubEvent)
        {
            if (ModelState.IsValid)
            {
                db.ClubEvents.Add(clubEvent);
                await db.SaveChangesAsync();

                return(RedirectToAction(actionName: "Edit",
                                        controllerName: "Clubs",
                                        routeValues: new { id = clubEvent.ClubId }));
            }

            return(View(clubEvent));
        }
Пример #9
0
        // GET: ClubEvents/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClubEvent clubEvent = db.ClubEvents.Find(id);

            if (clubEvent == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ClubId = new SelectList(db.Clubs, "ClubId", "ClubName", clubEvent.ClubId);
            return(View(clubEvent));
        }
Пример #10
0
 public async Task <ActionResult> _Create([Bind(Include = "EventID,Venue,Location,ClubId,StartDateTime,EndDateTime")] ClubEvent clubEvent)
 {
     if (ModelState.IsValid)
     {
         db.ClubEvents.Add(new ClubEvent
         {
             ClubId        = clubEvent.ClubId,
             Venue         = clubEvent.Venue,
             Location      = clubEvent.Location,
             StartDateTime = clubEvent.StartDateTime,
             EndDateTime   = clubEvent.EndDateTime
         });
         await db.SaveChangesAsync();
     }
     return(RedirectToAction("Details", "Clubs", new { id = clubEvent.ClubId }));
 }
Пример #11
0
        public async Task <ActionResult> Create([Bind(Include = "EventID,Venue,Location,ClubId,StartDateTime,EndDateTime")] ClubEvent clubEvent)
        {
            if (ModelState.IsValid)
            {
                db.ClubEvents.Add(clubEvent);
                await db.SaveChangesAsync();

                // return RedirectToAction("Edit", "Clubs"); // change from index
                return(RedirectToAction(actionName: "Edit",
                                        controllerName: "Clubs",
                                        routeValues: new { id = clubEvent.ClubId }));
            }

            ViewBag.ClubId = new SelectList(db.Clubs, "ClubId", "ClubName", clubEvent.ClubId);
            return(View(clubEvent));
        }
Пример #12
0
        public async Task CreateEvent(ClubEventCreateRequest clubEventCreateRequest)
        {
            Club club = await _clubsRepository.GetClubById(clubEventCreateRequest.ClubId);

            if (club == null)
            {
                return;
            }

            ClubEvent clubEvent = new ClubEvent
            {
                Club        = club,
                Title       = clubEventCreateRequest.Title,
                Description = clubEventCreateRequest.Description,
                EventType   = clubEventCreateRequest.EventType,
                StartTime   = clubEventCreateRequest.StartTime,
                Longtitude  = clubEventCreateRequest.Coordinates.Longtitute,
                Latitude    = clubEventCreateRequest.Coordinates.Latitude
            };

            if (clubEventCreateRequest.IncludePlayerStatuses == PlayerStatus.All)
            {
                foreach (var member in club.Members)
                {
                    clubEvent.InvitedMembers.Add(new ClubEventMember
                    {
                        ClubEvent = clubEvent,
                        Member    = member
                    });
                }
            }
            else
            {
                // clubEvent.InvitedMembers.Where(im => im IN IncludePlayerStatuses) = club.Members, TODO Implement individual events
            }

            _clubEventsRepository.AddEvent(clubEvent);
        }
Пример #13
0
 public void AddEvent(ClubEvent clubEvent)
 {
     _dbContext.ClubEvents.Add(clubEvent);
 }
        public async Task AddOrUpdateEvent(ClubEvent clubEvent)
        {
            var client = GetClient();

            if (clubEvent.IsNewItem)
            {
                clubEvent.DbKey = clubEvent.GenerateDbKey(IdPrefix);
            }

            BatchPutAttributesRequest request = new BatchPutAttributesRequest();

            request.DomainName = Domain;

            // Mandatory properties
            var attributes = new List <ReplaceableAttribute>
            {
                new ReplaceableAttribute {
                    Name = "Id", Value = clubEvent.Id, Replace = true
                },
                new ReplaceableAttribute {
                    Name = "Season", Value = ((int)clubEvent.Season).ToString(), Replace = true
                },
                new ReplaceableAttribute {
                    Name = "Date", Value = dateToString(clubEvent.Date), Replace = true
                },
                new ReplaceableAttribute {
                    Name = "EventType", Value = ((int)clubEvent.EventType).ToString(), Replace = true
                },
                new ReplaceableAttribute {
                    Name = "Description", Value = clubEvent.Description, Replace = true
                }
            };

            // Optional properties
            if (clubEvent.MatchType != null)
            {
                attributes.Add(new ReplaceableAttribute {
                    Name = "MatchType", Value = ((int)clubEvent.MatchType.Value).ToString(), Replace = true
                });
            }
            if (clubEvent.MatchDraw != null)
            {
                attributes.Add(new ReplaceableAttribute {
                    Name = "MatchDraw", Value = dateToString(clubEvent.MatchDraw.Value), Replace = true
                });
            }
            if (clubEvent.MatchStart != null)
            {
                attributes.Add(new ReplaceableAttribute {
                    Name = "MatchStart", Value = dateToString(clubEvent.MatchStart.Value), Replace = true
                });
            }
            if (clubEvent.MatchEnd != null)
            {
                attributes.Add(new ReplaceableAttribute {
                    Name = "MatchEnd", Value = dateToString(clubEvent.MatchEnd.Value), Replace = true
                });
            }
            if (clubEvent.Number != null)
            {
                attributes.Add(new ReplaceableAttribute {
                    Name = "Number", Value = numberToString(clubEvent.Number.Value), Replace = true
                });
            }
            if (clubEvent.Cup != null)
            {
                attributes.Add(new ReplaceableAttribute {
                    Name = "Cup", Value = clubEvent.Cup, Replace = true
                });
            }

            request.Items.Add(
                new ReplaceableItem
            {
                Name       = clubEvent.DbKey,
                Attributes = attributes
            }
                );

            try
            {
                BatchPutAttributesResponse response = await client.BatchPutAttributesAsync(request);

                _logger.LogDebug($"Event added: {clubEvent.DbKey} - {clubEvent.Description}");
            }
            catch (AmazonSimpleDBException ex)
            {
                _logger.LogError(ex, $"Error Code: {ex.ErrorCode}, Error Type: {ex.ErrorType}");
                throw;
            }
        }
        public async Task <List <ClubEvent> > GetEvents()
        {
            _logger.LogWarning($"Getting events at : {DateTime.Now.ToString("HH:mm:ss.000")}");

            var events = new List <ClubEvent>();

            var client = GetClient();

            SelectRequest request = new SelectRequest();

            request.SelectExpression = $"SELECT * FROM {Domain} WHERE ItemName() LIKE '{IdPrefix}:%' AND Date > '' ORDER BY Date";

            SelectResponse response = await client.SelectAsync(request);

            foreach (var item in response.Items)
            {
                var clubEvent = new ClubEvent();

                clubEvent.DbKey = item.Name;

                foreach (var attribute in item.Attributes)
                {
                    switch (attribute.Name)
                    {
                    case "Id":
                        clubEvent.Id = attribute.Value;
                        break;

                    case "Season":
                        clubEvent.Season = (Season)(Convert.ToInt32(attribute.Value));
                        break;

                    case "Date":
                        clubEvent.Date = DateTime.Parse(attribute.Value);
                        break;

                    case "EventType":
                        clubEvent.EventType = (EventType)(Convert.ToInt32(attribute.Value));
                        break;

                    case "Description":
                        clubEvent.Description = attribute.Value;
                        break;

                    case "MatchType":
                        clubEvent.MatchType = (MatchType)(Convert.ToInt32(attribute.Value));
                        break;

                    case "MatchDraw":
                        clubEvent.MatchDraw = DateTime.Parse(attribute.Value);
                        break;

                    case "MatchStart":
                        clubEvent.MatchStart = DateTime.Parse(attribute.Value);
                        break;

                    case "MatchEnd":
                        clubEvent.MatchEnd = DateTime.Parse(attribute.Value);
                        break;

                    case "Number":
                        clubEvent.Number = Convert.ToInt32(attribute.Value);
                        break;

                    case "Cup":
                        clubEvent.Cup = attribute.Value;
                        break;

                    default:
                        break;
                    }
                }

                events.Add(clubEvent);
            }

            return(events);
        }
        public static void Initialize(ClubAndSocContext context)
        {
            context.Database.EnsureCreated();

            // Look for any clubs.
            if (context.ClubsAndSocieties.Any())
            {
                return;   // DB has been seeded
            }

            //clubsAndSocieties
            var clubsAndSocieties = new ClubsAndSociety[]
            {
                new ClubsAndSociety {
                    Name = "Soccer", Chairperson = "Alexander", Treasurer = "Mary", Secretary = "Tommy", Phone = "098-24232", Email = "*****@*****.**", Description = "Two teams of 11 try to scor goals in each others net", AdminID = 1
                },
                new ClubsAndSociety {
                    Name = "Rugby", Chairperson = "Alexander", Treasurer = "Mary", Secretary = "Tommy", Phone = "098-24232", Email = "*****@*****.**", Description = "Two teams of 11 try to scor goals in each others net", AdminID = 1
                },
                new ClubsAndSociety {
                    Name = "Tennis", Chairperson = "Alexander", Treasurer = "Mary", Secretary = "Tommy", Phone = "098-24232", Email = "*****@*****.**", Description = "Two teams of 11 try to scor goals in each others net", AdminID = 1
                },
            };

            foreach (ClubsAndSociety c in clubsAndSocieties)
            {
                context.ClubsAndSocieties.Add(c);
            }
            context.SaveChanges();

            //Students
            var students = new Student[]
            {
                new Student {
                    Name = "Tom tim", Course = "Software", Email = "*****@*****.**", Password = "******",
                },
                new Student {
                    Name = "Tammy tim", Course = "Systems", Email = "*****@*****.**", Password = "******",
                },
                new Student {
                    Name = "Tony tim", Course = "Games", Email = "*****@*****.**", Password = "******",
                },
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            //Members
            var members = new Member[]
            {
                new Member {
                    StudentID = 1, ClubID = 1
                },
                new Member {
                    StudentID = 1, ClubID = 2
                },
                new Member {
                    StudentID = 2, ClubID = 2
                },
            };

            foreach (Member m in members)
            {
                context.Members.Add(m);
            }
            context.SaveChanges();

            //Admin
            var admins = new Administrator[]
            {
                new Administrator {
                    Name = "Holly Hunter", Password = "******"
                },
                new Administrator {
                    Name = "Martin Foley", Password = "******"
                },
                new Administrator {
                    Name = "Peter Rabbit", Password = "******"
                },
            };

            foreach (Administrator a in admins)
            {
                context.Administors.Add(a);
            }
            context.SaveChanges();

            //Club events
            var clubEvents = new ClubEvent[]
            {
                new ClubEvent {
                    ClubID = 1, EventID = 1
                },
                new ClubEvent {
                    ClubID = 1, EventID = 2
                },
                new ClubEvent {
                    ClubID = 2, EventID = 3
                },
            };

            foreach (ClubEvent ce in clubEvents)
            {
                context.ClubEvents.Add(ce);
            }
            context.SaveChanges();

            //Notifications
            var note = new Notification[]
            {
                new Notification {
                    AdminID = 1, Title = "No school", Date = DateTime.Parse("2017-09-01"), Message = "There will be no school next week"
                },
                new Notification {
                    AdminID = 2, Title = "No school", Date = DateTime.Parse("2017-09-01"), Message = "There will be no school the following week"
                },
            };

            foreach (Notification n in note)
            {
                context.Notifications.Add(n);
            }
            context.SaveChanges();

            //Posts
            var posts = new Post[]
            {
                new Post {
                    StudentID = 1, EventID = 1, Date = DateTime.Parse("2017-09-15"), PostMessage = "hi everyone :-)", Title = "Hi"
                },
                new Post {
                    StudentID = 2, EventID = 2, Date = DateTime.Parse("2017-09-15"), PostMessage = "hi :-)", Title = "Hi"
                },
            };

            foreach (Post p in posts)
            {
                context.Posts.Add(p);
            }
            context.SaveChanges();
        }
Пример #17
0
 public void RemoveEvent(ClubEvent clubEvent)
 {
     clubEvent.IsDeleted = true;
     UpdateEvent(clubEvent);
 }
Пример #18
0
 public void UpdateEvent(ClubEvent clubEvent)
 {
     _dbContext.ClubEvents.Update(clubEvent);
 }