Beispiel #1
0
        public async Task <IActionResult> TeacherProfile()
        {
            CreateBreadCrumb(new[] { new { Name = "Home", ActionUrl = "#" },
                                     new { Name = "Teacher", ActionUrl = "/Teacher/TeacherProfile" } });

            BaseViewModel VModel     = null;
            var           TempVModel = new TeacherProfileVM();

            //}
            ////*****get user avtar************

            //UsrImgPath = string.Format("{0}\\{1}.{2}", Path.Combine(GetBaseService().GetAppRootPath(), "AppFileRepo\\TeacherAvatar"),TempVModel. , "jpg");
            //if (System.IO.File.Exists(UsrImgPath))
            //{
            //    UsrImgPath = string.Format("~/AppFileRepo/UserAvatar/{0}.{1}", CurrentUserInfo.UserID, "jpg");
            //}
            //else
            //{
            //        UsrImgPath = "~/img/avatar5.png";
            //}
            string UsrImgPath = "~/img/avatar5.png";

            TempVModel.TeacherImgPath     = UsrImgPath;
            TempVModel.AttachTeacherImage = new FileUploadInfo();
            VModel = await GetViewModel(TempVModel);

            //*******************************
            return(View("~/Views/Master/TeacherProfile.cshtml", VModel));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        public async Task <JsonResult> UpdateTeacherProfile(TeacherProfileVM model)
        {
            CommonResponce result = null;

            // if (ModelState.IsValid)
            //{
            result = await _TeacherService.CheckDataValidation(model, false);

            if (!result.Stat)// validation failed
            {
                return(Json(new { stat = false, msg = result.StatusMsg }));
            }

            result = await _TeacherService.UpdateTeacherProfile(model);

            if (result.Stat == true)
            {
                if (model.AttachTeacherImage.FileSize > 0)
                {
                    var RtnMsg = GetBaseService().DirectoryFileService.CreateUserAvatarFromBase64String(GetBaseService().GetAppRootPath(), model.LoginId, model.AttachTeacherImage.FileContentsBase64);
                    model.TeacherImgPath = RtnMsg.StatusMsg;
                    //string TeacherImgPath = Path.Combine(GetBaseService().GetAppRootPath(), "AppFileRepo", "UserAvatar");
                    //if (GetBaseService().DirectoryFileService.CreateDirectoryIfNotExist(TeacherImgPath))
                    //{
                    //    TeacherImgPath = Path.Combine(TeacherImgPath, string.Format("{0}.{1}", model.LoginId, "jpg"));
                    //    if (GetBaseService().DirectoryFileService.CreateFileFromBase64String(model.AttachTeacherImage.FileContentsBase64, TeacherImgPath))
                    //    {
                    //        model.TeacherImgPath = string.Format("~/AppFileRepo/UserAvatar/{0}.{1}?r={2}", model.LoginId, "jpg", DateTime.Now.Ticks.ToString());
                    //        //model.BUserImgPath = model.TeacherImgPath; // update the Teacher avatar
                    //    }
                    //}
                }
                var CurrentUserInfo = GetLoginUserInfo();
                await GetBaseService().AddActivity(ActivityType.Update, CurrentUserInfo.UserID, CurrentUserInfo.UserName, "Teacher Profile", "Updated Teacher profile");

                return(Json(new { stat = true, msg = "Teacher Profile Updated", rtnUrl = "/Teacher/Teachers" }));
            }
            else
            {
                return(Json(new { stat = false, msg = result.StatusMsg }));
            }
            //  }
            //else
            //  return Json(new { stat = false, msg = "Invalid Teacher Profile" });
        }
Beispiel #5
0
        public async Task <IActionResult> UpdateTeacherProfile(int TeacherID)
        {
            CreateBreadCrumb(new[] { new { Name = "Home", ActionUrl = "#" },
                                     new { Name = "Teacher", ActionUrl = "/Teacher/UpdateTeacherProfile" } });

            BaseViewModel  VModel = null;
            CommonResponce CR     = await _TeacherService.GetTeacherByTeacherId(TeacherID);

            if (CR.Stat)
            {
                Teacher TeacherInfo = (Teacher)CR.StatusObj;
                var     TempVModel  = new TeacherProfileVM
                {
                    Id                       = TeacherInfo.Id,
                    RegNo                    = TeacherInfo.RegNo,
                    Name                     = TeacherInfo.Name,
                    Address                  = TeacherInfo.Address,
                    ContactNo                = TeacherInfo.ContactNo,
                    Email                    = TeacherInfo.Email,
                    TeacherImgPath           = "",
                    EducationalQualification = TeacherInfo.EducationalQualification
                };
                if (TeacherInfo.LoginUserId != null)
                {
                    AppUserVM AppUVM = await _AppUserService.GetAppUserByID((int)TeacherInfo.LoginUserId);

                    if (AppUVM != null)
                    {
                        TempVModel.LoginId = AppUVM.UserId;
                        string UsrImgPath = string.Format("~/AppFileRepo/UserAvatar/{0}.{1}", TempVModel.LoginId, "jpg");
                        TempVModel.TeacherImgPath = UsrImgPath;
                    }
                    //*****get user avtar************
                    TempVModel.AttachTeacherImage = new FileUploadInfo();
                }
                VModel = await GetViewModel(TempVModel);
            }

            //*******************************
            return(View("~/Views/Master/UpdateTeacherProfile.cshtml", VModel));
        }
Beispiel #6
0
        public async Task <JsonResult> TeacherProfile(TeacherProfileVM model)
        {
            StringBuilder  rtnMsg = new StringBuilder();
            CommonResponce result = null;

            if (ModelState.IsValid)
            {
                result = await _TeacherService.CheckDataValidation(model, true);

                if (!result.Stat)// validation failed
                {
                    return(Json(new { stat = false, msg = result.StatusMsg }));
                }
                result = await _AppUserService.GetUserProfile(model.LoginId); // check same login id

                if (result.Stat)                                              // login id exists
                {
                    return(Json(new { stat = false, msg = "Login Id already in use" }));
                }

                AppUserVM oAppUserVM = new AppUserVM(); // add an user in the user table for teacher
                oAppUserVM.Name     = model.Name;
                oAppUserVM.UserId   = model.LoginId;
                oAppUserVM.UserType = "S";// Super user
                oAppUserVM.Email    = model.Email;
                oAppUserVM.Mobile   = model.ContactNo;
                oAppUserVM.IsActive = true;
                string   ResetContext = Guid.NewGuid().ToString().Replace("-", "RP");
                DateTime PassValidity = DateTime.Now.AddDays(3); //validity for 1 day
                result = await _AppUserService.SaveAppUserAsync(oAppUserVM, ResetContext, PassValidity).ConfigureAwait(false);

                if (result.Stat == false)
                {
                    return(Json(new { stat = false, msg = result.StatusMsg }));
                }
                else
                {
                    model.LoginUserId = result.StatusObj;// user rec id
                    result            = await _TeacherService.InsertTeacherProfile(model);

                    if (!result.Stat)// user addition failed
                    {
                        return(Json(new { stat = false, msg = "Invalid Teacher Profile" }));
                    }
                    else
                    {
                        rtnMsg.Append("Teacher Profile Inserted.");
                        //save the user picture
                        if (model.AttachTeacherImage.FileSize > 0)
                        {
                            var RtnMsg = GetBaseService().DirectoryFileService.CreateUserAvatarFromBase64String(GetBaseService().GetAppRootPath(), model.LoginId, model.AttachTeacherImage.FileContentsBase64);
                            model.TeacherImgPath = RtnMsg.StatusMsg;
                            //string TeacherImgPath = Path.Combine(GetBaseService().GetAppRootPath(), "AppFileRepo", "UserAvatar");
                            //if (GetBaseService().DirectoryFileService.CreateDirectoryIfNotExist(TeacherImgPath))
                            //{
                            //    TeacherImgPath = Path.Combine(TeacherImgPath, string.Format("{0}.{1}", model.LoginId, "jpg"));
                            //    if (GetBaseService().DirectoryFileService.CreateFileFromBase64String(model.AttachTeacherImage.FileContentsBase64, TeacherImgPath))
                            //    {
                            //        model.TeacherImgPath = string.Format("~/AppFileRepo/UserAvatar/{0}.{1}?r={2}", model.LoginId, "jpg", DateTime.Now.Ticks.ToString());
                            //        //model.BUserImgPath = model.TeacherImgPath; // update the Teacher avatar
                            //    }
                            //}
                        }
                        var CurrentUserInfo = GetLoginUserInfo();
                        await GetBaseService().AddActivity(ActivityType.Update, CurrentUserInfo.UserID, CurrentUserInfo.UserName, "Teacher Profile", "Inserted Teacher profile");

                        await _JobService.AddNewUserCreateEmailJob(Convert.ToInt64(CurrentUserInfo.ID), model.Name, model.Email, GetAppRootUrl(), ResetContext);

                        return(Json(new { stat = true, msg = rtnMsg.ToString(), rtnUrl = "/Teacher/Teachers" }));
                    }
                }
            }
            return(Json(new { stat = result.Stat, msg = rtnMsg.ToString() }));
        }
Beispiel #7
0
        public async Task <CommonResponce> CheckDataValidation(TeacherProfileVM TeacherToInsert, bool IsAdd)
        {
            CommonResponce result = new CommonResponce {
                Stat = true, StatusMsg = ""
            };
            Tblmteacher oTeacher = null;

            if (IsAdd)  // check validation while adding a new teacher
            {
                oTeacher = await _DBTeacherRepository.GetTeacherByRegNo(TeacherToInsert.RegNo).ConfigureAwait(false);

                if (oTeacher != null)
                {
                    result.Stat = false; result.StatusMsg = "Registration No already in use";
                }
                else
                {
                    oTeacher = await _DBTeacherRepository.GetTeacherByEmailID(TeacherToInsert.Email).ConfigureAwait(false);

                    if (oTeacher != null)
                    {
                        result.Stat = false; result.StatusMsg = "Email Id already in use";
                    }
                }
            }
            else//check validation while updating a teacher profile
            {
                oTeacher = await _DBTeacherRepository.GetTeacherByEmailID(TeacherToInsert.Email).ConfigureAwait(false);

                if (oTeacher != null)
                {
                    if (oTeacher.Id != TeacherToInsert.Id)// different teacher with same email id
                    {
                        result.Stat = false;
                    }
                    result.StatusMsg = "Email Id already in use";
                }
                oTeacher = await _DBTeacherRepository.GetTeacherByRegNo(TeacherToInsert.RegNo).ConfigureAwait(false);

                if (oTeacher != null)                      // got result
                {
                    if (TeacherToInsert.Id != oTeacher.Id) // different teacher with same reg no
                    {
                        result.Stat = false; result.StatusMsg = "Registration No already in use";
                    }
                    else // same teacher found check duplicate email id
                    {
                        oTeacher = await _DBTeacherRepository.GetTeacherByEmailID(TeacherToInsert.Email);

                        if (oTeacher != null)
                        {
                            if (TeacherToInsert.Id != oTeacher.Id)  // different teacher with same email id
                            {
                                result.Stat = false;
                            }
                            result.StatusMsg = "Email Id already in use";
                        }
                    }
                }
            }
            return(result);
        }