Skip to content

Commit

Permalink
Socioboard 3.0.58
Browse files Browse the repository at this point in the history
  • Loading branch information
Sathish-Globussoft committed Jun 10, 2019
1 parent 08c219d commit 5ff57a9
Show file tree
Hide file tree
Showing 7 changed files with 326 additions and 103 deletions.
Binary file modified .vs/Socioboard/v14/.suo
Binary file not shown.
52 changes: 46 additions & 6 deletions src/Api.Socioboard/Controllers/GroupMemberController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -43,7 +44,7 @@ public GroupMemberController(ILogger<UserController> logger, IEmailSender emailS
/// <param name="members"></param>
/// <returns></returns>
[HttpPost("InviteGroupMembers")]
public IActionResult InviteGroupMembers(long groupId, string members)
public IActionResult InviteGroupMembers(long groupId, string members)
{
List<Groupmembers> lstGrpMembers = new List<Groupmembers>();
if (string.IsNullOrEmpty(members))
Expand All @@ -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))
{
Expand Down Expand Up @@ -100,6 +101,26 @@ public IActionResult InviteGroupMembers(long groupId, string members)
if (temp == null)
{
dbr.Add<Groupmembers>(member);

var savedMembers = dbr.Find<Groupmembers>(t => t.groupid == groupId && t.email == member.email).FirstOrDefault();

var lstnotifications = dbr.Single<Notifications>(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<Notifications>(notify);
}


_redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupMembers + groupId);
string path = _appEnv.WebRootPath + "\\views\\mailtemplates\\groupinvitation.html";
string html = System.IO.File.ReadAllText(path);
Expand All @@ -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);
Expand All @@ -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<Domain.Socioboard.Models.Groupmembers>(t => t.email.Equals(email)&&t.memberCode.Equals(code)).FirstOrDefault();
if(grpMember != null)
Domain.Socioboard.Models.Groupmembers grpMember = dbr.Find<Domain.Socioboard.Models.Groupmembers>(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<User>(email.Trim());
if (inMemUser == null)
Expand All @@ -169,6 +190,25 @@ public IActionResult ActivateGroupMember(string code, string email)
}
}


/// <summary>
///
/// </summary>
/// <param name="code"></param>
/// <param name="email"></param>
/// <returns></returns>
[HttpPost("DeclineGroupMember")]
public IActionResult DeclineGroupMember(string code, string email)
{
var dbr = new DatabaseRepository(_logger, _appEnv);
var grpMember = dbr.Find<Groupmembers>(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)
{
Expand Down
106 changes: 85 additions & 21 deletions src/Api.Socioboard/Controllers/NotificationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public IActionResult FindNotifications(long userId)
{
foreach (Notifications notify in lstnotifications)
{
ScheduledMessage schedulemsg = dbr.Single<ScheduledMessage>(t => t.id == notify.MsgId && t.userId==userId);
ScheduledMessage schedulemsg = dbr.Single<ScheduledMessage>(t => t.id == notify.MsgId && t.userId == userId);
if (schedulemsg != null)
{
lstschedulemsg.Add(schedulemsg);
Expand All @@ -72,7 +72,7 @@ public IActionResult FindNotifications(long userId)
{
return NotFound();
}


}

Expand All @@ -83,15 +83,15 @@ public IActionResult FindAllNotifications(long userId, int skip, int count)
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
List<ScheduledMessage> lstschedulemsg = new List<ScheduledMessage>();
List<Notifications> lstnotifications = dbr.FindWithRangeDesct<Notifications>(t => t.UserId == userId, skip, count, t=>t.Id).ToList();
List<Notifications> lstnotifications = dbr.FindWithRangeDesct<Notifications>(t => t.UserId == userId && t.MsgStatus != "Invited", skip, count, t => t.Id).ToList();
foreach (Notifications notify in lstnotifications)
{
ScheduledMessage schedulemsg = dbr.Single<ScheduledMessage>(t => t.id == notify.MsgId && t.userId==userId);
if(schedulemsg !=null)
ScheduledMessage schedulemsg = dbr.Single<ScheduledMessage>(t => t.id == notify.MsgId && t.userId == userId);
if (schedulemsg != null)
{
lstschedulemsg.Add(schedulemsg);
}

}
if (lstschedulemsg != null)
{
Expand All @@ -102,14 +102,60 @@ public IActionResult FindAllNotifications(long userId, int skip, int count)
return NotFound();
}
}
catch(Exception ex)
catch (Exception ex)
{
return NotFound();
}


}



/// <summary>
///
/// </summary>
/// <param name="userId"></param>
/// <param name="skip"></param>
/// <param name="count"></param>
/// <returns></returns>
[HttpGet("FindAllInvitationNotifications")]
public IActionResult FindAllInvitationNotifications(long userId, int skip, int count)
{
try
{
var dbr = new DatabaseRepository(_logger, _env);
var lstInvitations = new List<InvitationDetails>();
var notifications = dbr.FindWithRangeDesct<Notifications>(t => t.UserId == userId && t.MsgStatus == "Invited", skip, count, t => t.Id).ToList();
foreach (var notify in notifications)
{
var groupMember = dbr.Single<Groupmembers>(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)
{
Expand All @@ -132,33 +178,51 @@ 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<Notifications>(t => t.Id == notifyId);
dbr.Delete(notifyObject);
return Ok("deleted");
}
catch (Exception ex)
{
return NotFound();
}
}


[HttpGet("ChangePasswordDetail")]
public IActionResult ChangePasswordDetail(long userId)
{
try
{
{
MongoRepository mongorepo = new MongoRepository("FacebookPasswordChangeUserDetail", _appSettings);
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
List<Domain.Socioboard.Models.Facebookaccounts> datalst = dbr.Find<Facebookaccounts>(t => t.UserId == userId).ToList();
// Domain.Socioboard.Models.User userDet = dbr.FindSingle<User>(t => t.Id == userId);
var result = mongorepo.Find<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(t => t.userId == userId && t.status==false);
// Domain.Socioboard.Models.User userDet = dbr.FindSingle<User>(t => t.Id == userId);
var result = mongorepo.Find<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(t => t.userId == userId && t.status == false);
var task = Task.Run(async () =>
{
return await result;
});
int count = task.Result.Count;
IList<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail> lstfbpasschange = task.Result;
List<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail> lstfab = new List<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>();
foreach(var lstfb in lstfbpasschange)
foreach (var lstfb in lstfbpasschange)
{
if (lstfb.message.Contains("password"))
{
Expand All @@ -171,11 +235,11 @@ public IActionResult ChangePasswordDetail(long userId)
{

}

}

}
if (count>0)
if (count > 0)
{
return Ok(lstfab);
}
Expand All @@ -199,7 +263,7 @@ public IActionResult ChangeStatus(string profileId)
// DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
// List<Domain.Socioboard.Models.Facebookaccounts> datalst = dbr.Find<Facebookaccounts>(t => t.UserId == userId).ToList();
// Domain.Socioboard.Models.User userDet = dbr.FindSingle<User>(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<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(t => t.profileId == profileId && t.status == false);
var task = Task.Run(async () =>
{
Expand All @@ -208,7 +272,7 @@ public IActionResult ChangeStatus(string profileId)
int count = task.Result.Count;
if (count > 0)
{

var builders = Builders<BsonDocument>.Filter;
FilterDefinition<BsonDocument> filter = builders.Eq("profileId", profileId);
var update = Builders<BsonDocument>.Update.Set("status", true);
Expand All @@ -229,14 +293,14 @@ public IActionResult getfbchangeprofile(long userId)
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
List<Domain.Socioboard.Models.Facebookaccounts> datalst = dbr.Find<Facebookaccounts>(t => t.UserId == userId).ToList();
Domain.Socioboard.Models.User userDet = dbr.FindSingle<User>(t => t.Id == userId);
var result = mongorepo.Find<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(t => t.userId == userId && t.status==false);
var result = mongorepo.Find<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(t => t.userId == userId && t.status == false);
var task = Task.Run(async () =>
{
return await result;
});
int count = task.Result.Count;
IList<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail> lstfbpasschange = task.Result;
if (count>0)
if (count > 0)
{
return Ok(lstfbpasschange);
}
Expand Down
23 changes: 23 additions & 0 deletions src/Domain.Socioboard/Models/InvitationDetails.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
Loading

0 comments on commit 5ff57a9

Please sign in to comment.