public dynamic DoLogin(DTO.LABURNUM.COM.LoginModel model) { if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password)) { if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.STUDENT)) { DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel() { StudentUserName = model.UserName, StudentPassword = model.Password, ApiClientModel = model.ApiClientModel, IsStudentLogin = true }; return(new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel)); } if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.PARENT)) { DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel() { ParentUserName = model.UserName, ParentPassword = model.Password, ApiClientModel = model.ApiClientModel, IsStudentLogin = false }; return(new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel)); } if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.FACULTY)) { DTO.LABURNUM.COM.FacultyModel facultyModel = new DTO.LABURNUM.COM.FacultyModel() { UserName = model.UserName, Password = model.Password, ApiClientModel = model.ApiClientModel }; return(new API.LABURNUM.COM.Controllers.FacultyController().FacultyLogin(facultyModel)); } return(model); } else { return(null); } }
public DTO.LABURNUM.COM.SessionModel DoLogin(DTO.LABURNUM.COM.LoginModel model) { if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password)) { DTO.LABURNUM.COM.SessionModel sessionmodel = new DTO.LABURNUM.COM.SessionModel(); // model.Password = GetEncryptedPassword(model.Password); if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.STUDENT)) { DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel() { StudentUserName = model.UserName, StudentPassword = model.Password, ApiClientModel = model.ApiClientModel, IsStudentLogin = true }; sessionmodel.StudentModel = new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel); sessionmodel.LoginByUserId = sessionmodel.StudentModel.StudentId; sessionmodel.LoginBy = model.LoginBy; } if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.PARENT)) { DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel() { ParentUserName = model.UserName, ParentPassword = model.Password, ApiClientModel = model.ApiClientModel }; sessionmodel.StudentModel = new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel); sessionmodel.LoginByUserId = sessionmodel.StudentModel.StudentId; sessionmodel.LoginBy = model.LoginBy; } if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.FACULTY)) { DTO.LABURNUM.COM.FacultyModel facultyModel = new DTO.LABURNUM.COM.FacultyModel() { UserName = model.UserName, Password = model.Password, ApiClientModel = model.ApiClientModel }; sessionmodel.FacultyModel = new API.LABURNUM.COM.Controllers.FacultyController().FacultyLogin(facultyModel); sessionmodel.LoginByUserId = sessionmodel.FacultyModel.FacultyId; sessionmodel.LoginBy = sessionmodel.FacultyModel.UserTypeId; } API.LABURNUM.COM.AcademicYearTable acy = new FrontEndApi.AcademicYearTableApi().GetAcademicYearByYear(new Component.Utility().GetISTDateTime().Year); sessionmodel.AcademicYear = acy.AcademicYear; sessionmodel.AcademicYearId = acy.AcademicYearTableId; sessionmodel.LastLoginAt = new FrontEndApi.LoginActivityApi().GetLastLogin(sessionmodel.LoginByUserId, sessionmodel.LoginBy); DTO.LABURNUM.COM.LoginActivityModel lmodel = new DTO.LABURNUM.COM.LoginActivityModel() { UserTypeId = sessionmodel.LoginBy, StudentId = sessionmodel.LoginByUserId, ClientId = new FrontEndApi.ApiClientApi().GetClientId(model.ApiClientModel.UserName, model.ApiClientModel.Password) }; sessionmodel.LoginActivityId = new FrontEndApi.LoginActivityApi().Add(lmodel); return(sessionmodel); } else { return(null); } }
public dynamic DoLogin(DTO.LABURNUM.COM.LoginModel model) { if (new FrontEndApi.ApiClientApi().IsClientValid(model.ApiClientModel.UserName, model.ApiClientModel.Password)) { DTO.LABURNUM.COM.SessionModel sessionmodel = new DTO.LABURNUM.COM.SessionModel(); //model.Password = GetEncryptedPassword(model.Password); try { if (model.LoginBy == 0) { return(GetApiResponseModel("Login By Cannot Be Null.", false, null)); } if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.STUDENT)) { if (model.UserName == "" || model.Password == "") { return(GetApiResponseModel("Student UserName Or Password Cannnot Be Blank.", false, null)); } DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel() { StudentUserName = model.UserName, StudentPassword = model.Password, ApiClientModel = model.ApiClientModel, IsStudentLogin = true }; sessionmodel.StudentModel = new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel); sessionmodel.LoginByUserId = sessionmodel.StudentModel.StudentId; } if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.PARENT)) { if (model.UserName == "" || model.Password == "") { return(GetApiResponseModel("Parent UserName Or Password Cannnot Be Blank.", false, null)); } DTO.LABURNUM.COM.StudentModel studentmodel = new DTO.LABURNUM.COM.StudentModel() { ParentUserName = model.UserName, ParentPassword = model.Password, ApiClientModel = model.ApiClientModel }; sessionmodel.StudentModel = new API.LABURNUM.COM.Controllers.StudentController().ParentStudentLogin(studentmodel); sessionmodel.LoginByUserId = sessionmodel.StudentModel.StudentId; } if (model.LoginBy == DTO.LABURNUM.COM.Utility.UserType.GetValue(DTO.LABURNUM.COM.Utility.EnumUserType.FACULTY)) { if (model.UserName == "" || model.Password == "") { return(GetApiResponseModel("Faculty UserName Or Password Cannnot Be Blank.", false, null)); } DTO.LABURNUM.COM.FacultyModel facultyModel = new DTO.LABURNUM.COM.FacultyModel() { UserName = model.UserName, Password = model.Password, ApiClientModel = model.ApiClientModel }; sessionmodel.FacultyModel = new API.LABURNUM.COM.Controllers.FacultyController().FacultyLogin(facultyModel); sessionmodel.LoginByUserId = sessionmodel.FacultyModel.FacultyId; } sessionmodel.LoginBy = model.LoginBy; API.LABURNUM.COM.AcademicYearTable acy = new FrontEndApi.AcademicYearTableApi().GetAcademicYearByYear(new Component.Utility().GetISTDateTime().Year); sessionmodel.AcademicYear = acy.AcademicYear; sessionmodel.AcademicYearId = acy.AcademicYearTableId; sessionmodel.LastLoginAt = new FrontEndApi.LoginActivityApi().GetLastLogin(sessionmodel.LoginByUserId, sessionmodel.LoginBy); DTO.LABURNUM.COM.LoginActivityModel lmodel = new DTO.LABURNUM.COM.LoginActivityModel() { UserTypeId = sessionmodel.LoginBy, StudentId = sessionmodel.LoginByUserId, ClientId = new FrontEndApi.ApiClientApi().GetClientId(model.ApiClientModel.UserName, model.ApiClientModel.Password) }; sessionmodel.LoginActivityId = new FrontEndApi.LoginActivityApi().Add(lmodel); return(GetApiResponseModel("SuccessFully Performed", true, sessionmodel)); } catch (Exception ex) { return(GetApiResponseModel(ex.Message.ToString(), false, null)); } } else { return(GetApiResponseModel("Api Access User Name or Password Invalid.", false, null)); } }