public async Task <IActionResult> PostTblTeam(TblTeam tblTeam) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.TblTeam.Add(tblTeam); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TblTeamExists(tblTeam.FldTeamName)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetTblTeam", new { id = tblTeam.FldTeamName }, tblTeam)); }
public List <TblTeam> GetTeams(string rank) { var email = _context.TblLogin.Where(n => n.FldRank == rank).Select(n => n.FldUsername); List <TblTeam> toReturn = new List <TblTeam>(); if (rank == "355") { foreach (var item in email) { TblTeam data = new TblTeam { FldUsername = item, }; toReturn.Add(data); } } else { foreach (var item in email) { toReturn.Add(_context.TblTeam.Where(n => n.FldUsername == item).First()); } } return(toReturn); }
public async Task <IActionResult> PutTblTeam([FromRoute] string id, [FromBody] TblTeam tblTeam) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblTeam.FldTeamName) { return(BadRequest()); } _context.Entry(tblTeam).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TblTeamExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult EditProfile(int id, TblTeam model, string city, HttpPostedFileBase postedFile) { List <TblCountry> countries = db.Country_tbl.ToList(); ViewBag.CountryList = new SelectList(countries, "CountryId", "Country"); if (postedFile != null) { using (BinaryReader br = new BinaryReader(postedFile.InputStream)) { bytes = br.ReadBytes(postedFile.ContentLength); } } var EditTeamList = db.Team_tbl.Where(x => x.TeamId == id && x.Status == 1).FirstOrDefault(); if (EditTeamList != null) { EditTeamList.TeamName = model.TeamName; if (bytes != null) { EditTeamList.Photo = bytes; } db.SaveChanges(); } //db.Entry(model).State = System.Data.Entity.EntityState.Modified; //db.SaveChanges(); return(Content("<script>alert('Updated Successfully');location.href='TeamView';</script>")); }
public HttpResponseMessage Post(string user, [FromBody] TblTeam value) { string accountId = CompetitionDB.Users.FirstOrDefault(x => x.UserName == user).Id; int id = CompetitionDB.TblUsers.FirstOrDefault(x => x.UserId == accountId).Id; value.TeamCaptainId = id; CompetitionDB.TblTeams.Add(value); return(ToJsonCreated(CompetitionDB.SaveChanges())); }
public HttpResponseMessage Post([FromBody] TblTeam value) { CompetitionDB.TblTeams.Add(value); CompetitionDB.SaveChanges(); TblUser user = CompetitionDB.TblUsers.Find(value.TeamCaptainId); user.TeamId = value.Id; CompetitionDB.Entry(user).State = EntityState.Modified; return(ToJsonCreated(CompetitionDB.SaveChanges())); }
public void CreateTeam(string teamName, int schoolID, string subject, byte[] report) { using (DB_YoungEnterpriseContext databaseContext = GetConnection()) { TblTeam team = new TblTeam() { FldTeamName = teamName, FldSchoolId = schoolID, FldSubjectCategory = subject, FldReport = report }; databaseContext.TblTeam.Add(team); databaseContext.SaveChanges(); } }
public Teams GetTeamByShortName(string name) { TblTeam tblTeam = db.Single <TblTeam>("where shortname = @t1", new { t1 = name }); Teams team = new Teams(); team.teamId = tblTeam.teamid; team.shortName = tblTeam.shortname; team.teamName = tblTeam.teamname; team.photoUrl = tblTeam.photourl; team.characters = db.Fetch <TblCharacter>("SELECT * FROM dnd.tblcharacter WHERE teamid = @t1", new { t1 = tblTeam.teamid }).Select(y => new Teams.Character() { id = y.characterId, name = y.name, bio = y.bioshort, bioFull = y.biofull, photoUrl = y.photourl }).ToList(); return(team); }
public async Task <IActionResult> DownloadReport(DownloadReportTeamName name) { TblTeam team = dbService.GetSpecificTeam(name.TeamName); return(File(team.FldReport, "application/pdf")); }
public ActionResult TeamRegistration(TblTeam model, string city, HttpPostedFileBase postedFile) { var userid = Session["UserId"].ToString(); var teamsponsorid = Session["TeamSponsorId"].ToString(); List <TblCountry> countries = db.Country_tbl.ToList(); ViewBag.CountryList = new SelectList(countries, "CountryId", "Country"); List <TblUser> user = db.User_tbl.ToList(); ViewBag.UserList = new SelectList(user, "UserId", "UserId"); if (ModelState.IsValid) { byte[] bytes; using (BinaryReader br = new BinaryReader(postedFile.InputStream)) { bytes = br.ReadBytes(postedFile.ContentLength); } //TblPlayer tblPlayer = new TblPlayer(); db.Team_tbl.Add(new TblTeam { TeamReferenceNumber = "1", //PlayerId = model.PlayerId, TeamName = model.TeamName, CityId = Convert.ToInt32(city), //if(file!=null) //{ // string path = Path.Combine(Server.MapPath("~/UserImages"), Path.GetFileName(file.FileName)); //file.SaveAs(path); //} Photo = bytes, Confirmed = 1, RegistrationDate = DateTime.Now, ExpirationDate = DateTime.Now, TeamSponsorId = Convert.ToInt32(teamsponsorid), Status = 1, CreatedId = 1, CreatedDate = DateTime.Now, ModifiedId = 0, ModifiedDate = DateTime.Now }); db.SaveChanges(); return(RedirectToAction("Team")); } return(View()); }
public TeamModel(TblTeam row) { Id = row.Id; Name = row.Name; CaptainId = row.TeamCaptainId; }