// GET: Club public ActionResult Index(long ownerId, int pageIndex = 1, int pageSize = 10) { int totalRecord = 0; var model = new ClubDao().ListAllByOwnerID(ownerId, ref totalRecord, pageIndex, pageSize); ViewBag.Total = totalRecord; ViewBag.Page = pageIndex; ViewBag.OwnerID = ownerId; int maxPage = 5; int totalPage = 0; if (totalRecord % pageSize != 0) { totalPage = (int)(totalRecord / pageSize) + 1; } else { totalPage = (int)(totalRecord / pageSize); } ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = pageIndex + 1; ViewBag.Prev = pageIndex - 1; return(View(model)); }
////Other methods //Save MoreImages public JsonResult SaveImages(long id, string images) { JavaScriptSerializer serializer = new JavaScriptSerializer(); var listImages = serializer.Deserialize <List <string> >(images); XElement xElement = new XElement("Images"); foreach (var item in listImages) { var subStringItem = item.Substring(22); xElement.Add(new XElement("Image", subStringItem)); } ClubDao dao = new ClubDao(); try { dao.UpdateImages(id, xElement.ToString()); return(Json(new { status = true })); } catch (Exception ex) { return(Json(new { status = false })); } }
//Load MoreImages public JsonResult LoadImages(long id) { ClubDao dao = new ClubDao(); var club = dao.GetByID(id); var images = club.MoreImages; if (images != null) { XElement xImages = XElement.Parse(images); List <string> listImagesReturn = new List <string>(); foreach (XElement element in xImages.Elements()) { listImagesReturn.Add(element.Value); } return(Json(new { data = listImagesReturn }, JsonRequestBehavior.AllowGet)); } else { List <string> listImagesReturn = new List <string>(); return(Json(new { data = listImagesReturn }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit(long id) { var club = new ClubDao().GetByID(id); var listStadium = new ClubStadiumDao().ListClubStadium(id); ViewBag.ListStadium = listStadium; return(View(club)); }
public ActionResult Edit(long id) { var club = new ClubDao().GetByID(id); var listAvailableTime = new ClubAvailableTimeDao().ListClubAvailableTime(id); ViewBag.ListAvailableTime = listAvailableTime; return(View(club)); }
public ActionResult Edit(long id) { var club = new ClubDao().GetByID(id); var listPlayer = new ClubPlayerDao().ListClubPlayer(id); ViewBag.ListPlayer = listPlayer; return(View(club)); }
////Display, create, edit, delete Club //Index page of Club management public ActionResult Index(string searchString, int page = 1, int pageSize = 10) { var dao = new ClubDao(); var model = dao.ListAllPaging(searchString, page, pageSize); ViewBag.SearchString = searchString; ViewBag.PageSize = pageSize; return(View(model)); }
public void RegisterDaos() { UserDao = new UserDao(); TeamDao = new TeamDao(); ClubDao = new ClubDao(); NewsDao = new NewsDao(); TeamUserDao = new TeamUserDao(); EventDao = new EventDao(); AttendantDao = new AttendantDao(); }
//List all Club when having a keyword public JsonResult ListClub(string q) { var data = new ClubDao().ListClub(q); return(Json(new { data = data, status = true }, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(long id) { var club = new ClubDao().GetByID(id); long ownerId = 0; if (club != null) { ownerId = (long)club.OwnerID; } ViewBag.OwnerID = ownerId; return(View(club)); }
public ActionResult Create(Club club) { if (ModelState.IsValid) { //Xử lý MetaTitle if (!string.IsNullOrEmpty(club.Name)) { club.MetaTitle = StringHelper.ToUnsignString(club.Name); } var userSession = (UserLogin)Session[FootballFlick.Common.CommonConstants.USER_SESSION]; club.OwnerID = userSession.UserID; var dao = new ClubDao(); if (dao.CheckCode(club.Code) == false) { long id = dao.Insert(club); if (id > 0) { //Tự động Insert level của Club vào ClubLevel ClubLevel clubLevel = new ClubLevel() { ClubID = id, LevelID = 1, Date = DateTime.Now }; bool resLv = new ClubLevelDao().Insert(clubLevel); if (resLv == false) { ModelState.AddModelError("", "Automatically create ClubLevel failed."); } ViewBag.Success = "Create your Club successfully"; } else { ModelState.AddModelError("", "Create a new club failed."); } } else { ModelState.AddModelError("", "The Code already exists. Please try another Code."); } } return(View(club)); }
public ActionResult Create(Club club) { if (ModelState.IsValid) { //Xử lý MetaTitle if (!string.IsNullOrEmpty(club.Name)) { club.MetaTitle = StringHelper.ToUnsignString(club.Name); } var dao = new ClubDao(); if (dao.CheckCode(club.Code) == false) { //Insert Club vào database long id = dao.Insert(club); if (id > 0) { //Tự động Insert level của Club vào ClubLevel ClubLevel clubLevel = new ClubLevel() { ClubID = id, LevelID = 1, Date = DateTime.Now }; bool resLv = new ClubLevelDao().Insert(clubLevel); if (resLv == false) { ModelState.AddModelError("", "Automatically create ClubLevel failed."); } //Thông báo tạo mới thành công SetAlert("Create a new club successfully.", "success"); return(RedirectToAction("Index", "Club")); } else { ModelState.AddModelError("", "Create a new club failed."); } } else { ModelState.AddModelError("", "The Code already exists. Please try another Code."); } } return(View(club)); }
public ActionResult Edit(Club club) { if (ModelState.IsValid) { if (!string.IsNullOrEmpty(club.Name)) { club.MetaTitle = StringHelper.ToUnsignString(club.Name); } var result = new ClubDao().Update(club, 1); if (result) { SetAlert("Edit this club successfully.", "success"); } else { ModelState.AddModelError("", "Edit this club failed."); } } return(View(club)); }
//Dislay all information about the Club public ActionResult Detail(long id, int pageIndex = 1, int pageSize = 10) { var club = new ClubDao().GetViewModelByID(id); var rankInfor = new ClubDao().DisplayRankedClub(id); ViewBag.RankInfor = rankInfor; //Liệt kê danh sách các Player của Club var listPlayer = new ClubPlayerDao().ListClubPlayer(id); ViewBag.ListPlayer = listPlayer; //Phân trang cho bảng liệt kê các Matches int totalRecord = 0; var listMatch = new MatchDao().ListMatchesOftheClub(id, ref totalRecord, pageIndex, pageSize); ViewBag.ListMatch = listMatch; ViewBag.Total = totalRecord; ViewBag.Page = pageIndex; int maxPage = 5; int totalPage = 0; if (totalRecord % pageSize != 0) { totalPage = (int)(totalRecord / pageSize) + 1; } else { totalPage = (int)(totalRecord / pageSize); } ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = pageIndex + 1; ViewBag.Prev = pageIndex - 1; return(View(club)); }
//Rank all Clubs of the system public ActionResult Rank(int?levelId, string searchString, int pageIndex = 1, int pageSize = 10) { int totalRecord = 0; var model = new ClubDao().DisplayListRankedClub(levelId, searchString, ref totalRecord, pageIndex, pageSize); ViewBag.SearchString = searchString; Level selectedLevel = new Level(); if (levelId != null) { selectedLevel = new LevelDao().GetByID((int)levelId); } ViewBag.SelectedLevel = selectedLevel; ViewBag.Total = totalRecord; ViewBag.Page = pageIndex; int maxPage = 5; int totalPage = 0; if (totalRecord % pageSize != 0) { totalPage = (int)(totalRecord / pageSize) + 1; } else { totalPage = (int)(totalRecord / pageSize); } ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = pageIndex + 1; ViewBag.Prev = pageIndex - 1; return(View(model)); }
// GET: ClubPlayer public ActionResult Index(long clubId, int pageIndex = 1, int pageSize = 10) { int totalRecord = 0; var model = new ClubPlayerDao().ListClubPlayerPageList(clubId, ref totalRecord, pageIndex, pageSize); ViewBag.Total = totalRecord; ViewBag.Page = pageIndex; var club = new ClubDao().GetByID(clubId); ViewBag.OwnerID = club.OwnerID; ViewBag.ClubID = club.ID; ViewBag.ClubCode = club.Code; ViewBag.ClubName = club.Name; int maxPage = 5; int totalPage = 0; if (totalRecord % pageSize != 0) { totalPage = (int)(totalRecord / pageSize) + 1; } else { totalPage = (int)(totalRecord / pageSize); } ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = pageIndex + 1; ViewBag.Prev = pageIndex - 1; return(View(model)); }
public ActionResult Edit(long id) { var club = new ClubDao().GetByID(id); return(View(club)); }