예제 #1
0
        public async Task <SportsEvent> AddSportsEventAsync(SportsEvent sportsEvent)
        {
            _context.SportsEvents.Add(sportsEvent);
            await _context.SaveChangesAsync();

            return(sportsEvent);
        }
        public ActionResult DeleteConfirmed(string id)
        {
            SportsEvent sportsEvent = db.SportsEvents.Find(id);

            db.SportsEvents.Remove(sportsEvent);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "EventName,EventDate,EventVenue")] SportsEvent sportsEvent)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sportsEvent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sportsEvent));
 }
예제 #4
0
        public async Task <SportsEvent> UpdateSportsEventAsync(SportsEvent sportsEvent)
        {
            if (!_context.SportsEvents.Local.Any(a => a.Id == sportsEvent.Id))
            {
                _context.SportsEvents.Attach(sportsEvent);
            }
            _context.Entry(sportsEvent).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(sportsEvent);
        }
예제 #5
0
 public void SetSportsEvent(SportsEvent ar)
 {
     _editingSportsEvent = ar;
     if (SportsEvent != null)
     {
         SportsEvent.ErrorsChanged -= RaiseCanExecuteChanged;
     }
     SportsEvent = new DtoSportsEvent();
     SportsEvent.ErrorsChanged += RaiseCanExecuteChanged;
     CopySportsEvent(ar, SportsEvent);
 }
        public ActionResult Create([Bind(Include = "EventName,EventDate,EventVenue")] SportsEvent sportsEvent)
        {
            if (ModelState.IsValid)
            {
                string t = TempData["Test1"] as string;
                db.SportsEvents.Add(sportsEvent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sportsEvent));
        }
        // GET: SportsEvents/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SportsEvent sportsEvent = db.SportsEvents.Find(id);

            if (sportsEvent == null)
            {
                return(HttpNotFound());
            }
            return(View(sportsEvent));
        }
예제 #8
0
        private void UpdateSportsEvent(DtoSportsEvent source, SportsEvent target)
        {
            source.Gender = target.Gender;

            source.Gender      = target.Gender;
            source.GenderId    = target.GenderId;
            source.Location    = target.Location;
            source.LocationId  = target.LocationId;
            source.Organizer   = target.Organizer;
            source.OrganizerId = target.OrganizerId;
            source.Schedule    = target.Schedule;
            source.ScheduleId  = target.ScheduleId;
            source.Sport       = target.Sport;
            source.SportId     = target.SportId;
        }
        // GET: SportsEvents/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            string      t           = TempData["Test1"] as string;
            SportsEvent sportsEvent = db.SportsEvents.Find(id);

            if (sportsEvent == null)
            {
                return(HttpNotFound());
            }
            return(View(sportsEvent));
        }
예제 #10
0
        private void CopySportsEvent(SportsEvent source, DtoSportsEvent target)
        {
            target.Id = source.Id;

            if (EditMode)
            {
                source.Gender      = target.Gender;
                source.GenderId    = target.GenderId;
                source.Location    = target.Location;
                source.LocationId  = target.LocationId;
                source.Organizer   = target.Organizer;
                source.OrganizerId = target.OrganizerId;
                source.Schedule    = target.Schedule;
                source.ScheduleId  = target.ScheduleId;
                source.Sport       = target.Sport;
                source.SportId     = target.SportId;
            }
        }
예제 #11
0
        static void Main(string[] args)
        {
            //Student s = new Student
            //{
            //    Name = "Siva",
            //    Standard = 10,
            //    Comments="Dont have any"
            //};

            //Student s1 = new Student
            //{
            //    Name="Bhavana",
            //    Standard=10,

            //};

            //Teacher t = new Teacher
            //{
            //    Name = "Siva",
            //    Students = new[] { s, s1 }
            //};

            //using (SchoolContext context = new SchoolContext())
            //{
            //    context.Students.Add(s);
            //    context.Students.Add(s1);
            //    context.SaveChanges();
            //    context.Teachers.Add(t);
            //    context.SaveChanges();
            //}

            using (SchoolContext context = new SchoolContext())
            {
                Console.WriteLine("Enter Sports Event Name");
                SportsEvent sp = new SportsEvent();
                sp.EventName             = Console.ReadLine();
                sp.EventDate             = DateTime.Now;
                sp.ParticipatingStudents = context.Students.ToList();
                context.SportsEvents.Add(sp);
                context.SaveChanges();
            }
        }
예제 #12
0
 private void OnEditSportsEvent(SportsEvent sportsEvent)
 {
     EditSportsEventRequested(sportsEvent);
 }
 private void NavToAddSportsEvent(SportsEvent sportsEvent)
 {
     _sportsEventFormViewModel.EditMode = false;
     _sportsEventFormViewModel.SetSportsEvent(sportsEvent);
     CurrentViewModel = _sportsEventFormViewModel;
 }