public async Task <CommonResponce> UpdateSubject(SubjectMasterVM oSubjectToUpdate) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "" }; bool isValid = false; try { var oSubject = await _DBSubjectRepository.GetSubjectBySubjectId(oSubjectToUpdate.Id).ConfigureAwait(false); if (oSubject != null) { oSubject.Name = oSubjectToUpdate.Name; _commonRepository.Update(oSubject); result.Stat = true; result.StatusMsg = "Subject information updated successfully"; } else // subject not found { result.StatusMsg = "Not a valid Subject"; } } catch { result.Stat = isValid; result.StatusMsg = "Failed to update subject information"; } return(result); }
public async Task <CommonResponce> UpdateStandard(StandardMasterVM oStandardToUpdate) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "" }; bool isValid = false; try { var oStandard = await _DBStandardMasterRepository.GetStandardByStandardID(oStandardToUpdate.Id).ConfigureAwait(false); if (oStandard != null) { oStandard.Name = oStandardToUpdate.Name; _commonRepository.Update(oStandard); result.Stat = true; result.StatusMsg = "Standard information updated successfully"; } else // student not found { result.StatusMsg = "Not a valid Standard"; } } catch { result.Stat = isValid; result.StatusMsg = "Failed to update Standard information"; } return(result); }
public async Task <JsonResult> AppSettings(SettingsVM model) { if (ModelState.IsValid) { CommonResponce result = null; string ActivityMsg = ""; if (model.Flag.Equals("GENERALSetting")) { result = await _AppSettingService.SaveGeneralSetting(model.AppGeneralSettings).ConfigureAwait(false); ActivityMsg = "Changed App Settings"; } else { result = await _AppSettingService.SaveMailSetting(model.MailSettings).ConfigureAwait(false); ActivityMsg = "Changed Email Settings"; } if (result.Stat) { await GetBaseService().AddActivity(ActivityType.Update, model.BUserID, model.BUserName, "Settings", ActivityMsg); return(Json(new { stat = true, msg = "Successfully Changed settings" })); } else { return(Json(new { stat = false, msg = result.StatusMsg })); } } else { return(Json(new { stat = false, msg = "Invalid application settings" })); } }
public async Task <CommonResponce> InsertStudentProfile(StudentProfileVM StudentToInsert) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "" }; CommonResponce DataValidationResult = new CommonResponce { Stat = false, StatusMsg = "" }; bool isValid = false; Tblmstudent oStudent = null; try { oStudent = new Tblmstudent { RegNo = StudentToInsert.RegNo, Name = StudentToInsert.Name, Address = StudentToInsert.Address, Email = StudentToInsert.Email, ContactNo = StudentToInsert.ContactNo, StandardId = StudentToInsert.StandardId, LoginUserId = StudentToInsert.LoginUserId }; //isValid = await _commonRepository.Insert(_mapper.Map<Tblmstudent>(StudentToInsert)); isValid = await _commonRepository.Insert(oStudent); result.Stat = isValid; result.StatusMsg = "Student added successfully"; } catch { result.Stat = isValid; result.StatusMsg = "Failed to add new student"; } return(result); }
public async Task <CommonResponce> UpdateTeacherProfile(TeacherProfileVM TeacherToUpdate) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "" }; bool isValid = false; try { var oTeacher = await _DBTeacherRepository.GetTeacherByTeacherId(TeacherToUpdate.Id).ConfigureAwait(false); if (oTeacher != null) { oTeacher.RegNo = TeacherToUpdate.RegNo; oTeacher.Name = TeacherToUpdate.Name; oTeacher.Address = TeacherToUpdate.Address; oTeacher.Email = TeacherToUpdate.Email; oTeacher.ContactNo = TeacherToUpdate.ContactNo; oTeacher.EducationalQualification = TeacherToUpdate.EducationalQualification; _commonRepository.Update(oTeacher); result.Stat = true; result.StatusMsg = "Teacher information updated successfully"; } else // teacher not found { result.StatusMsg = "Not a valid Teacher"; } } catch { result.Stat = isValid; result.StatusMsg = "Failed to update teacher information"; } return(result); }
public async Task <CommonResponce> DeleteTeacherProfile(int TeacherId) { CommonResponce result = new CommonResponce() { Stat = false, StatusMsg = "Error in deleting Student" }; try { var oTeacher = await _DBTeacherRepository.GetTeacherByTeacherId(TeacherId).ConfigureAwait(false); // get teacher details from db if (oTeacher != null) // Teacher found { _commonRepository.Delete(oTeacher); result.Stat = true; result.StatusMsg = "Teacher deleted successfully"; } else { result.StatusMsg = "Not a valid Teacher"; } } catch { result.StatusMsg = "Failed to delete Teacher"; } return(result); }
public async Task <CommonResponce> UpdateStudentProfile(StudentProfileVM oStudentToUpdate) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "" }; bool isValid = false; try { var oStudent = await _DBStudentRepository.GetStudentByStudentId(oStudentToUpdate.Id).ConfigureAwait(false); if (oStudent != null) { oStudent.RegNo = oStudentToUpdate.RegNo; oStudent.Name = oStudentToUpdate.Name; oStudent.Address = oStudentToUpdate.Address; oStudent.Email = oStudentToUpdate.Email; oStudent.ContactNo = oStudentToUpdate.ContactNo; oStudent.StandardId = oStudentToUpdate.StandardId; _commonRepository.Update(oStudent); result.Stat = true; result.StatusMsg = "Student information updated successfully"; } else // student not found { result.StatusMsg = "Not a valid Student"; } } catch { result.Stat = isValid; result.StatusMsg = "Failed to update student information"; } return(result); }
public async Task <CommonResponce> InsertTeacherProfile(TeacherProfileVM TeacherToInsert) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "" }; bool isValid = false; try { Tblmteacher oTeacher = new Tblmteacher { RegNo = TeacherToInsert.RegNo, Name = TeacherToInsert.Name, Address = TeacherToInsert.Address, Email = TeacherToInsert.Email, ContactNo = TeacherToInsert.ContactNo, EducationalQualification = TeacherToInsert.EducationalQualification, LoginUserId = TeacherToInsert.LoginUserId }; //isValid = await _commonRepository.Insert(_mapper.Map<Tblmstudent>(StudentToInsert)); isValid = await _commonRepository.Insert(oTeacher); result.Stat = isValid; result.StatusMsg = "Teacher added successfully"; } catch { result.Stat = isValid; result.StatusMsg = "Failed to add new teacher"; } return(result); }
public async Task <CommonResponce> ChangeProfilePasswordAsync(ChangeProfilePasswordVM oModel) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "" }; var oUser = await _DBUserRepository.GetUserByID(oModel.Id).ConfigureAwait(false); if (oUser != null) { if (oUser.Password.Equals(_AppEncription.EncriptWithPrivateKey(oModel.OldPassword))) { oUser.Password = _AppEncription.EncriptWithPrivateKey(oModel.NewPassword); await _DBUserRepository.Update(oUser).ConfigureAwait(false); result.Stat = true; result.StatusMsg = "Successfully changed User password"; } else { result.StatusMsg = "Old Password not Matched"; } } else { result.StatusMsg = "Not a valid User"; } return(result); }
public async Task <CommonResponce> UpdateAppUserProfileAsync(UserProfileVM oModel) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "" }; var oUser = await _DBUserRepository.GetUserByID(oModel.Id).ConfigureAwait(false); if (oUser != null) { oUser.Name = oModel.UserName; oUser.Email = oModel.Email; oUser.Mobile = oModel.Mobile; oUser.Dob = oModel.Dob; await _DBUserRepository.Update(oUser).ConfigureAwait(false); result.Stat = true; result.StatusMsg = "Successfully updated application User"; } else { result.StatusMsg = "Not a valid User"; } return(result); }
public async Task <CommonResponce> ResetUserPassByAdminAsync(long UID, string ResetContext, DateTime PasswordValidity) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "" }; Appuser oUser = await _DBUserRepository.GetUserByID(UID).ConfigureAwait(false); if (oUser != null) { oUser.IsPassReset = 1; oUser.ResetPassContext = ResetContext; oUser.ResetPassValidity = PasswordValidity; await _DBUserRepository.Update(oUser).ConfigureAwait(false); result.Stat = true; result.StatusMsg = "Successfully reset User password"; result.StatusObj = oUser; } else { result.StatusMsg = "Not a valid User"; } return(result); }
public async Task <CommonResponce> DeleteSubject(int SubjectId) { CommonResponce result = new CommonResponce() { Stat = false, StatusMsg = "Error in deleting Subject" }; try { var oSubject = await _DBSubjectRepository.GetSubjectBySubjectId(SubjectId).ConfigureAwait(false); // get subject details from db if (oSubject != null) // subject found { _commonRepository.Delete(oSubject); result.Stat = true; result.StatusMsg = "Subject deleted successfully"; } else { result.StatusMsg = "Not a valid Subject"; } } catch { result.StatusMsg = "Failed to delete Subject"; } return(result); }
public async Task <CommonResponce> DeleteClassroom(int ClassroomID) { CommonResponce result = new CommonResponce() { Stat = false, StatusMsg = "Error in deleting Classroom" }; try { var oClassroom = await _DBClassroomRepository.GetClassroomByClassroomId(ClassroomID); if (oClassroom != null) // Student found { _commonRepository.Delete(oClassroom); result.Stat = true; result.StatusMsg = "Classroom deleted successfully"; } else { result.StatusMsg = "Not a valid Student"; } } catch { result.StatusMsg = "Failed to delete Classroom"; } return(result); }
public async Task <CommonResponce> CheckDataValidation(StudentProfileVM StudentToInsert, bool IsAdd) { CommonResponce result = new CommonResponce { Stat = true, StatusMsg = "" }; Tblmstudent oStudent = null; if (IsAdd) // check validation while adding a new student { oStudent = await _DBStudentRepository.GetStudentByRegNo(StudentToInsert.RegNo).ConfigureAwait(false); if (oStudent != null) { result.Stat = false; result.StatusMsg = "Registration No already in use"; } else { oStudent = await _DBStudentRepository.GetStudentByEmailID(StudentToInsert.Email); if (oStudent != null) { result.Stat = false; result.StatusMsg = "Email Id already in use"; } } } else // validation while updating { oStudent = await _DBStudentRepository.GetStudentByRegNo(StudentToInsert.RegNo).ConfigureAwait(false); if (oStudent != null) // got result { if (StudentToInsert.Id != oStudent.Id) // different student with same reg no { result.Stat = false; result.StatusMsg = "Registration No already in use"; } else // same student found check duplicate email id { oStudent = await _DBStudentRepository.GetStudentByEmailID(StudentToInsert.Email); if (oStudent != null) { if (StudentToInsert.Id != oStudent.Id) // different student with same email id { result.Stat = false; } result.StatusMsg = "Email Id already in use"; } } } } return(result); }
public async Task <CommonResponce> SendEmailAsync(EmailMessage message) { CommonResponce commonResponse = new CommonResponce { Stat = false, StatusMsg = string.Empty }; var mailMessage = CreateEmailMessage(message); var Result = await SendAsync(mailMessage); commonResponse.Stat = Result == 1 ? true : false; commonResponse.StatusMsg = Result == 1 ? "Successfully mail sent" : ErrMsg; return(commonResponse); }
public async Task <IActionResult> UpdateStudentProfile(int StudentID) { CreateBreadCrumb(new[] { new { Name = "Home", ActionUrl = "#" }, new { Name = "Student", ActionUrl = "/Student/UpdateStudentProfile" } }); BaseViewModel VModel = null; CommonResponce CR = await _StudentService.GetStudentByStudentId(StudentID); if (CR.Stat) { List <StandardMasterBM> oAllStandards = await _StandardMasterService.GetAllStandards(500); Student StudentInfo = (Student)CR.StatusObj; //*****get user avtar************ //string UsrImgPath = string.Format("{0}\\{1}.{2}", Path.Combine(GetBaseService().GetAppRootPath(), "AppFileRepo\\StudentAvatar"), StudentInfo.RegNo, "jpg"); //if (System.IO.File.Exists(UsrImgPath)) // UsrImgPath = string.Format("~/AppFileRepo/StudentAvatar/{0}.{1}", StudentInfo.RegNo, "jpg"); //else // UsrImgPath = "~/img/avatar5.png"; var TempVModel = new StudentProfileVM { Id = StudentInfo.Id, Name = StudentInfo.Name, RegNo = StudentInfo.RegNo, Address = StudentInfo.Address, ContactNo = StudentInfo.ContactNo, Email = StudentInfo.Email, StandardId = StudentInfo.StandardId, StudentImgPath = "", AttachStudentImage = new FileUploadInfo() }; TempVModel.AllStandards.AddRange(oAllStandards);// all standard list //var TempVModel = new StudentProfileVM(); if (StudentInfo.LoginUserId != null) { var AppVM = await _AppUserService.GetAppUserByID((int)StudentInfo.LoginUserId); if (AppVM != null) { TempVModel.LoginId = AppVM.UserId; string UsrImgPath = string.Format("~/AppFileRepo/UserAvatar/{0}.{1}", TempVModel.LoginId, "jpg"); TempVModel.StudentImgPath = UsrImgPath; } } VModel = await GetViewModel(TempVModel); } //******************************* return(View("~/Views/Master/UpdateStudentProfile.cshtml", VModel)); }
public CommonResponce Delete(Classroom ClassroomToDelete) { CommonResponce result = new CommonResponce(); bool isValid = false; try { _commonRepository.Delete(_mapper.Map <Tblmclassroom>(ClassroomToDelete)); result.Stat = true; result.StatusMsg = "Classroom deleted successfully"; } catch { result.Stat = isValid; result.StatusMsg = "Failed to delete classroom information"; } return(result); }
public async Task <CommonResponce> DeleteAppUser(long Id) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "Error on deleting user" }; result.Stat = await _DBUserRepository.Delete(Id).ConfigureAwait(false); if (result.Stat) { result.StatusMsg = "Successfully deleted the user."; } return(result); }
public CommonResponce Delete(StudentClassroom StudentClassroomToDelete) { CommonResponce result = new CommonResponce(); bool isValid = false; try { _commonRepository.Delete(_mapper.Map <Tblrstudentclassroom>(StudentClassroomToDelete)); result.Stat = true; result.StatusMsg = "Student assignment to Classroom deleted successfully"; } catch { result.Stat = isValid; result.StatusMsg = "Failed to delete Student assignment to Classroom"; } return(result); }
public async Task <CommonResponce> GetTeacherByEmailID(string EmailID) { bool isValid = true; var oTeacher = await _DBTeacherRepository.GetTeacherByEmailID(EmailID); if (oTeacher == null) { isValid = false; } CommonResponce result = new CommonResponce { Stat = isValid, StatusMsg = (isValid ? "" : "Invalid Eamil id"), StatusObj = oTeacher }; return(result); }
public async Task <CommonResponce> GetClassroomByStandardID(int StandardID) { bool isValid = true; var oClassroom = await _DBClassroomRepository.GetClassroomByStandardID(StandardID); if (oClassroom == null) { isValid = false; } CommonResponce result = new CommonResponce { Stat = isValid, StatusMsg = (isValid ? "" : "Invalid Standard Id"), StatusObj = oClassroom }; return(result); }
public async Task <CommonResponce> Insert(Classroom ClassroomToInsert) { CommonResponce result = new CommonResponce(); bool isValid = false; try { isValid = await _commonRepository.Insert(_mapper.Map <Tblmclassroom>(ClassroomToInsert)); result.Stat = isValid; result.StatusMsg = "Classroom added successfully"; } catch (Exception ex) { result.Stat = isValid; result.StatusMsg = ex.Message + " Failed to add new Classroom"; } return(result); }
public async Task <CommonResponce> GetStudentByEmailID(string EmailID) { bool isValid = true; var oStudent = await _DBStudentRepository.GetStudentByEmailID(EmailID); if (oStudent == null) { isValid = false; } CommonResponce result = new CommonResponce { Stat = isValid, StatusMsg = (isValid ? "" : "Invalid Email ID"), StatusObj = oStudent }; return(result); }
public async Task <CommonResponce> GetStudentByRegNo(string RegNo) { bool isValid = true; var oStudent = await _DBStudentRepository.GetStudentByRegNo(RegNo); if (oStudent == null) { isValid = false; } CommonResponce result = new CommonResponce { Stat = isValid, StatusMsg = (isValid ? "" : "Invalid Student Registration No"), StatusObj = oStudent }; return(result); }
public async Task <CommonResponce> Insert(StudentClassroom StudentClassroomToInsert) { CommonResponce result = new CommonResponce(); bool isValid = false; try { isValid = await _commonRepository.Insert(_mapper.Map <Tblrstudentclassroom>(StudentClassroomToInsert)); result.Stat = isValid; result.StatusMsg = "Student assigned to Classroom successfully"; } catch (Exception ex) { result.Stat = isValid; result.StatusMsg = ex.Message + " Failed to assign Student to Classroom"; } return(result); }
public async Task <CommonResponce> GetSubjectBySubjectName(string SubjectName) { bool isValid = true; var oSubject = await _DBSubjectRepository.GetSubjectBySubjectName(SubjectName); if (oSubject == null) { isValid = false; } CommonResponce result = new CommonResponce { Stat = isValid, StatusMsg = (isValid ? "" : "Invalid Subject Name"), StatusObj = oSubject }; return(result); }
public async Task <CommonResponce> ResetUserPassAsync(UserResetVM oModel) { CommonResponce result = new CommonResponce { Stat = false, StatusMsg = "" }; try { Appuser oUser = await _DBUserRepository.GetUserByPassResetContext(oModel.UserResetContext).ConfigureAwait(false); if (oUser != null) { if (oUser.ResetPassValidity < DateTime.Now) { result.StatusMsg = "Reset Password Link has expired"; } else { if (oUser.IsActive == 1) { oUser.IsPassReset = 0; oUser.ResetPassContext = ""; oUser.Password = _AppEncription.EncriptWithPrivateKey(oModel.Password); await _DBUserRepository.Update(oUser).ConfigureAwait(false); result.Stat = true; result.StatusMsg = "Successfully reset user Password"; } else { result.StatusMsg = "User not valid or expired"; } } } else { result.StatusMsg = "Not a valid password reset link."; } } catch (Exception) { result.StatusMsg = "Not a valid password reset link (ex)."; } return(result); }
public async Task <JsonResult> UpdateStudentProfile(StudentProfileVM model) { CommonResponce result = null; if (ModelState.IsValid) { result = await _StudentService.CheckDataValidation(model, false); if (!result.Stat)// validation failed { return(Json(new { stat = false, msg = result.StatusMsg })); } result = await _StudentService.UpdateStudentProfile(model); if (result.Stat == true) { var CurrentUserInfo = GetLoginUserInfo();// get current user await GetBaseService().AddActivity(ActivityType.Update, CurrentUserInfo.UserID, CurrentUserInfo.UserName, "Student Profile", "Updated Student profile"); if (model.AttachStudentImage.FileSize > 0) { var RtnMsg = GetBaseService().DirectoryFileService.CreateUserAvatarFromBase64String(GetBaseService().GetAppRootPath(), model.LoginId, model.AttachStudentImage.FileContentsBase64); model.StudentImgPath = RtnMsg.StatusMsg; //string StudentImgPath = Path.Combine(GetBaseService().GetAppRootPath(), "AppFileRepo", "UserAvatar"); //if (GetBaseService().DirectoryFileService.CreateDirectoryIfNotExist(StudentImgPath)) //{ // StudentImgPath = Path.Combine(StudentImgPath, string.Format("{0}.{1}", model.LoginId, "jpg")); // if (GetBaseService().DirectoryFileService.CreateFileFromBase64String(model.AttachStudentImage.FileContentsBase64, StudentImgPath)) // { // model.StudentImgPath = string.Format("~/AppFileRepo/UserAvatar/{0}.{1}?r={2}", model.LoginId, "jpg", DateTime.Now.Ticks.ToString()); // //model.BUserImgPath = model.StudentImgPath; // update the Student avatar // } //} } return(Json(new { stat = true, msg = "Student Profile Updated", rtnUrl = "/Student/Students" })); } else { return(Json(new { stat = false, msg = result.StatusMsg })); } } else { return(Json(new { stat = false, msg = "Invalid Student Profile" })); } }
public async Task <JsonResult> ClassRoom(ClassRoomDetailsVM model) { if (ModelState.IsValid) { string TempMemberAsignList = string.Empty; CommonResponce result = null; string TempAsignKey = string.Format("{0}_{1}", model.TempClassRefId, "ClassTeacher"); model.AllTeachers = await _ClassroomService.GetAllClassMembers(500, "teacher").ConfigureAwait(false); model.AllStudents = await _ClassroomService.GetAllClassMembers(500, "student").ConfigureAwait(false); if (TempData.ContainsKey(TempAsignKey)) { TempMemberAsignList = TempData[TempAsignKey].ToString(); model.AsignTeacher = TempMemberAsignList.Split(','); } TempAsignKey = string.Format("{0}_{1}", model.TempClassRefId, "ClassStudent"); if (TempData.ContainsKey(TempAsignKey)) { TempMemberAsignList = TempData[TempAsignKey].ToString(); model.AsignStudent = TempMemberAsignList.Split(','); } // write the class save service if (model.Id > 0) { // write update logic result = await _ClassroomService.Update(model); } else { // write save logic result = await _ClassroomService.Insert(model); } return(Json(new { stat = result.Stat, msg = result.StatusMsg })); } else { return(Json(new { stat = false, msg = "Invalid Classroom data" })); } }
public async Task <CommonResponce> GetDeviceByCpuId(string CpuId) { Device device = null; bool isValid = false; var dbDevice = await _deviceRepository.GetDeviceByCpuId(CpuId.Trim()).ConfigureAwait(false); if (dbDevice != null) { device = _mapper.Map <Device>(dbDevice); isValid = true; } CommonResponce result = new CommonResponce { Stat = isValid, StatusMsg = "", StatusObj = device }; return(result); }