public bool LoadFromFile(string path) { BoxProductInfo.Init(new TableLoaderLocalCSV <int, TDataBoxOpenInfo>(), path, "BoxOpenInfo.csv"); CoopMode.Init(new TableLoaderLocalCSV <int, TDataCoopMode>(), path, "CoopMode.csv"); CoopModeMinion.Init(new TableLoaderLocalCSV <int, TDataCoopModeMinion>(), path, "CoopModeMinion.csv"); CoopModeBossInfo.Init(new TableLoaderLocalCSV <int, TDataCoopModeBossInfo>(), path, "CoopModeBossInfo.csv"); DiceInfo.Init(new TableLoaderLocalCSV <int, TDataDiceInfo>(), path, "DiceInfo.csv"); DiceUpgrade.Init(new TableLoaderLocalCSV <int, TDataDiceUpgrade>(), path, "DiceUpgrade.csv"); DiceLevelInfo.Init(new TableLoaderLocalCSV <int, TDataDiceLevelInfo>(), path, "DiceLevelInfo.csv"); GuardianInfo.Init(new TableLoaderLocalCSV <int, TDataGuardianInfo>(), path, "GuardianInfo.csv"); Vsmode.Init(new TableLoaderLocalCSV <int, TDataVsmode>(), path, "Vsmode.csv"); LangEN.Init(new TableLoaderLocalCSV <int, TDataLangEN>(), path, "LangEN.csv"); LangKO.Init(new TableLoaderLocalCSV <int, TDataLangKO>(), path, "LangKO.csv"); RankingReward.Init(new TableLoaderLocalCSV <int, TDataRankingReward>(), path, "RankingReward.csv"); ClassInfo.Init(new TableLoaderLocalCSV <int, TDataClassInfo>(), path, "ClassInfo.csv"); SeasonpassInfo.Init(new TableLoaderLocalCSV <int, TDataSeasonpassInfo>(), path, "SeasonpassInfo.csv"); SeasonpassReward.Init(new TableLoaderLocalCSV <int, TDataSeasonpassReward>(), path, "SeasonpassReward.csv"); ClassReward.Init(new TableLoaderLocalCSV <int, TDataClassReward>(), path, "ClassReward.csv"); ItemList.Init(new TableLoaderLocalCSV <int, TDataItemList>(), path, "ItemList.csv"); QuestInfo.Init(new TableLoaderLocalCSV <int, TDataQuestInfo>(), path, "QuestInfo.csv"); QuestData.Init(new TableLoaderLocalCSV <int, TDataQuestData>(), path, "QuestData.csv"); QuestDayReward.Init(new TableLoaderLocalCSV <int, TDataQuestDayReward>(), path, "QuestDayReward.csv"); ShopInfo.Init(new TableLoaderLocalCSV <int, TDataShopInfo>(), path, "ShopInfo.csv"); ShopProductList.Init(new TableLoaderLocalCSV <int, TDataShopProductList>(), path, "ShopProductList.csv"); MailInfo.Init(new TableLoaderLocalCSV <int, TDataMailInfo>(), path, "MailInfo.csv"); loaded = true; return(true); }
public async Task <IActionResult> UpdateStudent(StudentViewModel std) { //GEt the List of class var i = _context.Class.ToList(); ViewBag.Class = i; // Create a student and save to the database Student st = new Student() { StudentId = std.stdntidVM, StudentName = std.stdntnameVM, StudentCAddress = std.stdntcaddrssVM, StudentPAddress = std.stdntpaddrssVM, StudentNationality = std.stdntnationVM, StudentDOB = std.dobVM, StudentGender = std.stdntgenderVM, DateOfAdmission = std.stdntdoaVM, StudentClass = std.stdntclsVM, StudentPhoto = std.stdntphotoVM, Year = std.stdntyearVM, }; _context.Student.Update(st); await _context.SaveChangesAsync(); //Create guradian info for that student and save it GuardianInfo gi = new GuardianInfo() { SL = std.Serial, StudentID = std.stdntidVM, GNameF = std.gnameFVM, GNameM = std.gnameMVM, GPhoneF = std.gphoneFVM, GPhoneM = std.gphoneMVM, GEmailF = std.gemailFVM, GEmailM = std.gemailMVM, GOccupationF = std.goccupationFVM, GOccupationM = std.goccupationMVM, GOrganisationF = std.gorganisationFVM, GOrganisationM = std.gorganisationMVM, GDesignationF = std.gdesignationFVM, GDesignationM = std.gdesignationsMVM }; _context.GuardianInfo.Update(gi); await _context.SaveChangesAsync(); return(RedirectToAction("StudentList", "AdmissionOfficer")); }
public async Task <IActionResult> AddStudent(StudentViewModel std) { //GEt the List of class var i = _context.Class.ToList(); //Insert a new element in position 0 i.Insert(0, new Class { ClassId = 0, ClassName = "Select" }); ViewBag.Class = i; // Create a student and save to the database Student st = new Student() { StudentId = std.stdntidVM, StudentName = std.stdntnameVM, StudentCAddress = std.stdntcaddrssVM, StudentPAddress = std.stdntpaddrssVM, StudentNationality = std.stdntnationVM, StudentDOB = std.dobVM, StudentGender = std.stdntgenderVM, DateOfAdmission = DateTime.Now.Date, StudentClass = std.stdntclsVM, StudentPhoto = std.stdntphotoVM, Year = DateTime.Now.Year }; _context.Student.Add(st); await _context.SaveChangesAsync(); //Get the id of saved student var StudentId = st.StudentId; //Create guradian info for that student and save it GuardianInfo gi = new GuardianInfo() { SL = 0, StudentID = StudentId, GNameF = std.gnameFVM, GNameM = std.gnameMVM, GPhoneF = std.gphoneFVM, GPhoneM = std.gphoneMVM, GEmailF = std.gemailFVM, GEmailM = std.gemailMVM, GOccupationF = std.goccupationFVM, GOccupationM = std.goccupationMVM, GOrganisationF = std.gorganisationFVM, GOrganisationM = std.gorganisationMVM, GDesignationF = std.gdesignationFVM, GDesignationM = std.gdesignationsMVM }; _context.GuardianInfo.Add(gi); await _context.SaveChangesAsync(); // Create random password PasswordCreator ps = new PasswordCreator(); //Insert the login information for student login and save Login lg = new Login() { SL = 0, Username = StudentId.ToString(), Password = ps.RandomPassword(), FirstLoginStatus = true, ActiveStatus = true, RoleId = 1, DistinguishId = StudentId, }; lg.CurrentPassword = lg.Password; _context.Login.Add(lg); await _context.SaveChangesAsync(); //Clear the modelstate ModelState.Clear(); return(View()); }
public async Task <IActionResult> UpdateStudent(StudentVm std, IFormFile image) { //GEt the List of class var i = _context.Class.ToList(); ViewBag.Class = i; if (ModelState.IsValid) { // Update a student and save to the database Student st = new Student() { StudentId = std.stdntidVM, StudentName = std.stdntnameVM, StudentCAddress = std.stdntcaddrssVM, StudentPAddress = std.stdntpaddrssVM, StudentNationality = std.stdntnationVM, StudentDOB = std.dobVM, StudentGender = std.stdntgenderVM, DateOfAdmission = std.stdntdoaVM, ClassId = std.stdntclsVM, StudentPhoto = std.stdntphotoVM, Year = std.stdntyearVM, SectionId = std.SectionId }; string un = null; if (image != null) { if (st.StudentPhoto != null) { /// Delete Existing Image var path = Path.Combine(_imagepath.WebRootPath + "/images"); string filepath = Path.Combine(path, st.StudentPhoto); if (System.IO.File.Exists(filepath)) { System.IO.File.Delete(filepath); } st.StudentPhoto = null; path = null; un = null; filepath = null; ///Update Image path = Path.Combine(_imagepath.WebRootPath + "/images"); un = Guid.NewGuid().ToString() + "_" + image.FileName; filepath = Path.Combine(path, un); using (var file = new FileStream(filepath, FileMode.Create)) { await image.CopyToAsync(file); } st.StudentPhoto = un; } else { var path = Path.Combine(_imagepath.WebRootPath + "/images"); un = Guid.NewGuid().ToString() + "_" + image.FileName; string filepath = Path.Combine(path, un); using (var file = new FileStream(filepath, FileMode.Create)) { await image.CopyToAsync(file); } st.StudentPhoto = un; } } _context.Student.Update(st); await _context.SaveChangesAsync(); //Create guradian info for that student and save it GuardianInfo gi = new GuardianInfo() { GuardianInfoId = std.Serial, StudentId = std.stdntidVM, GNameF = std.gnameFVM, GNameM = std.gnameMVM, GPhoneF = std.gphoneFVM, GPhoneM = std.gphoneMVM, GEmailF = std.gemailFVM, GEmailM = std.gemailMVM, GOccupationF = std.goccupationFVM, GOccupationM = std.goccupationMVM, GOrganisationF = std.gorganisationFVM, GOrganisationM = std.gorganisationMVM, GDesignationF = std.gdesignationFVM, GDesignationM = std.gdesignationsMVM }; _context.GuardianInfo.Update(gi); await _context.SaveChangesAsync(); return(RedirectToAction("StudentList")); } else { return(View()); } }
public async Task <IActionResult> AddStudent(StudentVm std, IFormFile image) { if (ModelState.IsValid && std.stdntclsVM != 0) { //GEt the List of class var i = _context.Class.ToList(); //Insert a new element in position 0 i.Insert(0, new Class { ClassId = 0, ClassName = "Select" }); ViewBag.Class = i; // Create a student and save to the database if (std.stdntclsVM == 0) { ViewBag.Message = "Please enter a valid class"; return(View()); } var sectioncapacity = await _context.SectionCapacity.AsNoTracking().Where(s => s.ClassId == std.stdntclsVM).ToListAsync(); int finalsection = 0; for (int k = 0; k < sectioncapacity.Count; k++) { var secid = sectioncapacity[k].SectionId; var seccapacity = sectioncapacity[k].Capacity; var countStudent = await _context.Student.AsNoTracking().Where(s => s.SectionId == secid).ToListAsync(); if (seccapacity > countStudent.Count) { finalsection = secid; break; } } Student st = new Student() { StudentId = std.stdntidVM, StudentName = std.stdntnameVM, StudentCAddress = std.stdntcaddrssVM, StudentPAddress = std.stdntpaddrssVM, StudentNationality = std.stdntnationVM, StudentDOB = std.dobVM, StudentGender = std.stdntgenderVM, DateOfAdmission = DateTime.Now.Date, ClassId = std.stdntclsVM, StudentPhoto = null, Year = DateTime.Now.Year }; st.SectionId = finalsection; string un = null; if (image != null) { var path = Path.Combine(_imagepath.WebRootPath + "/images"); un = Guid.NewGuid().ToString() + "_" + image.FileName; string filepath = Path.Combine(path, un); using (var file = new FileStream(filepath, FileMode.Create)) { await image.CopyToAsync(file); } st.StudentPhoto = un; } _context.Student.Add(st); await _context.SaveChangesAsync(); //Get the id of saved student var StudentId = st.StudentId; //Create guradian info for that student and save it GuardianInfo gi = new GuardianInfo() { GuardianInfoId = 0, StudentId = StudentId, GNameF = std.gnameFVM, GNameM = std.gnameMVM, GPhoneF = std.gphoneFVM, GPhoneM = std.gphoneMVM, GEmailF = std.gemailFVM, GEmailM = std.gemailMVM, GOccupationF = std.goccupationFVM, GOccupationM = std.goccupationMVM, GOrganisationF = std.gorganisationFVM, GOrganisationM = std.gorganisationMVM, GDesignationF = std.gdesignationFVM, GDesignationM = std.gdesignationsMVM }; _context.GuardianInfo.Add(gi); await _context.SaveChangesAsync(); // Create random password PasswordGenerator ps = new PasswordGenerator(); //Insert the login information for student login and save Login lg = new Login() { LoginId = 0, Username = StudentId.ToString(), Password = ps.RandomPassword(), FirstLoginStatus = true, ActiveStatus = true, RoleId = 1, DistinguishId = StudentId, }; lg.CurrentPassword = lg.Password; _context.Login.Add(lg); await _context.SaveChangesAsync(); //Clear the modelstate ModelState.Clear(); return(View()); } else { //Get the List of class var i = _context.Class.ToList(); //insert a new element in position 0 i.Insert(0, new Class { ClassId = 0, ClassName = "Select" }); ViewBag.Class = i; return(View()); } }