public GetLicenses DeleteLicensedUser(GetLicenses obj) { var returnModel = new GetLicenses(); var getLicensedUserList = _userAuthenticationsRepo.GetAll().ToList(); var userList = _usersRepo.GetAll().ToList(); var getUserId = (from p in getLicensedUserList join s in userList on p?.UserId equals s?.Id where p.Id == obj.LicensedId && s.Id == p.UserId select s).SingleOrDefault(); var Users = _usersRepo.Get(getUserId.Id); var UserAuthentications = _userAuthenticationsRepo.Get(obj.LicensedId); if (UserAuthentications != null) { _userAuthenticationsRepo.Delete(UserAuthentications); // returnModel.Message = "Delete Successful."; } if (Users != null) { _usersRepo.Delete(Users); // returnModel.Message = "Delete Successful."; } return(returnModel); }
public string UpdateLicensedUser(GetLicenses obj) { string returnResult = (dynamic)null; try { var getLicensedUserList = _userAuthenticationsRepo.GetAll().ToList(); //var getUserId = (from p in getLicensedUserList // join s in userList on p?.UserId equals s?.Id // where s.Id == p.UserId // select s).SingleOrDefault(); if (obj != null) { if (obj.Users != null) { var currentItem = _usersRepo.GetAll().Where(u => u.Id == obj.Users.Id).FirstOrDefault(); currentItem.Id = obj.Users.Id; currentItem.OurEduId = obj.Users.OurEduId; currentItem.Password = obj.Users.Password; currentItem.LastEntryDate = DateTime.Now; currentItem.LastLogoutDate = null; currentItem.GenderId = obj.Users.GenderId; currentItem.FirstName = obj.Users.FirstName; currentItem.LastName = obj.Users.LastName; currentItem.IP300X200 = null; currentItem.IP600X400 = null; currentItem.EmailAddress = obj.Users.EmailAddress; currentItem.ContactNo = obj.Users.ContactNo; currentItem.DateOfBirth = null; currentItem.IsForgetPassword = false; currentItem.IsActive = obj.Users.IsActive; _usersRepo.Update(currentItem); returnResult = "Saved"; } } //if (obj != null) //{ // if (obj.UserAuthentications != null) // { // var currentItem = _userAuthenticationsRepo.Get(obj.UserAuthentications.Id); // currentItem.Id = obj.UserAuthentications.Id; // currentItem.ActorId = obj.UserAuthentications.ActorId; // currentItem.UserId = getUserId.Id; // currentItem.IsActive = obj.UserAuthentications.IsActive; // _userAuthenticationsRepo.Update(currentItem); // returnResult = "Saved"; // } //} } catch (Exception ex) { returnResult = "ERROR102:FeeTypesServ/UpdateFeeTypes - " + ex.Message; } return(returnResult); }
//[Rahul - update 20Apr21] //public async Task<IActionResult> InsertLicensedUser(IndexUserAuthenticationsVM obj) public JsonResult InsertLicensedUser(IndexUserAuthenticationsVM obj) { var result = (dynamic)null; string message = (dynamic)null; try { if (obj.Users != null) { var Users = new GetLicenses_Users() { OurEduId = obj.Users.OurEduId, Password = obj.Users.Password, LastEntryDate = DateTime.Now, LastLogoutDate = null, GenderId = obj.Users.GenderId, FirstName = obj.Users.FirstName, LastName = obj.Users.LastName, IP300X200 = null, IP600X400 = null, EmailAddress = obj.Users.EmailAddress, ContactNo = obj.Users.ContactNo, DateOfBirth = null, IsForgetPassword = false, IsActive = obj.Users.IsActive, }; var UserAuthentications = new GetLicenses_UserAuthentications() { ActorId = obj.UserAuthentications.ActorId, UserId = obj.Users.Id, IsActive = obj.Users.IsActive, }; var model = new GetLicenses() { Users = Users, UserAuthentications = UserAuthentications }; //await Task.Run(() => _userAuthentication.InsertLicensesedUser(model)); message = _userAuthentication.InsertLicensesedUser(model); result = Json(new { success = true, Message = message }); } } catch (Exception ex) { //return BadRequest(); result = Json(new { success = false, Message = "ERROR101:Students/InsertStudent - " + ex.Message }); } //return RedirectToAction("LicensedUserList"); return(result); }
public async Task <IActionResult> UpdateLicensedUser(IndexUserAuthenticationsVM obj) { try { if (obj.Users != null) { var Users = new GetLicenses_Users() { Id = obj.Users.UserId, UserAuthenticationId = obj.UserAuthenticationId, OurEduId = obj.Users.OurEduId, Password = obj.Users.Password, LastEntryDate = DateTime.Now, LastLogoutDate = null, GenderId = obj.Users.GenderId, FirstName = obj.Users.FirstName, LastName = obj.Users.LastName, IP300X200 = null, IP600X400 = null, EmailAddress = obj.Users.EmailAddress != null? obj.Users.EmailAddress:"", ContactNo = obj.Users.ContactNo != null ? obj.Users.ContactNo : "", DateOfBirth = null, IsForgetPassword = false, IsActive = obj.Users.IsActive, }; //var UserAuthentications = new GetLicenses_UserAuthentications() //{ // Id = obj.UserAuthentications.Id, // ActorId = obj.UserAuthentications.ActorId, // UserId = obj.Users.Id, // IsActive = obj.Users.IsActive, //}; var model = new GetLicenses() { // WebRootPath = _he.WebRootPath, Users = Users //UserAuthentications = UserAuthentications }; await Task.Run(() => _userAuthentication.UpdateLicensedUser(model)); } } catch (Exception ex) { return(BadRequest()); } return(RedirectToAction("LicensedUserList")); }
public string InsertLicensesedUser(GetLicenses obj) { string retrurnResult = (dynamic)null; try { if (obj != null) { if (obj.Users != null) { var Users = new GetLicenses_Users() { OurEduId = obj.Users.OurEduId, Password = obj.Users.Password, LastEntryDate = DateTime.Now, LastLogoutDate = null, GenderId = obj.Users.GenderId, FirstName = obj.Users.FirstName, LastName = obj.Users.LastName, IP300X200 = null, IP600X400 = null, EmailAddress = obj.Users.EmailAddress, ContactNo = obj.Users.ContactNo, DateOfBirth = null, IsForgetPassword = false, IsActive = obj.Users.IsActive }; _usersRepo.Insert(Users); retrurnResult = "Saved"; } var getLastId = _usersRepo.GetLastId(); var usersList = _usersRepo.Get(getLastId); if (obj.UserAuthentications != null) { var UserAthentications = new GetLicenses_UserAuthentications() { ActorId = obj.UserAuthentications.ActorId, UserId = getLastId, IsActive = obj.Users.IsActive }; _userAuthenticationsRepo.Insert(UserAthentications); retrurnResult = "Saved"; } } } catch (Exception ex) { retrurnResult = "ERROR102: userServ/InsertuserList -" + ex.Message; } return(retrurnResult); }
public GetLicenses GetLicenses() { var model = new GetLicenses(); try { var UsersList = _usersRepo.GetAll().ToList(); var userAuthenticationList = _userAuthenticationsRepo.GetAll().ToList(); var ActorList = _actorsRepo.GetAll().ToList(); var query = (from _userAuthentication in userAuthenticationList join _User in UsersList on _userAuthentication?.UserId equals _User?.Id join _actor in ActorList on _userAuthentication?.ActorId equals _actor?.Id select new { _userAuthentication, _User, _actor }); var list = new List <GetLicenses_UserAuthentications>(); foreach (var item in query) { var temp = new GetLicenses_UserAuthentications() { Id = item._userAuthentication.Id, ActorId = item._userAuthentication.ActorId, Actor = item._actor.Name, UserId = item._userAuthentication.UserId, IsActive = item._userAuthentication.IsActive, UserName = item._User.FirstName + " " + item._User.LastName, OurEduId = item._User.OurEduId, FirstName = item._User.FirstName, LastName = item._User.LastName, Password = item._User.Password, Email = item._User.EmailAddress, Contact = item._User.ContactNo, GenderId = item._User.GenderId }; list.Add(temp); } ; model = new GetLicenses() { _UserAuthentications = list }; } catch (Exception ex) { var test = ex.Message; } return(model); }
public async Task <IActionResult> DeleteLicensedUser(long LicensedId) { try { var model = new GetLicenses() { //WebRootPath = _he.WebRootPath, LicensedId = LicensedId }; await Task.Run(() => _userAuthentication.DeleteLicensedUser(model)); } catch (Exception) { return(BadRequest()); } return(RedirectToAction("LicensedUserList")); }