public static void SetUserAccess(Guid id) { try { JamiyahDBEntities db = new JamiyahDBEntities(); GlobalClass.FormList = new List <UserFormClass>(); var tf = (from x in db.UserGroupForm where x.UserGroupKey == id && x.Forms.IsDelete == false orderby x.Forms.FormLevel select new UserFormClass { FormID = x.FormKey, ModuleID = x.ModuleKey, FormName = x.Forms.FormName, FormLevel = x.Forms.FormLevel, FormController = x.Forms.FormController, FormView = x.Forms.FormView, FormCss = x.Forms.FormCss, }); GlobalClass.FormList = tf.ToList(); GlobalClass.ModuleList = new List <UserModuleClass>(); var mm = (from x in db.UserGroupModule where x.UserGroupKey == id && x.Modules.IsDelete == false orderby x.Modules.ModuleLevel select new UserModuleClass { UserGroupModuleKey = x.UserGroupModuleKey, UserGroupKey = x.UserGroupKey, ModuleKey = x.ModuleKey, ModuleName = x.Modules.ModuleName, Level = x.Modules.ModuleLevel, formList = ((from g in db.UserGroupForm where g.UserGroupKey == x.UserGroupKey && g.ModuleKey == x.ModuleKey && g.Forms.IsDelete == false orderby g.Forms.FormLevel select new UserFormClass { FormID = g.FormKey, ModuleID = g.ModuleKey, FormName = g.Forms.FormName, FormLevel = g.Forms.FormLevel, FormController = g.Forms.FormController, FormView = g.Forms.FormView, FormCss = g.Forms.FormCss, })).ToList() }); GlobalClass.ModuleList = mm.ToList(); } catch (Exception ex) { string temp = ex.Message.ToString(); } }
public ActionResult PreviousBoardExam(int id) { StudentInfoViewModel model = new StudentInfoViewModel(); model.PreviousInstitutionList = new List <StudentInfoPreviousInstitutionViewModel>(); model.Id = id; //var entity = db.StudentInfoPreviousInstitution.Where(m=>m.StudentInfo_FK == id); var p = db.StudentInfoPreviousInstitution.Any(m => m.StudentInfo_FK == id); if (p == false) { using (var _sdb = new JamiyahDBEntities()) { foreach (var item in _sdb.BoardExamination) { StudentInfoPreviousInstitutionViewModel _institutionObj = new StudentInfoPreviousInstitutionViewModel(); _institutionObj.ExamName = item.ExminationName; StudentInfoPreviousInstitution _studentInfoPreviousInstitutionEntity = new StudentInfoPreviousInstitution(); _studentInfoPreviousInstitutionEntity.ExamName = _institutionObj.ExamName; _studentInfoPreviousInstitutionEntity.StudentInfo_FK = id; _sdb.StudentInfoPreviousInstitution.Add(_studentInfoPreviousInstitutionEntity); // db.SaveChanges(); } //save at the end _sdb.SaveChanges(); } } IQueryable <StudentInfoPreviousInstitution> query = db.StudentInfoPreviousInstitution.Where(m => m.StudentInfo_FK == id); var data = query.Select(asset => new StudentInfoPreviousInstitutionViewModel() { Id = asset.Id, StudentInfo_FK = asset.StudentInfo_FK, ExamName = asset.ExamName, ExamYear = asset.ExamYear, InstitutionName = asset.InstitutionName, InstitutionCode = asset.InstitutionCode, InstitutionDistrict = asset.InstitutionDistrict, RegiNo = asset.RegiNo, RollNo = asset.RollNo, Grade = asset.Grade }).ToList(); model.PreviousInstitutionList = data; return(View(model)); }
public ActionResult Create(StudentInfoViewModel model, HttpPostedFileBase PostedLogo) { if (ModelState.IsValid) { StudentInfo entity = new StudentInfo(); if (PostedLogo != null) { byte[] imgBinaryData = new byte[PostedLogo.ContentLength]; int readresult = PostedLogo.InputStream.Read(imgBinaryData, 0, PostedLogo.ContentLength); entity.StudentPhoto = imgBinaryData; } entity.StudentNameBangla = model.StudentNameBangla; entity.StudentNameEnglish = model.StudentNameEnglish; entity.StudentNameArabic = model.StudentNameArabic; entity.StudentDateOfBirth = model.StudentDateOfBirth; entity.GenderId = model.GenderId; entity.Nationality = model.Nationality; entity.FatherNameBangla = model.FatherNameBangla; entity.FatherNameEnglish = model.FatherNameEnglish; entity.FatherIsAlive = model.FatherIsAlive; entity.FatherOccupation = model.FatherOccupation; entity.MotherNameBangla = model.MotherNameBangla; entity.MotherNameEnglish = model.MotherNameEnglish; entity.MotherIsAlive = model.MotherIsAlive; entity.MotherMobile = model.MotherMobile; entity.GuardianName = model.GuardianName; entity.GuardianOccupation = model.GuardianOccupation; entity.GuardianHouseNo = model.GuardianHouseNo; entity.GuardianVillage = model.GuardianVillage; entity.GuardianPostOffice = model.GuardianPostOffice; entity.GuardianThana = model.GuardianThana; entity.GuardianDistrict = model.GuardianDistrict; entity.RelationWithGuardian = model.RelationWithGuardian; entity.YearlyIncomeGuardian = model.YearlyIncomeGuardian; entity.PermanentAddressHouse = model.PermanentAddressHouse; entity.PermanentAddressVillage = model.PermanentAddressVillage; entity.PermanentAddressPostOffice = model.PermanentAddressPostOffice; entity.PermanentAddressThana = model.PermanentAddressThana; entity.PermanentAddressDistrict = model.PermanentAddressDistrict; entity.HonarablePersonNameInArea = model.HonarablePersonNameInArea; entity.PreviousInstitutionName = model.PreviousInstitutionName; entity.PreviousInstitutionAddress = model.PreviousInstitutionAddress; entity.PreviousInstitutionClass = model.PreviousInstitutionClass; entity.PreviousInstitutionClearanceNo = model.PreviousInstitutionClearanceNo; entity.PreviousInstitutionClearanceDate = model.PreviousInstitutionClearanceDate; entity.AdmittedDepartmentId = model.AdmittedDepartmentId; entity.Brach = model.AdmittedBranchId; entity.IsAssign = false; db.StudentInfo.Add(entity); db.SaveChanges(); model.Id = entity.Id; // var entity = db.BoardExamination.All(); var p = db.StudentInfoPreviousInstitution.Any(m => m.StudentInfo_FK == model.Id); if (p == false) { using (var _sdb = new JamiyahDBEntities()) { foreach (var item in _sdb.BoardExamination) { StudentInfoPreviousInstitutionViewModel _institutionObj = new StudentInfoPreviousInstitutionViewModel(); _institutionObj.ExamName = item.ExminationName; StudentInfoPreviousInstitution _studentInfoPreviousInstitutionEntity = new StudentInfoPreviousInstitution(); _studentInfoPreviousInstitutionEntity.ExamName = _institutionObj.ExamName; _studentInfoPreviousInstitutionEntity.StudentInfo_FK = model.Id; _sdb.StudentInfoPreviousInstitution.Add(_studentInfoPreviousInstitutionEntity); // db.SaveChanges(); } //save at the end _sdb.SaveChanges(); } } return(RedirectToAction("Edit", new { id = model.Id })); } ViewBag.GenderId = new SelectList(db.Gender.OrderBy(m => m.GenderName), "Id", "GenderName"); ViewBag.AdmittedDepartmentId = new SelectList(db.Department.OrderBy(m => m.Name), "Id", "Name"); ViewBag.BranchId = new SelectList(db.Company.OrderBy(m => m.CompanyName), "CompanyKey", "CompanyName"); return(View(model)); }