public async Task <IActionResult> PutWorkoutExcerciseCategories(Guid id, WorkoutExcerciseCategories workoutExcerciseCategories)
        {
            if (id != workoutExcerciseCategories.Workout_excercise_categories_id)
            {
                return(BadRequest());
            }

            _context.Entry(workoutExcerciseCategories).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WorkoutExcerciseCategoriesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> PutPlayer(int id, Player player)
        {
            if (id != player.Id)
            {
                return(BadRequest());
            }

            _context.Entry(player).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlayerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutTeam([FromRoute] int id, [FromBody] Team team)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != team.Id)
            {
                return(BadRequest());
            }

            _context.Entry(team).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeamExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("SportID,SportTitle,Description")] Sport sport)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sport);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(sport));
        }
Beispiel #5
0
        public async Task <IActionResult> Create([Bind("Id,Email,Password,RoleId")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoleId"] = new SelectList(_context.Roles, "Id", "Id", user.RoleId);
            return(View(user));
        }
Beispiel #6
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Number")] Player player)
        {
            if (ModelState.IsValid)
            {
                player.Id = Guid.NewGuid();
                db.Players.Add(player);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(player));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Founded")] Team team)
        {
            if (ModelState.IsValid)
            {
                team.Id = Guid.NewGuid();
                db.Teams.Add(team);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(team));
        }
        public async Task <IActionResult> Create([Bind("EnrollmentID,SportID,ContestantID")] Enrollment enrollment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(enrollment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContestantID"] = new SelectList(_context.Contestants, "ID", "ID", enrollment.ContestantID);
            ViewData["SportID"]      = new SelectList(_context.Sports, "SportID", "SportID", enrollment.SportID);
            return(View(enrollment));
        }
        public async Task <Guid> CreateUser(User user)
        {
            _context.Users.Add(user);
            await _context.SaveChangesAsync();

            return(user.UserId);
        }
        public IActionResult Edit(int id, [Bind("InstructorID,Name,Surname,Midname,Experience,Aducation")] Instructor instructor)
        {
            if (id != instructor.InstructorID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(instructor);
                    _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstructorExists(instructor.InstructorID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(instructor));
        }
Beispiel #11
0
        public async Task <IActionResult> Create([FromBody][Bind("Username,Email,FirstName,LastName,Phone")] User user)
        {
            try
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(Ok(user));
            }
            catch (Exception e)
            {
                return(Conflict(new { errorText = e.Message }));
            }
        }
Beispiel #12
0
        public async Task <IActionResult> PostSport([FromBody] Sport sport)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            context.Sport.Add(sport);
            await context.SaveChangesAsync();

            return(CreatedAtAction("PostSport", new { id = sport.Id }, sport));
        }
        public async Task AddAsync(TEntity entity)
        {
            await Context.Set <TEntity>().AddAsync(entity);

            await Context.SaveChangesAsync();
        }
Beispiel #14
0
        public void AddStatsCategory(StatsCategory cat)
        {
            _context.StatsCategories.Add(cat);

            _context.SaveChangesAsync();
        }