public ActionResult AddUpdateUserProfile(List <ProfileUserVM> request, int?RequestId = null) { var getUserProfile = new ProfileDataAccess().GetUserProfiles(request.FirstOrDefault() == null ? 0 : request.FirstOrDefault().UserID.GetValueOrDefault()); var getSystemRequest = new SystemRequestDataAccess().GetSystemRequest(RequestId.GetValueOrDefault()); var existingJson = getUserProfile.Count <= 0 ? null : CustomHelper.GetJson(getUserProfile); var updatedJson = CustomHelper.GetJson(request); var row = new tbl_System_Requests { ID = RequestId.GetValueOrDefault(), AuthorizationStatus = "P", CreatorID = StateHelper.UserId, IsActive = true, ExistingData = existingJson, UpdatedData = updatedJson, RequestType = Constants.RequestTypes.UserProfile, AuthorizationComments = getSystemRequest?.AuthorizationComments ?? string.Empty, AuthorizerID = getSystemRequest?.AuthorizerID ?? 0 }; var success = (!RequestId.HasValue || RequestId.GetValueOrDefault() <= 0) ? new SystemRequestDataAccess().AddSystemRequest(row) : new SystemRequestDataAccess().UpdateSystemRequest(row); return(Json(new { IsSuccess = success }, JsonRequestBehavior.AllowGet)); }
public static List <ProfileUserVM> GetProfileUsers(int UserID) { try { var data = new ProfileDataAccess().GetUserProfiles(UserID); if (data != null) { return(data.Select(e => new ProfileUserVM { ID = e.ID, ProfileID = e.ProfileID, UserID = e.UserID, ProfileTitle = new ProfileDataAccess().GetProfileById(int.Parse(e.ProfileID.ToString())).Title }).ToList()); } else { return(null); } } catch (Exception ex) { throw ex; } }
public static List <PageSectionVM> GetAllPages() { try { var data = new ProfileDataAccess().GetAllPages(); if (data != null) { return(data.Select(e => new PageSectionVM { ID = e.ID, Title = e.Title, SectionID = e.SectionID, SequenceNo = e.SequenceNo, IsActive = e.IsActive, URL = e.URL, SectionTitle = new ProfileDataAccess().GetSectionName(int.Parse(e.SectionID.ToString())) }).ToList()); } else { return(null); } } catch (Exception ex) { throw ex; } }
public ActionResult AddProfileModificationRequest(tbl_Profile request, int?RequestId = null) { var getProfile = new ProfileDataAccess().GetProfileById(request.ID); var getSystemRequest = new SystemRequestDataAccess().GetSystemRequest(RequestId.GetValueOrDefault()); request.AuthorizationStatus = getProfile.AuthorizationStatus; request.AuthorizationComments = getProfile.AuthorizationComments; var existingJson = getProfile == null ? null : CustomHelper.GetJson(getProfile); var updatedJson = CustomHelper.GetJson(request); var row = new tbl_System_Requests { ID = RequestId.GetValueOrDefault(), AuthorizationStatus = "P", CreatorID = StateHelper.UserId, IsActive = true, ExistingData = existingJson, UpdatedData = updatedJson, RequestType = Constants.RequestTypes.ProfileModification, AuthorizationComments = getSystemRequest?.AuthorizationComments, AuthorizerID = getSystemRequest?.AuthorizerID }; var success = (!RequestId.HasValue || RequestId.GetValueOrDefault() <= 0) ? new SystemRequestDataAccess().AddSystemRequest(row) : new SystemRequestDataAccess().UpdateSystemRequest(row); return(Json(new { IsSuccess = success }, JsonRequestBehavior.AllowGet)); }
public static bool Registration(string login, string password, Profile profile) { var userDataAccess = new UserDataAccess(); var userList = userDataAccess.Select(); var profileDataAccess = new ProfileDataAccess(); foreach (var element in userList) { if (element.Login == login) { return(false); } } //Проверяю на валидность Email var isValid = EmailValidationService.IsValidEmail(profile.Email); if (isValid) { var user = new User() { Login = login, Password = EncryiptionService.GetHashString(password) }; userDataAccess.Insert(user); profileDataAccess.Insert(profile); return(true); } else { return(false); } }
public ActionResult AddUpdateProfilePages(List <ProfilePageVM> request, int?RequestId = null) { if (request == null) { return(Json(new { IsSuccess = false, ErrorMessage = CustomMessages.SomethingWentWrong }, JsonRequestBehavior.AllowGet)); } var getSystemRequest = new SystemRequestDataAccess().GetSystemRequest(RequestId.GetValueOrDefault()); var getProfilePages = new ProfileDataAccess().GetProfilePage(request.FirstOrDefault() != null ? request.FirstOrDefault().ProfileID.GetValueOrDefault() : 0); var existingJson = getProfilePages.Count <= 0 ? null : CustomHelper.GetJson(getProfilePages); var updatedJson = CustomHelper.GetJson(request); var row = new tbl_System_Requests { ID = RequestId.GetValueOrDefault(), AuthorizationStatus = "P", CreatorID = StateHelper.UserId, IsActive = true, ExistingData = existingJson, UpdatedData = updatedJson, RequestType = Constants.RequestTypes.ProfilePage, AuthorizationComments = getSystemRequest?.AuthorizationComments ?? string.Empty, AuthorizerID = getSystemRequest?.AuthorizerID ?? 0 }; var success = (!RequestId.HasValue || RequestId.GetValueOrDefault() <= 0) ? new SystemRequestDataAccess().AddSystemRequest(row): new SystemRequestDataAccess().UpdateSystemRequest(row); return(Json(new { IsSuccess = success }, JsonRequestBehavior.AllowGet)); }
// GET: User Profile [Use to assign profile to user] public ActionResult UserProfile(int?Id) { var viewModel = new ProfileDataAccess().GetAllProfiles("A"); if (Id.HasValue) { var getSystemRequest = new SystemRequestDataAccess().GetSystemRequest(Id.GetValueOrDefault(), "R"); if (getSystemRequest == null) { return(RedirectToAction("UserProfileReview", "SystemReview")); } ViewBag.SystemRequest = new tbl_System_Requests { ID = Id.GetValueOrDefault() }; //getSystemRequest; var profileUser = CustomHelper.ParseJson <List <ProfileUserVM> >(getSystemRequest.UpdatedData); var userData = new UserDataAccess().GetUserById(profileUser.FirstOrDefault()?.UserID ?? 0); ViewBag.ProfileUser = profileUser; ViewBag.UserID = userData.UserLogin; } var users = new UserDataAccess().GetUsers("A"); ViewBag.Users = users; return(View(viewModel)); }
public async Task <IActionResult> UpdateRole(int userId, bool?IsContributor = null, bool?IsAdmin = null, int?portalLanguageId = null) { try { ProfileDataAccess _profileAccess = new ProfileDataAccess(_iconfiguration); DatabaseResponse response = await _profileAccess.UpdateUserRole(userId, IsContributor, IsAdmin, portalLanguageId); if (response.ResponseCode == (int)DbReturnValue.UpdateSuccess) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.UpdateSuccess), ReturnedObject = response.Results })); } else if (response.ResponseCode == (int)DbReturnValue.UpdationFailed) { Log.Warning(EnumExtensions.GetDescription(DbReturnValue.UpdationFailed)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.UpdationFailed), ReturnedObject = response.Results })); } else { Log.Warning(EnumExtensions.GetDescription(DbReturnValue.NotExists)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.NotExists), ReturnedObject = response.Results })); } } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(Ok(new OperationResponse { HasSucceeded = false, Message = StatusMessages.ServerError, StatusCode = ((int)ResponseStatus.ServerError).ToString(), IsDomainValidationErrors = false })); } }
public async Task <IActionResult> DeleteUserBookmarkedContent([FromBody] DeleteUserBookMarks userBookmarks) { try { ProfileDataAccess _profileAccess = new ProfileDataAccess(_iconfiguration); DatabaseResponse response = await _profileAccess.DeleteUserBookmarkedContent(userBookmarks); if (response.ResponseCode == (int)DbReturnValue.DeleteSuccess) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.DeleteSuccess), ReturnedObject = response.Results })); } else if (response.ResponseCode == (int)DbReturnValue.DeleteFailed) { Log.Warning(EnumExtensions.GetDescription(DbReturnValue.DeleteFailed)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.DeleteFailed), ReturnedObject = response.Results })); } else { Log.Warning(EnumExtensions.GetDescription(DbReturnValue.NotExists)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.NotExists), ReturnedObject = response.Results })); } } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(Ok(new OperationResponse { HasSucceeded = false, Message = StatusMessages.ServerError, StatusCode = ((int)ResponseStatus.ServerError).ToString(), IsDomainValidationErrors = false })); } }
public async Task <IActionResult> GetEmailNotificationStatus(int UserID) { try { if (!ModelState.IsValid) { return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = true, StatusCode = ((int)ResponseStatus.BadRequest).ToString(), Message = string.Join("; ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)) })); } ProfileDataAccess _profileAccess = new ProfileDataAccess(_iconfiguration); DatabaseResponse response = await _profileAccess.GetEmailNotificationStatus(UserID); if (response.ResponseCode == (int)DbReturnValue.RecordExists) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.RecordExists), ReturnedObject = response.Results })); } else { Log.Error(EnumExtensions.GetDescription(DbReturnValue.NotExists)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.NotExists), ReturnedObject = response.Results })); } } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(Ok(new OperationResponse { HasSucceeded = false, Message = StatusMessages.ServerError, StatusCode = ((int)ResponseStatus.ServerError).ToString(), IsDomainValidationErrors = false })); } }
public ActionResult AuthorizeNewProfile(int?Id) { var viewModel = new ProfileDataAccess().GetProfileById(Id.GetValueOrDefault()); if (viewModel.AuthorizationStatus != "P") { return(RedirectToAction("AuthorizeProfile")); } return(View(viewModel)); }
public static bool AddProfilePages(List <tbl_Profile_Page> request) { var success = new ProfileDataAccess().DeleteProfilePage(request.FirstOrDefault().ProfileID.GetValueOrDefault()); if (success) { return(new ProfileDataAccess().AddProfilePage(request)); } else { return(false); } }
public static bool AddProfileUsers(List <tbl_User_Profile> request) { var success = new ProfileDataAccess().DeleteProfileUser(request.FirstOrDefault().UserID.GetValueOrDefault()); if (success) { return(new ProfileDataAccess().AddUserProfile(request)); } else { return(false); } }
// GET: Profile [Use to add profile] public ActionResult Index(int?Id) { var viewModel = new tbl_Profile(); if (Id.HasValue) { viewModel = new ProfileDataAccess().GetProfileById(Id.GetValueOrDefault()); if (viewModel.AuthorizationStatus != "R") { return(RedirectToAction("DashboardView", "Base")); } } return(View(viewModel)); }
public ActionResult AuthorizeNewProfileRequest(tbl_Profile request) { var profile = new ProfileDataAccess().GetProfileById(request.ID); var log = new UserLogDataAccess().GetUserLogByEntityId(request.ID, "tbl_Profile"); if (log.FirstOrDefault()?.ActionUserStamp == StateHelper.UserId) { return(Json(new { IsSuccess = false, ErrorMessage = CustomMessages.SameCreatorAndsAuthorizer }, JsonRequestBehavior.AllowGet)); } profile.AuthorizationStatus = request.AuthorizationStatus; profile.AuthorizationComments = request.AuthorizationComments; var success = new ProfileDataAccess().UpdateProfile(profile); return(Json(new { IsSuccess = success, ErrorMessage = (!success) ? CustomMessages.GenericErrorMessage : CustomMessages.AuthorizedSucessfully, Response = success }, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> GetUserFavouritesByContentID(int UserId, int ContentId, int ContentType) { try { ProfileDataAccess _profileAccess = new ProfileDataAccess(_iconfiguration); DatabaseResponse response = await _profileAccess.GetUserFavouritesByContentID(UserId, ContentId, ContentType); if (response.ResponseCode == (int)DbReturnValue.RecordExists) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.RecordExists), ReturnedObject = response.Results })); } else { Log.Error(EnumExtensions.GetDescription(DbReturnValue.NotExists)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.NotExists), ReturnedObject = response.Results })); } } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(Ok(new OperationResponse { HasSucceeded = false, Message = StatusMessages.ServerError, StatusCode = ((int)ResponseStatus.ServerError).ToString(), IsDomainValidationErrors = false })); } }
public Profile SaveToProfile(Account account) { var profileDataAccess = new ProfileDataAccess(); var profile = new Profile(); profile.Login = account.Login; Console.Write("Напишите Имя: "); profile.FirstName = Console.ReadLine(); Console.Write("Напишите Фамилию: "); profile.LastName = Console.ReadLine(); Console.Write("Напишите Email: "); profile.Email = Console.ReadLine(); Console.Write("Напишите путь к картинке: "); profile.PathToImage = Console.ReadLine(); profileDataAccess.Insert(profile); return(profile); }
public static List <SystemRequestVM> GetSystemRequestForProfile(string AuthorizationStatus, string RequestType) { List <SystemRequestVM> lstData = new List <SystemRequestVM>(); if (RequestType.ToLower().Contains("register")) { var rows = new ProfileDataAccess().GetAllProfiles(AuthorizationStatus); if (rows.Count > 0) { using (var db = new SoneriCISEntities()) { lstData = (from r in rows let l = (from l in db.tbl_User_Log where l.EntityID == r.ID select l).FirstOrDefault() select new SystemRequestVM { ProfileName = r.Title, RequestDate = l.ActionTimestamp.GetValueOrDefault(), ID = r.ID, RequestType = "Profile_Register" }).ToList(); } } } else { var rows = new SystemRequestDataAccess().GetAllSystemRequests(AuthorizationStatus, RequestType); using (var db = new SoneriCISEntities()) { lstData = (from r in rows let l = (from l in db.tbl_User_Log where l.EntityID == r.ID select l).FirstOrDefault() select new SystemRequestVM { ProfileName = (RequestType == Constants.RequestTypes.ProfileModification) ? Helpers.CustomHelper.ParseJson <tbl_Profile>(r.UpdatedData)?.Title ?? string.Empty : Helpers.CustomHelper.ParseJson <List <ProfilePageVM> >(r.UpdatedData).FirstOrDefault()?.ProfileName ?? string.Empty, RequestDate = l.ActionTimestamp.GetValueOrDefault(), ID = r.ID, RequestType = r.RequestType }).ToList(); } } return(lstData); }
public async Task <IActionResult> UpdateLastLogin(int userId) { try { ProfileDataAccess _profileAccess = new ProfileDataAccess(_iconfiguration); DatabaseResponse response = await _profileAccess.UpdateLastLogin(userId); if (response.ResponseCode == (int)DbReturnValue.UpdateSuccess) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.UpdateSuccess), ReturnedObject = null })); } else { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.UpdationFailed) })); } } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(Ok(new OperationResponse { HasSucceeded = false, Message = StatusMessages.ServerError, StatusCode = ((int)ResponseStatus.ServerError).ToString(), IsDomainValidationErrors = false })); } }
// GET: Update Profile [Use to edit/update profile] public ActionResult UpdateProfile(int?Id) { var systemRequest = new tbl_System_Requests(); if (Id.HasValue) { systemRequest = new SystemRequestDataAccess().GetSystemRequest(Id.GetValueOrDefault(), "R"); if (systemRequest == null) { return(RedirectToAction("DashboardView", "Base")); } ViewBag.ProfileDetails = CustomHelper.ParseJson <tbl_Profile>(systemRequest.UpdatedData); } ViewBag.SystemRequest = systemRequest; var viewModel = new ProfileDataAccess().GetAllProfiles("A"); return(View(viewModel)); }
public static List <Tuple <string, DateTime, int, string> > GetProfileDetails(string AuthorizationStatus, string RequestType) { var rows = new ProfileDataAccess().GetAllProfiles(AuthorizationStatus); if (rows.Count > 0) { using (var db = new SoneriCISEntities()) { return((from r in rows let l = (from l in db.tbl_User_Log where l.EntityID == r.ID select l).FirstOrDefault() select Tuple.Create( r.Title, l.ActionTimestamp.GetValueOrDefault(), r.ID, "Profile_Register" )).ToList()); } } else { return(new List <Tuple <string, DateTime, int, string> >()); } }
public async Task <IActionResult> CreateInitialProfile([FromBody] CreateInitialProfileRequest profile) { try { if (!ModelState.IsValid) { return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = true, StatusCode = ((int)ResponseStatus.BadRequest).ToString(), Message = string.Join("; ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage)) })); } ProfileDataAccess _profileAccess = new ProfileDataAccess(_iconfiguration); DatabaseResponse response = await _profileAccess.CreateInitialProfile(profile); if (response.ResponseCode == (int)DbReturnValue.CreateSuccess) { DatabaseResponse userResponse = await _profileAccess.GetUserProfileById(((UserMaster)response.Results).Id); if (userResponse.ResponseCode == (int)DbReturnValue.RecordExists) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.CreateSuccess), ReturnedObject = userResponse.Results })); } else { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.CreationFailed) })); } } else if (response.ResponseCode == (int)DbReturnValue.EmailExists) { Log.Error(EnumExtensions.GetDescription(DbReturnValue.EmailExists)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.EmailExists), ReturnedObject = response.Results })); } else { Log.Error(EnumExtensions.GetDescription(DbReturnValue.CreationFailed)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.CreationFailed), // ReturnedObject = response.Results })); } } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(Ok(new OperationResponse { HasSucceeded = false, Message = StatusMessages.ServerError, StatusCode = ((int)ResponseStatus.ServerError).ToString(), IsDomainValidationErrors = false })); } }