public ActionResult Register(string mode, string id) { Models.StudentVM studView = new Models.StudentVM(); studView.UserDetails = new UserMasterDTO(); studView.MODE = mode; studView.DisabledClass = ""; if (string.Equals(mode, "EDIT", StringComparison.OrdinalIgnoreCase)) { studView.UserDetails.UserMasterId = int.Parse(id); } if (string.Equals(mode, "VIEW", StringComparison.OrdinalIgnoreCase)) { studView.DisabledClass = "disabledPlace"; } studView.Transactions = new List <UserTransactionDTO>(); if (mode != null && (string.Equals(mode, "EDIT", StringComparison.OrdinalIgnoreCase) || string.Equals(mode, "VIEW", StringComparison.OrdinalIgnoreCase))) { //Populate edit data using id passed in URL, if id==null then show error message StatusDTO <StudentDTO> dto = _studSvc.Select(Convert.ToInt32(id)); studView.UserDetails = new UserMasterDTO(); studView.UserDetails.UserMasterId = dto.ReturnObj.UserDetails.UserMasterId; //uvModel.UserMasterId = dto.ReturnObj.UserMasterId; studView.UserDetails.FName = dto.ReturnObj.UserDetails.FName; studView.UserDetails.MName = dto.ReturnObj.UserDetails.MName; studView.UserDetails.LName = dto.ReturnObj.UserDetails.LName; studView.UserDetails.Gender = dto.ReturnObj.UserDetails.Gender; studView.UserDetails.Image = dto.ReturnObj.UserDetails.Image; studView.UserDetails.DOB = dto.ReturnObj.UserDetails.DOB; studView.DOBString = studView.UserDetails.DOB.HasValue ? studView.UserDetails.DOB.Value.ToString("dd-MMM-yyyy") : string.Empty; studView.UserDetails.EmailId = dto.ReturnObj.UserDetails.EmailId; studView.UserDetails.ResidentialAddress = dto.ReturnObj.UserDetails.ResidentialAddress; studView.UserDetails.PermanentAddress = dto.ReturnObj.UserDetails.PermanentAddress; studView.UserDetails.ContactNo = dto.ReturnObj.UserDetails.ContactNo; studView.UserDetails.AltContactNo = dto.ReturnObj.UserDetails.AltContactNo; studView.UserDetails.BloodGroup = dto.ReturnObj.UserDetails.BloodGroup; studView.UserDetails.Location = dto.ReturnObj.UserDetails.Location; studView.UserDetails.Role = dto.ReturnObj.UserDetails.Role; //studView.Student = new StudentDTO(); studView.RollNumber = dto.ReturnObj.RollNumber; studView.RegistrationNumber = dto.ReturnObj.RegistrationNumber; studView.AdmissionDate = dto.ReturnObj.AdmissionDate; studView.FatherContact = dto.ReturnObj.FatherContact; studView.GuardianName = dto.ReturnObj.GuardianName; studView.FatherEmailId = dto.ReturnObj.FatherEmailId; studView.HouseType = dto.ReturnObj.HouseType; studView.StandardSectionMap = dto.ReturnObj.StandardSectionMap; studView.FatherName = dto.ReturnObj.FatherName; studView.FatherQualification = dto.ReturnObj.FatherQualification; studView.FatherOccupation = dto.ReturnObj.FatherOccupation; studView.FatherDesignation = dto.ReturnObj.FatherDesignation; studView.FatherOrganisationName = dto.ReturnObj.FatherOrganisationName; studView.MotherName = dto.ReturnObj.MotherName; studView.MotherQualification = dto.ReturnObj.MotherQualification; studView.MotherOccupation = dto.ReturnObj.MotherOccupation; studView.MotherAnnualIncome = dto.ReturnObj.MotherAnnualIncome; studView.MotherOrganisationName = dto.ReturnObj.MotherOrganisationName; studView.IsChristian = dto.ReturnObj.IsChristian; studView.IsParentTeacher = dto.ReturnObj.IsParentTeacher; studView.SubjectNameTheyTeach = dto.ReturnObj.SubjectNameTheyTeach; studView.IsParentFromEngMedium = dto.ReturnObj.IsParentFromEngMedium; studView.IsJointOrNuclearFamily = dto.ReturnObj.IsJointOrNuclearFamily; studView.SiblingsInStadOrNot = dto.ReturnObj.SiblingsInStadOrNot; studView.AnyAlumuniMember = dto.ReturnObj.AnyAlumuniMember; studView.StuInPrivateTution = dto.ReturnObj.StuInPrivateTution; studView.NoOfTution = dto.ReturnObj.NoOfTution; studView.FeesPaidForTution = dto.ReturnObj.FeesPaidForTution; studView.Transactions = _userTrans.GetUserTransactions(dto.ReturnObj.UserDetails.UserMasterId); studView.TransactionMasters = _uiddlRepo.getTransactionMasters(); string studentImageFolder = _configSvc.GetStudentImagesFolder(); string fatherImageFolder = _configSvc.GetFatherImagesFolder(); string motherImageFolder = _configSvc.GetMotherImagesFolder(); studView.StudentImagePath = _configSvc.GetStudentImagesRelPath() + "/" + GetImageFileName(studView.RegistrationNumber, studentImageFolder); studView.FatherImagePath = _configSvc.GetFatherImagesRelPath() + "/" + GetImageFileName(studView.RegistrationNumber, fatherImageFolder); studView.MotherImagePath = _configSvc.GetMotherImagesRelPath() + "/" + GetImageFileName(studView.RegistrationNumber, motherImageFolder); } //studView.Transactions = _userTrans.GetUserTransactions(dto.ReturnObj.UserDetails.UserMasterId); studView.TransactionMasters = _uiddlRepo.getTransactionMasters(); studView.CalcInSelectList = _uiddlRepo.getCalcTypeDic(); studView.TransactionMasterSelectList = _dropDwnRepo.GetTransactionMasters(); studView.GenderList = _uiddlRepo.getGenderDropDown(); studView.LocationList = _uiddlRepo.getLocationDropDown(); studView.RoleList = _uiddlRepo.getRoleDropDown(); studView.ClassTypeList = _uiddlRepo.getClassTypeDropDown(); studView.SectionList = _uiddlRepo.getSectionDropDown(); studView.HouseList = _uiddlRepo.getHouseDropDown(); studView.IsChristianList = _uiddlRepo.getSelectValueDropDown(); studView.IsParentTeacherList = _uiddlRepo.getSelectValueDropDown(); studView.IsParentFromEngMedList = _uiddlRepo.getSelectValueDropDown(); studView.JointOrNuclearFamilyList = _uiddlRepo.getSelectJointNuclearDropDown(); studView.SiblingsInStdOrNotList = _uiddlRepo.getSelectValueDropDown(); studView.AnyAlumunimemberList = _uiddlRepo.getSelectValueDropDown(); studView.StudentinPvtTutionList = _uiddlRepo.getSelectValueDropDown(); //uvModel.BookCategoryList = _uiddlRepo.getBookCategoryDropDown(); //uvModel.DepartmentList = _uiddlRepo.getDepartmentDropDown(); //uvModel.DesignationList = _uiddlRepo.getDesignationDropDown(); studView.StandardSectionList = _uiddlRepo.getStandardSectionDropDown(); studView.GraceAmountOnList = _uiddlRepo.getCalcType(); return(View(studView)); }
public ActionResult Register(Models.StudentVM studentView, HttpPostedFileBase file) { string folderName = string.Empty; if (file != null) { if (file.ContentLength > 0) { for (int i = 0; i < Request.Files.Count; i++) { string keyName = Request.Files.Keys[i]; switch (keyName) { case "fuFatherImage": folderName = _configSvc.GetFatherImagesFolder(); break; case "fuMotherImage": folderName = _configSvc.GetMotherImagesFolder(); break; case "fuStudentImage": folderName = _configSvc.GetStudentImagesFolder(); break; } SaveImageFiles(folderName, Request.Files[i].FileName, studentView.RegistrationNumber); } } } DateTime dtValidator = new DateTime(); if (DateTime.TryParse(studentView.DOBString, out dtValidator)) { if (studentView.UserDetails == null) { studentView.UserDetails = new UserMasterDTO(); } studentView.UserDetails.DOB = dtValidator; } if (string.Equals(studentView.MODE, "EDIT", StringComparison.OrdinalIgnoreCase)) { //Call update //if (ModelState.IsValid) //{ StatusDTO <StudentDTO> status = _studSvc.Update(studentView); if (status.IsSuccess) { if (studentView.Transactions != null && studentView.Transactions.Count > 0) { for (int i = 0; i < studentView.Transactions.Count; i++) { if (studentView.Transactions[i].UserTransactionId > 0) { _userTrans.Update(studentView.Transactions[i]); } else { studentView.Transactions[i].User = new UserMasterDTO(); studentView.Transactions[i].User.UserMasterId = studentView.UserDetails.UserMasterId; _userTrans.Insert(studentView.Transactions[i]); } } } return(RedirectToAction("Search")); } studentView.ErrorMessage = status.FailureReason; //} } else { //Call insert //if (ModelState.IsValid) //{ string pass = !string.IsNullOrEmpty(studentView.UserDetails.Password)? encrypt.encryption(studentView.UserDetails.Password):null; studentView.UserDetails.Password = pass; StatusDTO <StudentDTO> status = _studSvc.Insert(studentView); studentView.UserDetails = new UserMasterDTO(); studentView.UserDetails.UserMasterId = status.ReturnObj.UserDetails.UserMasterId; if (status.IsSuccess) { if (studentView.Transactions != null && studentView.Transactions.Count > 0) { for (int i = 0; i < studentView.Transactions.Count; i++) { if (studentView.Transactions[i].UserTransactionId > 0) { _userTrans.Update(studentView.Transactions[i]); } else { studentView.Transactions[i].User = new UserMasterDTO(); studentView.Transactions[i].User.UserMasterId = status.ReturnObj.UserDetails.UserMasterId; _userTrans.Insert(studentView.Transactions[i]); } } } //return RedirectToAction("Register", new { mode = "EDIT", id = studentView.UserDetails.UserMasterId.ToString() }); return(RedirectToAction("Search")); } studentView.ErrorMessage = status.FailureReason; //} } //if(ModelState.IsValid) //{ //} //ModelState.Clear(); studentView.TransactionMasters = _uiddlRepo.getTransactionMasters(); studentView.GraceAmountOnList = _uiddlRepo.getCalcType(); studentView.CalcInSelectList = _uiddlRepo.getCalcTypeDic(); studentView.TransactionMasterSelectList = _dropDwnRepo.GetTransactionMasters(); studentView.GenderList = _uiddlRepo.getGenderDropDown(); studentView.LocationList = _uiddlRepo.getLocationDropDown(); studentView.RoleList = _uiddlRepo.getRoleDropDown(); //uvModel.ClassTypeList = _uiddlRepo.getClassTypeDropDown(); studentView.SectionList = _uiddlRepo.getSectionDropDown(); studentView.HouseList = _uiddlRepo.getHouseDropDown(); //uvModel.BookCategoryList = _uiddlRepo.getBookCategoryDropDown(); //uvModel.DepartmentList = _uiddlRepo.getDepartmentDropDown(); //uvModel.DesignationList = _uiddlRepo.getDesignationDropDown(); studentView.StandardSectionList = _uiddlRepo.getStandardSectionDropDown(); studentView.Transactions = _userTrans.GetUserTransactions(studentView.UserDetails.UserMasterId); return(View(studentView)); }