Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, LoveTeam student)
        {
            if (id == 0)
            {
                return(BadRequest());
            }

            if (student == null)
            {
                return(BadRequest());
            }

            try
            {
                student.LoveTeamId = id;
                context.LoveTeams.Update(student);
                await context.SaveChangesAsync();

                return(Ok(new
                {
                    result = "Successfully updated"
                }));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(LoveTeam student)
        {
            if (student == null)
            {
                return(BadRequest());
            }

            try
            {
                context.LoveTeams.Add(student);
                await context.SaveChangesAsync();

                return(Ok(new
                {
                    result = "Successfully saved"
                }));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }