diff --git a/.vs/Socioboard/v14/.suo b/.vs/Socioboard/v14/.suo index 6412b07bf..6a059d8dc 100644 Binary files a/.vs/Socioboard/v14/.suo and b/.vs/Socioboard/v14/.suo differ diff --git a/src/Api.Socioboard/Controllers/GroupMemberController.cs b/src/Api.Socioboard/Controllers/GroupMemberController.cs index 41cd1a249..ef5bed76b 100644 --- a/src/Api.Socioboard/Controllers/GroupMemberController.cs +++ b/src/Api.Socioboard/Controllers/GroupMemberController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; @@ -43,7 +44,7 @@ public GroupMemberController(ILogger logger, IEmailSender emailS /// /// [HttpPost("InviteGroupMembers")] - public IActionResult InviteGroupMembers(long groupId, string members) + public IActionResult InviteGroupMembers(long groupId, string members) { List lstGrpMembers = new List(); if (string.IsNullOrEmpty(members)) @@ -53,7 +54,7 @@ public IActionResult InviteGroupMembers(long groupId, string members) else { string[] lstmem = members.Split(';'); - foreach(var item in lstmem) + foreach (var item in lstmem) { if (!string.IsNullOrEmpty(item)) { @@ -100,6 +101,26 @@ public IActionResult InviteGroupMembers(long groupId, string members) if (temp == null) { dbr.Add(member); + + var savedMembers = dbr.Find(t => t.groupid == groupId && t.email == member.email).FirstOrDefault(); + + var lstnotifications = dbr.Single(t => t.MsgId == savedMembers.id); + + if (lstnotifications == null && savedMembers != null) + { + var notify = new Notifications + { + MsgId = savedMembers.id, + MsgStatus = "Invited", + notificationtime = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture), + NotificationType = grp.groupName, + ReadOrUnread = "Unread", + UserId = member.userId + }; + dbr.Add(notify); + } + + _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupMembers + groupId); string path = _appEnv.WebRootPath + "\\views\\mailtemplates\\groupinvitation.html"; string html = System.IO.File.ReadAllText(path); @@ -121,7 +142,7 @@ public IActionResult GetGroupMembers(long groupId) return Ok(GroupMembersRepository.getGroupMembers(groupId, _redisCache, dbr)); } - [HttpGet ("GetGroupAdmin")] + [HttpGet("GetGroupAdmin")] public IActionResult GetGroupAdmin(long groupId) { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); @@ -146,10 +167,10 @@ public IActionResult LeaveGroup(long groupId, long userId) public IActionResult ActivateGroupMember(string code, string email) { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); - Domain.Socioboard.Models.Groupmembers grpMember = dbr.Find(t => t.email.Equals(email)&&t.memberCode.Equals(code)).FirstOrDefault(); - if(grpMember != null) + Domain.Socioboard.Models.Groupmembers grpMember = dbr.Find(t => t.email.Equals(email) && t.memberCode.Equals(code)).FirstOrDefault(); + if (grpMember != null) { - if(grpMember.userId == 0) + if (grpMember.userId == 0) { User inMemUser = _redisCache.Get(email.Trim()); if (inMemUser == null) @@ -169,6 +190,25 @@ public IActionResult ActivateGroupMember(string code, string email) } } + + /// + /// + /// + /// + /// + /// + [HttpPost("DeclineGroupMember")] + public IActionResult DeclineGroupMember(string code, string email) + { + var dbr = new DatabaseRepository(_logger, _appEnv); + var grpMember = dbr.Find(t => t.email.Equals(email) && t.memberCode.Equals(code)).FirstOrDefault(); + if (grpMember == null) + return Ok("Error!"); + + dbr.Delete(grpMember); + return Ok("deleted"); + } + [HttpPost("DeleteGroupMembers")] public IActionResult DeleteGroupMembers(string grpMmbrIdss) { diff --git a/src/Api.Socioboard/Controllers/NotificationsController.cs b/src/Api.Socioboard/Controllers/NotificationsController.cs index 5c0049eb6..ce97378de 100644 --- a/src/Api.Socioboard/Controllers/NotificationsController.cs +++ b/src/Api.Socioboard/Controllers/NotificationsController.cs @@ -47,7 +47,7 @@ public IActionResult FindNotifications(long userId) { foreach (Notifications notify in lstnotifications) { - ScheduledMessage schedulemsg = dbr.Single(t => t.id == notify.MsgId && t.userId==userId); + ScheduledMessage schedulemsg = dbr.Single(t => t.id == notify.MsgId && t.userId == userId); if (schedulemsg != null) { lstschedulemsg.Add(schedulemsg); @@ -72,7 +72,7 @@ public IActionResult FindNotifications(long userId) { return NotFound(); } - + } @@ -83,15 +83,15 @@ public IActionResult FindAllNotifications(long userId, int skip, int count) { DatabaseRepository dbr = new DatabaseRepository(_logger, _env); List lstschedulemsg = new List(); - List lstnotifications = dbr.FindWithRangeDesct(t => t.UserId == userId, skip, count, t=>t.Id).ToList(); + List lstnotifications = dbr.FindWithRangeDesct(t => t.UserId == userId && t.MsgStatus != "Invited", skip, count, t => t.Id).ToList(); foreach (Notifications notify in lstnotifications) { - ScheduledMessage schedulemsg = dbr.Single(t => t.id == notify.MsgId && t.userId==userId); - if(schedulemsg !=null) + ScheduledMessage schedulemsg = dbr.Single(t => t.id == notify.MsgId && t.userId == userId); + if (schedulemsg != null) { lstschedulemsg.Add(schedulemsg); } - + } if (lstschedulemsg != null) { @@ -102,14 +102,60 @@ public IActionResult FindAllNotifications(long userId, int skip, int count) return NotFound(); } } - catch(Exception ex) + catch (Exception ex) + { + return NotFound(); + } + + + } + + + + /// + /// + /// + /// + /// + /// + /// + [HttpGet("FindAllInvitationNotifications")] + public IActionResult FindAllInvitationNotifications(long userId, int skip, int count) + { + try + { + var dbr = new DatabaseRepository(_logger, _env); + var lstInvitations = new List(); + var notifications = dbr.FindWithRangeDesct(t => t.UserId == userId && t.MsgStatus == "Invited", skip, count, t => t.Id).ToList(); + foreach (var notify in notifications) + { + var groupMember = dbr.Single(t => t.id == notify.MsgId && t.userId == userId); + if (groupMember == null) + continue; + var invitation = new InvitationDetails + { + GroupId = groupMember.groupid, + Message = notify.NotificationType, + EmailId = groupMember.email, + MemberCode = groupMember.memberCode, + UserId = groupMember.userId, + NotifyId = notify.Id + }; + lstInvitations.Add(invitation); + + } + return Ok(lstInvitations); + } + catch (Exception ex) { return NotFound(); } - + } + + [HttpGet("UpdateNotifications")] public IActionResult UpdateNotifications(long userId) { @@ -132,12 +178,30 @@ public IActionResult UpdateNotifications(long userId) return NotFound(); } } - catch(Exception ex) + catch (Exception ex) { return NotFound(); } - + + } + + + + [HttpGet("DeleteNotifications")] + public IActionResult DeleteNotifications(long notifyId) + { + try + { + var dbr = new DatabaseRepository(_logger, _env); + var notifyObject = dbr.FindFirstMatch(t => t.Id == notifyId); + dbr.Delete(notifyObject); + return Ok("deleted"); + } + catch (Exception ex) + { + return NotFound(); + } } @@ -145,12 +209,12 @@ public IActionResult UpdateNotifications(long userId) public IActionResult ChangePasswordDetail(long userId) { try - { + { MongoRepository mongorepo = new MongoRepository("FacebookPasswordChangeUserDetail", _appSettings); DatabaseRepository dbr = new DatabaseRepository(_logger, _env); List datalst = dbr.Find(t => t.UserId == userId).ToList(); - // Domain.Socioboard.Models.User userDet = dbr.FindSingle(t => t.Id == userId); - var result = mongorepo.Find(t => t.userId == userId && t.status==false); + // Domain.Socioboard.Models.User userDet = dbr.FindSingle(t => t.Id == userId); + var result = mongorepo.Find(t => t.userId == userId && t.status == false); var task = Task.Run(async () => { return await result; @@ -158,7 +222,7 @@ public IActionResult ChangePasswordDetail(long userId) int count = task.Result.Count; IList lstfbpasschange = task.Result; List lstfab = new List(); - foreach(var lstfb in lstfbpasschange) + foreach (var lstfb in lstfbpasschange) { if (lstfb.message.Contains("password")) { @@ -171,11 +235,11 @@ public IActionResult ChangePasswordDetail(long userId) { } - + } - + } - if (count>0) + if (count > 0) { return Ok(lstfab); } @@ -199,7 +263,7 @@ public IActionResult ChangeStatus(string profileId) // DatabaseRepository dbr = new DatabaseRepository(_logger, _env); // List datalst = dbr.Find(t => t.UserId == userId).ToList(); // Domain.Socioboard.Models.User userDet = dbr.FindSingle(t => t.Id == userId); - // Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail lstchanges = new Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail(); + // Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail lstchanges = new Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail(); var result = mongorepo.Find(t => t.profileId == profileId && t.status == false); var task = Task.Run(async () => { @@ -208,7 +272,7 @@ public IActionResult ChangeStatus(string profileId) int count = task.Result.Count; if (count > 0) { - + var builders = Builders.Filter; FilterDefinition filter = builders.Eq("profileId", profileId); var update = Builders.Update.Set("status", true); @@ -229,14 +293,14 @@ public IActionResult getfbchangeprofile(long userId) DatabaseRepository dbr = new DatabaseRepository(_logger, _env); List datalst = dbr.Find(t => t.UserId == userId).ToList(); Domain.Socioboard.Models.User userDet = dbr.FindSingle(t => t.Id == userId); - var result = mongorepo.Find(t => t.userId == userId && t.status==false); + var result = mongorepo.Find(t => t.userId == userId && t.status == false); var task = Task.Run(async () => { return await result; }); int count = task.Result.Count; IList lstfbpasschange = task.Result; - if (count>0) + if (count > 0) { return Ok(lstfbpasschange); } diff --git a/src/Domain.Socioboard/Models/InvitationDetails.cs b/src/Domain.Socioboard/Models/InvitationDetails.cs new file mode 100644 index 000000000..fba972a92 --- /dev/null +++ b/src/Domain.Socioboard/Models/InvitationDetails.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Domain.Socioboard.Models +{ + public class InvitationDetails + { + + public virtual long GroupId { get; set; } + + public virtual string Message { get; set; } + + public virtual string EmailId { get; set; } + + public virtual string MemberCode { get; set; } + + public virtual long UserId { get; set; } + + public virtual Int64 NotifyId { get; set; } + } +} diff --git a/src/Socioboard/wwwroot/contents/socioboard/controllers/notificationallcontroller.js b/src/Socioboard/wwwroot/contents/socioboard/controllers/notificationallcontroller.js index 6b0b9c212..4ffc1e40b 100644 --- a/src/Socioboard/wwwroot/contents/socioboard/controllers/notificationallcontroller.js +++ b/src/Socioboard/wwwroot/contents/socioboard/controllers/notificationallcontroller.js @@ -9,32 +9,101 @@ SocioboardApp.controller('NotificationAllController', function ($rootScope, $sco var startNotify = 0; $scope.notifycount = startNotify; $scope.LoadAllNotifications = function () { - + $http.get(apiDomain + '/api/Notifications/FindAllNotifications?userId=' + $rootScope.user.Id + '&skip=' + startNotify + '&count=' + 10) .then(function (response) { + debugger; $scope.lstnotifications = response.data; $scope.notifycount = $scope.notifycount + 10; $http.get(apiDomain + '/api/Notifications/UpdateNotifications?userId=' + $rootScope.user.Id) - .then(function (response) { - $scope.updated = response.data; - }) + .then(function (response) { + $scope.updated = response.data; + }) + .catch((error) => { + debugger; + }); }, function (reason) { $scope.error = reason.data; }); // end codes to load recent Feeds + + $http.get(apiDomain + '/api/Notifications/FindAllInvitationNotifications?userId=' + $rootScope.user.Id + '&skip=' + startNotify + '&count=' + 10) + .then(function (response) { + $scope.lstinvitationnotifications = response.data; + debugger; + }, function (reason) { + $scope.error = reason.data; + }); + } + + + $scope.acceptInviations = function (email, memberCode, notifyId) { + $http.post(apiDomain + '/api/GroupMember/ActivateGroupMember?code=' + memberCode + '&email=' + email) + .then(function (response) { + debugger; + if (response.data === "updated") { + $scope.lstinvitationnotifications = $scope.lstinvitationnotifications.filter(element => { + return element.memberCode !== memberCode && element.email !== email; + }); + } + }, function (reason) { + $scope.error = reason.data; + }) + .then(() => { + return $http.get(apiDomain + '/api/Notifications/DeleteNotifications?notifyId=' + notifyId); + }) + .then(function (response) { + debugger; + if (response.data === "deleted") { + } + }, function (reason) { + $scope.error = reason.data; + }) + .catch((error) => { + debugger; + }); + debugger; } + + $scope.declineInviations = function (email, memberCode, notifyId) { + $http.post(apiDomain + '/api/GroupMember/DeclineGroupMember?code=' + memberCode + '&email=' + email) + .then(function (response) { + debugger; + if (response.data === "deleted") { + $scope.lstinvitationnotifications = $scope.lstinvitationnotifications.filter(element => { + return element.memberCode !== memberCode && element.email !== email; + }); + } + }, function (reason) { + $scope.error = reason.data; + }) + .then(() => { + return $http.get(apiDomain + '/api/Notifications/DeleteNotifications?notifyId=' + notifyId); + }) + .then(function (response) { + debugger; + if (response.data === "deleted") { + } + }, function (reason) { + $scope.error = reason.data; + }) + .catch((error) => { + debugger; + }); + } + $scope.LoadAllNotifications(); $scope.changepass = function () { - + $http.get(apiDomain + '/api/Notifications/ChangePasswordDetail?userId=' + $rootScope.user.Id) .then(function (response) { - $scope.lstChangePass = response.data; + $scope.lstChangePass = response.data; var abc = $scope.lstChangePass; $scope.lstsinglepass = []; - angular.forEach($scope.lstChangePass, function (value, key) { - $scope.lstsinglepass.push(value.profileName); + angular.forEach($scope.lstChangePass, function (value, key) { + $scope.lstsinglepass.push(value.profileName); }); console.log($scope.lstsinglepass); if (response.data != "No Data") { @@ -43,9 +112,9 @@ SocioboardApp.controller('NotificationAllController', function ($rootScope, $sco else { $scope.notifycount = 0; } - + console.log("data", $scope.notifycount); - + }, function (reason) { $scope.error = reason.data; }); @@ -65,7 +134,7 @@ SocioboardApp.controller('NotificationAllController', function ($rootScope, $sco $http.get(apiDomain + '/api/Notifications/getfbchangeprofile?userId=' + $rootScope.user.Id) .then(function (response) { $scope.lstfbprofile = response.data; - // console.log($scope.lstfbprofile); + // console.log($scope.lstfbprofile); //var abc = $scope.lstfbprofile; //$scope.notifycount = $scope.notifycount + 10; @@ -80,7 +149,7 @@ SocioboardApp.controller('NotificationAllController', function ($rootScope, $sco $scope.reconnect = function () { var facebookid = $scope.lstfbprofile; console.log($scope.lstfbprofile); - // console.log("abcd", $scope.lstfbprofile.userPrimaryEmail); + // console.log("abcd", $scope.lstfbprofile.userPrimaryEmail); $http.get(domain + '/socioboard/recfbcont?id=' + facebookid + '&fbprofileType=' + 0) .then(function (response) { window.location.href = response.data; @@ -93,7 +162,7 @@ SocioboardApp.controller('NotificationAllController', function ($rootScope, $sco // start codes to load recent Feeds - $scope.loadmore = function () { + $scope.loadmore = function () { $("#load_more_toggle").addClass("hide"); $http.get(apiDomain + '/api/Notifications/FindAllNotifications?userId=' + $rootScope.user.Id + '&skip=' + $scope.notifycount + '&count=' + 10) .then(function (response) { @@ -106,7 +175,7 @@ SocioboardApp.controller('NotificationAllController', function ($rootScope, $sco }) }, function (reason) { $scope.error = reason.data; - }); + }); } // end codes to load recent Feeds }); diff --git a/src/Socioboard/wwwroot/contents/socioboard/views/settings/notification_all.html b/src/Socioboard/wwwroot/contents/socioboard/views/settings/notification_all.html index 75e9cc73a..c1c956191 100644 --- a/src/Socioboard/wwwroot/contents/socioboard/views/settings/notification_all.html +++ b/src/Socioboard/wwwroot/contents/socioboard/views/settings/notification_all.html @@ -1,17 +1,19 @@
@@ -22,54 +24,79 @@
Your notifications
- - +
+
+ +
+
+ + + + + +
+
+
    +
  • + Team Name: {{notify.message}} +

    Team invites you to join!!

    + + Accept + Decline + +
  • +
+ + +
+
+ - - -
diff --git a/src/Socioboard/wwwroot/contents/socioboard/views/shared/header.html b/src/Socioboard/wwwroot/contents/socioboard/views/shared/header.html index 73f58aa63..e392d2e9e 100644 --- a/src/Socioboard/wwwroot/contents/socioboard/views/shared/header.html +++ b/src/Socioboard/wwwroot/contents/socioboard/views/shared/header.html @@ -141,12 +141,12 @@

--> - + + + {{notifycount}} +