public ActionResult Create(User collection) { try { // TODO: Add insert logic here interfaceobj.InsertModel(collection); interfaceobj.Save(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(PlayerRole collection) { try { // TODO: Add insert logic here IplayerRole.InsertModel(collection); IplayerRole.Save(); return(RedirectToAction("Index")); } catch { return(View()); } }
// POST: api/Match public IHttpActionResult Post(PlayerScore match) { iplayerscore.InsertModel(match); iplayerscore.Save(); return(Ok()); }
// POST: api/PlayerAPI public HttpResponseMessage Post(HttpRequestMessage request, [FromBody] Player value) { iplayer.InsertModel(value); iplayer.Save(); return(request.CreateResponse(HttpStatusCode.OK, "Data Inserted Successfully")); }
// POST: api/Match public IHttpActionResult Post(MatchPlayer match) { imatchpalyer.InsertModel(match); imatchpalyer.Save(); return(Ok()); }
// POST: api/Match public HttpResponseMessage Post(HttpRequestMessage request, Match match) { imatch.InsertModel(match); imatch.Save(); //Match mch = objmatch.match; //var plyers = objmatch.Players; //CommanClass.GetConnection().Matches.Add(mch); //CommanClass.GetConnection().SaveChanges(); //int matchid = matchDal.GetMaxMatchId(); //List<MatchPlayer> lstmatchplayer = new List<MatchPlayer>(); //foreach (Player item in plyers) //{ // CommanClass.GetConnection().Players.Add(item); // CommanClass.GetConnection().SaveChanges(); // int playerid = new PlayerRespository().GetMaxPlayerId(); // lstmatchplayer.Add(new MatchPlayer() // { // PlayerId = playerid, // MatchId = matchid // }); //} //foreach (MatchPlayer item in lstmatchplayer) //{ // CommanClass.GetConnection().MatchPlayers.Add(item); //} //CommanClass.GetConnection().SaveChanges(); ///////////////Upload Multiple player list for one match ////////////// //Match mh = new Match() //{ // Name = "Test", // SeriesName = "Test", // Location = "Rajkot", // Date = DateTime.Now, // TimeSlot = "154h 54m 2s" //}; //List<Player> listpl = new List<Player>(); //Player pl = new Player() //{ // FirstName = "Sachin", // LastName = "Tendulkar", // Age = 37, // Address = "Mumbai", // Location = "Mumbai", // RoleId = 1 //}; //Player pl1 = new Player() //{ // FirstName = "virendra", // LastName = "sehwag", // Age = 37, // Address = "Mumbai", // Location = "Mumbai", // RoleId = 1 //}; //Player pl2 = new Player() //{ // FirstName = "Rahul", // LastName = "dravid ", // Age = 37, // Address = "Mumbai", // Location = "Mumbai", // RoleId = 1 //}; //Player pl3 = new Player() //{ // FirstName = "vvs", // LastName = "laxman", // Age = 37, // Address = "Mumbai", // Location = "Mumbai", // RoleId = 1 //}; //listpl.Add(pl); //listpl.Add(pl1); //listpl.Add(pl2); //listpl.Add(pl3); //mh.MatchPlayers = new List<MatchPlayer>(); //mh.PlayerScores = new List<PlayerScore>(); //foreach (Player item in listpl) //{ // mh.MatchPlayers.Add( // new MatchPlayer // { // Match = mh, // Player = item // //PlayerId = item.Id // }); //} //imatch.InsertModel(mh); //imatch.Save(); return(request.CreateResponse(HttpStatusCode.OK, "Data Inserted Successfully")); }
// POST: api/UserAPI public HttpResponseMessage Post(HttpRequestMessage request, [FromBody] Matches value) { //UserRespository userres = new UserRespository(); //UserMatch userobj = new UserMatch(); //userobj = userres.CheckUserData(Convert.ToInt32(value.Id),Convert.ToInt32(matchid)); //if (userobj.Id == null) // { //interfaceobj.InsertModel(value); //interfaceobj.Save(); // } //else //{ // return request.CreateErrorResponse(HttpStatusCode.OK, "Already User Found"); //} //User user = new User() //{ // FirstName = value.Firstname, // LastName = value.Lastname, // UserName = value.Username, // EmailAddress = value.Emailaddress, // Age = value.age //}; //interfaceobj.InsertModel(user); //interfaceobj.Save(); //int userid = userDal.GetMaxId(); //foreach (UserPlayer item in value.UserTeam.UserPlayer) //{ // lstusermatch.Add(new UserMatch() // { // PlayerId = item.PlayerId, // MatchId = item.MatchId, // UserId = userid // }); //} //Team team = new Team() //{ // TeamName = value.UserTeam.TeamName, // UserMatches = lstusermatch //}; //interfaceobjteam.InsertModel(team); // interfaceobjteam.Save(); try { List <UserMatch> lstusermatch = new List <UserMatch>(); Team team = new Team(); foreach (FabricApplication.Models.BAL.MatchPlayer item in value.MatchPlayers) { if (item.IsSelected == true) { lstusermatch.Add(new UserMatch() { PlayerId = item.PlayerId, UserId = value.UserId, MatchId = item.MatchId }); interfaceplayerscore.InsertModel(new PlayerScore() { PlayerId = item.PlayerId, MatchId = item.MatchId, Points = item.Points, Credits = item.Credits }); } team.TeamName = value.TeamName; team.UserMatches = lstusermatch; } interfaceobjteam.InsertModel(team); interfaceobjteam.Save(); interfaceplayerscore.Save(); //Team mh = new Team() //{ // TeamName = value.TeamName, //}; //foreach (FabricApplication.Models.BAL.MatchPlayer item in value.MatchPlayers) //{ // mh.UserMatches.Add( // new UserMatch // { // Team = mh, // //Player = item // PlayerId = item.PlayerId, // MatchId = value.Id, // UserId = value.UserId, // Player = new Player() // { // Id = Convert.ToInt32(item.PlayerId), // FirstName = item.FirstName, // LastName = item.LastName, // Address = item.Address, // Age = item.Age, // PlayerScores = new List<PlayerScore>() // { // new PlayerScore() // { // Points = item.Points, // Credits = item.Credits, // PlayerId = item.PlayerId, // MatchId = item.MatchId // } // } // } // }); //} //interfaceobjteam.InsertModel(mh); //interfaceobjteam.Save(); return(request.CreateErrorResponse(HttpStatusCode.OK, "Data Inserted Successfully")); } //value.UserMatches = new List<UserMatch>(); //value.PlayerScores = new List<PlayerScore>(); //value.MatchPlayers = new List<FabricApplication.Models.BAL.MatchPlayer>(); //foreach (FabricApplication.Models.BAL.MatchPlayer item in value.MatchPlayers) //{ // var result = AutoMapper.Mapper.Map<FabricApplication.Match>(item); // value.UserMatches.Add(new UserMatch() // { // PlayerId = item.PlayerId, // UserId = value.UserId, // MatchId = item.MatchId // }); // value.PlayerScores.Add(new PlayerScore() // { // PlayerId = item.PlayerId, // Points = item.Points, // Credits = item.Credits // }); // interfacematch.InsertModel(result); //} //interfacematch.Save(); // return request.CreateErrorResponse(HttpStatusCode.OK, "Data Inserted Successfully"); catch (Exception ex) { return(request.CreateResponse(ex.Message)); } }