public async Task <IActionResult> PutSponsors(int id, Sponsors sponsors) { if (id != sponsors.sponsorId) { return(BadRequest()); } _context.Entry(sponsors).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SponsorsExists(sponsors.sponsorId)) { return(NotFound()); } else { throw; } } return(Ok()); }
public async Task <IActionResult> PutInfo(int id, Info info) { if (id != info.infoId) { return(BadRequest()); } _context.Entry(info).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InfoExists(info.infoId)) { return(NotFound()); } else { throw; } } return(Ok()); }
public async Task <Object> PostUser(User model) { var identity = new IdentityUserModel() { UserName = model.username, name = model.name, lastname = model.lastname }; try { var result = await _userManager.CreateAsync(identity, model.passcode); if (result != null) { try { _context.User.Add(model); await _context.SaveChangesAsync(); } catch (Exception e) { return(StatusCode(500, e)); } return(CreatedAtAction("GetUser", new { id = model.userId }, model)); } return(BadRequest(new { message = result })); } catch (Exception ex) { return(BadRequest(new { message = ex })); } }
public async Task <IActionResult> PutTeam(int id, Team team) { if (id != team.teamId) { return(BadRequest()); } _context.Entry(team).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PositionExists(team.teamId)) { return(NotFound()); } else { throw; } } return(Ok()); }
public async Task <IActionResult> PutBloc(int id, Bloc bloc) { if (id != bloc.blocId) { return(BadRequest()); } _context.Entry(bloc).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BlocExists(bloc.blocId)) { return(NotFound()); } else { throw; } } return(Ok()); }
public async Task <IActionResult> PutRol(int id, Rol rol) { if (id != rol.rolId) { return(BadRequest()); } _context.Entry(rol).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RolExists(rol.rolId)) { return(NotFound()); } else { throw; } } return(Ok()); }
public async Task <ActionResult <Recruitment> > Postrecruitment(Recruitment recruitment) { var email = "*****@*****.**"; try { using (MailMessage message = new MailMessage("*****@*****.**", email)) { message.Subject = "Formulario de aplicación para unirse a Pardos Santo Domingo"; message.Body = "Saludos Coridiales a la directiva del equipo Pardos Santo Domingo, " + "mi nombre es " + recruitment.name + " " + recruitment.lastname + " el portador del número de cedula de identidad " + "y electoral No. " + recruitment.identification_card + " soy un prospecto de " + recruitment.height + "cm de altura además de " + recruitment.weight + "lb de peso y aquí les envío mi solicitud con todo el entusiasmo del mundo."; message.IsBodyHtml = false; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "%+?wGn5GXAtraEJS"); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(message); } try { _context.Recruitment.Add(recruitment); await _context.SaveChangesAsync(); } catch (System.Exception) { return(BadRequest(new { message = "Error al guardar la información en nuestra base de datos..." })); } } catch (System.Exception) { return(BadRequest(new { message = "Error al intentar enviar la solicitud..." })); } return(Ok(new { message = "Solicitud enviada con éxito..." })); }