本文整理汇总了C#中Person.HasPermission方法的典型用法代码示例。如果您正苦于以下问题:C# Person.HasPermission方法的具体用法?C# Person.HasPermission怎么用?C# Person.HasPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person.HasPermission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FetchBulkSmsUsernameAndPassword
public static void FetchBulkSmsUsernameAndPassword(Person currentPerson, out string username, out string password)
{
if (currentPerson.HasPermission(common.Permissions.SmsChurch) || currentPerson.HasPermission(common.Permissions.SmsGroupLeaders) || currentPerson.HasPermission(common.Permissions.SmsGroupMembers))
{
using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
{
username = (from c in context.ChurchSmsProviders
where c.ChurchId == currentPerson.ChurchId
&& c.SmsProviderId == (int)SmsProviders.BulkSmsSouthAfrica
select c.Username)
.FirstOrDefault();
password = (from c in context.ChurchSmsProviders
where c.ChurchId == currentPerson.ChurchId
&& c.SmsProviderId == (int)SmsProviders.BulkSmsSouthAfrica
select c.Password)
.FirstOrDefault();
return;
}
}
username = null;
password = null;
}
示例2: AddStandardComment
public static List<StandardCommentViewModel> AddStandardComment(Person currentPerson, string standardComment)
{
using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
{
if (currentPerson.HasPermission(common.Permissions.AddEvent))
{
var check = CheckToSeeIfTheCommentIsAlreadyThere(currentPerson, standardComment, context);
if (check == 0)
{
var newStandardComment = new StandardComment
{
StandardComment1= standardComment,
ChurchId = currentPerson.ChurchId
};
context.StandardComments.AddObject(newStandardComment);
context.SaveChanges();
}
}
return (from e in context.StandardComments
where e.ChurchId == currentPerson.ChurchId
select new StandardCommentViewModel
{
StandardCommentId = e.StandardCommentId,
StandardComment = e.StandardComment1
}).ToList();
}
}
示例3: DeleteSite
public static string DeleteSite(Person currentPerson, int siteId)
{
if (currentPerson.HasPermission(Permissions.DeleteSite))
{
using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
{
var siteToDelete = (from s in context.Sites
where s.ChurchId == currentPerson.ChurchId
&& s.SiteId == siteId
select s).FirstOrDefault();
if (siteToDelete == null)
{
return "Could not delete site";
}
//Remove all the people linked to this site
var peopleLinkedToSite = context.People.Where(p => p.SiteId == siteId);
foreach (var p in peopleLinkedToSite)
{
p.SiteId = null;
p.Changed = DateTime.Now;
}
context.Sites.DeleteObject(siteToDelete);
context.SaveChanges();
return "Site succesfully removed";
}
}
return "Could not delete site";
}
示例4: FetchPermissionsForRoleJQGrid
public static JqGridData FetchPermissionsForRoleJQGrid(Person currentPerson, JqGridRequest request, int roleId)
{
using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
{
var permissions = (from p in context.Permissions
join pr in context.PermissionRoles
on p.PermissionId equals pr.PermissionId
join r in context.Roles
on pr.RoleId equals r.RoleId
where r.ChurchId == currentPerson.ChurchId
&& (pr.RoleId == roleId)
select p);
if (!currentPerson.HasPermission(Permissions.SystemAdministrator))
{
permissions = permissions.Where(p => p.IsVisible == true);
}
int totalRecords = permissions.Count();
switch (request.sidx)
{
case "Permission":
{
if (request.sord.ToLower() == "asc")
{
permissions = permissions.OrderBy(p => p.Name).Skip((request.page - 1) * request.rows).Take(request.rows);
}
else
{
permissions = permissions.OrderByDescending(p => p.Name).Skip((request.page - 1) * request.rows).Take(request.rows);
}
break;
}
}
JqGridData peopleGridData = new JqGridData()
{
total = (int)Math.Ceiling((float)totalRecords / (float)request.rows),
page = request.page,
records = totalRecords,
rows = (from p in permissions.AsEnumerable()
select new JqGridRow()
{
id = p.PermissionId.ToString(),
cell = new string[]
{
p.PermissionId.ToString(),
p.Name
}
}).ToArray()
};
return peopleGridData;
}
}
示例5: DeletePerson
public static void DeletePerson(int personId, Person currentPerson)
{
if(!currentPerson.HasPermission(Permissions.DeletePerson))
return;
using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
{
if (RemovePersonFromChurchSpecificTables(personId, currentPerson, context))
{
DeletePerson(personId, context);
}
context.SaveChanges();
}
}
示例6: AddGroupClassification
public static List<GroupClassificationViewModel> AddGroupClassification(Person currentPerson, string groupClassification)
{
using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
{
if (currentPerson.HasPermission(common.Permissions.AddGroupClassification))
{//Check to see if it is not already in the db
var check = (from g in context.GroupClassifications
where g.ChurchId == currentPerson.ChurchId
&& g.Name == groupClassification
select g).Count();
if (check == 0)
{
GroupClassification gc = new GroupClassification();
gc.Created = DateTime.Now;
gc.Changed = DateTime.Now;
gc.Name = groupClassification;
gc.ChurchId = currentPerson.ChurchId;
if (currentPerson.ChurchId == 3) //ebenezer
{
gc.GroupTypeId = (int)GroupTypes.LifeGroup;
}
else
{
gc.GroupTypeId = (int)GroupTypes.HomeGroup;
}
context.GroupClassifications.AddObject(gc);
context.SaveChanges();
}
}
return (from g in context.GroupClassifications
where g.ChurchId == currentPerson.ChurchId
select new GroupClassificationViewModel
{
GroupClassificationId = g.GroupClassificationId,
GroupClassification = g.Name
}).ToList();
}
}
示例7: AddPermissionsToRole
public static void AddPermissionsToRole(Person currentPerson, int roleId, List<int> permissionIds)
{
if (!currentPerson.HasPermission(Permissions.EditPermissions))
return;
using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
{
foreach (var permissionId in permissionIds)
{
PermissionRole pr = new PermissionRole()
{
RoleId = roleId,
Changed = DateTime.Now,
Created = DateTime.Now,
PermissionId = permissionId
};
context.PermissionRoles.AddObject(pr);
}
context.SaveChanges();
}
}
示例8: SendVisitorWelcome
private static void SendVisitorWelcome(bool includeUsername,
string firstname,
string surname,
Church church,
string email,
Person personToSave)
{
string password = string.Empty;
if (includeUsername)
{
personToSave.Username = (firstname + surname).Replace(" ", string.Empty); //TODO replace with a boolean saying welcome letter has been sent
password = RandomPasswordGenerator.Generate(RandomPasswordOptions.AlphaNumeric);
personToSave.PasswordHash = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "sha1");
}
personToSave.PublicId = Email.SendWelcomeEmail(firstname,
surname,
church,
email,
password,
personToSave.HasPermission(Permissions.SendVisitorWelcomeLetter),
includeUsername);
}
示例9: FetchChurchListJQGrid
public static JqGridData FetchChurchListJQGrid(Person currentPerson, JqGridRequest request)
{
using (oikonomosEntities context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
{
var rolesToInclude = context
.PermissionRoles
.Where(p => p.PermissionId == (int)Permissions.IncludeInChurchList && p.Role.ChurchId == currentPerson.ChurchId)
.Select(p=>p.RoleId)
.ToList();
var people = (from p in context.People.Include("Family").Include("PersonOptionalFields")
from c in p.PersonChurches
where c.ChurchId == currentPerson.ChurchId
&& rolesToInclude.Contains(c.RoleId)
select p);
if (!(currentPerson.HasPermission(Permissions.ViewChurchContactDetails)))
{
if(!currentPerson.HasPermission(Permissions.ViewGroupContactDetails))
throw new Exception("You do not have permission to view contact details");
//Get the groups
var groups = (from pg in context.PersonGroups
where pg.PersonId == currentPerson.PersonId
select pg.GroupId).ToList();
people = (from p in people
from pg in p.PersonGroups
where groups.Contains(pg.GroupId)
select p);
}
if (request._search)
{
switch (request.searchField)
{
case "search":
{
people = Filters.ApplyNameSearch(request.searchString, people);
break;
}
case "homegroup":
{
var homegroupId = (from pg in context.PersonGroups
where pg.PersonId == currentPerson.PersonId
select pg.GroupId).FirstOrDefault();
if (homegroupId > 0)
{
people = (from p in context.People.Include("Family").Include("PersonOptionalFields")
from c in p.PersonChurches
join pg in context.PersonGroups
on p.PersonId equals pg.PersonId
where c.ChurchId == currentPerson.ChurchId
&& pg.GroupId == homegroupId
select p);
}
break;
}
}
}
int totalRecords = people.Count();
switch (request.sidx)
{
case "Firstname":
{
people = request.sord.ToLower() == "asc" ? people.OrderBy(p => p.Firstname).Skip((request.page - 1) * request.rows).Take(request.rows) : people.OrderByDescending(p => p.Firstname).Skip((request.page - 1) * request.rows).Take(request.rows);
break;
}
case "Surname":
{
people = request.sord.ToLower() == "asc" ? people.OrderBy(p => p.Family.FamilyName).Skip((request.page - 1) * request.rows).Take(request.rows) : people.OrderByDescending(p => p.Family.FamilyName).Skip((request.page - 1) * request.rows).Take(request.rows);
break;
}
case "Email":
{
people = request.sord.ToLower() == "asc" ? people.OrderBy(p => p.Email).Skip((request.page - 1) * request.rows).Take(request.rows) : people.OrderByDescending(p => p.Email).Skip((request.page - 1) * request.rows).Take(request.rows);
break;
}
}
var membersGridData = new JqGridData()
{
total = (int)Math.Ceiling((float)totalRecords / request.rows),
page = request.page,
records = totalRecords,
rows = (from p in people.AsEnumerable()
select new JqGridRow()
{
id = p.PersonId.ToString(),
cell = new string[] {
p.PersonId.ToString(),
p.Firstname,
p.Family.FamilyName,
p.Family.HomePhone,
p.PersonOptionalFields.FirstOrDefault(c => c.OptionalFieldId == (int)OptionalFields.CellPhone)==null?"":p.PersonOptionalFields.FirstOrDefault(c => c.OptionalFieldId == (int)OptionalFields.CellPhone).Value,
p.Email
}
}).ToArray()
//.........这里部分代码省略.........
示例10: SendEmails
private static void SendEmails(PersonViewModel person, bool sendWelcomeEmail, Church church, Person personToSave)
{
if (sendWelcomeEmail && person.PersonId == 0 && personToSave.HasPermission(Permissions.SendWelcomeLetter) && personToSave.HasValidEmail())
{
SendVisitorWelcome(sendWelcomeEmail,
person.Firstname,
person.Surname,
church,
person.Email,
personToSave);
}
else if (sendWelcomeEmail && personToSave.HasValidEmail() && personToSave.HasPermission(Permissions.Login))
{
SendEmailAndPassword(person.Firstname,
person.Surname,
church,
person.Email,
personToSave);
}
}
示例11: SaveSite
public static void SaveSite(Person currentPerson, SiteSettingsViewModel siteSettings)
{
if (string.IsNullOrWhiteSpace(siteSettings.SiteName))
return;
using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
{
//Check Roles
if (!currentPerson.HasPermission(Permissions.AddSite) && !currentPerson.HasPermission(Permissions.EditSite)) return;
var siteToSave = new Site();
if (siteSettings.SiteId == 0)
{
if (!currentPerson.HasPermission(Permissions.AddSite)) return;
siteToSave.Created = DateTime.Now;
siteToSave.ChurchId = currentPerson.ChurchId;
}
else
{
if (!currentPerson.HasPermission(Permissions.EditSite)) return;
siteToSave = (from s in context.Sites.Include("Address")
where s.SiteId == siteSettings.SiteId
select s).FirstOrDefault() ??
new Site {Created = DateTime.Now, ChurchId = currentPerson.ChurchId};
}
siteToSave.Changed = DateTime.Now;
siteToSave.Name = siteSettings.SiteName;
if (siteSettings.AddressId == 0)
{
siteToSave.Address = new Address {Created = DateTime.Now};
context.Sites.AddObject(siteToSave);
}
siteToSave.Address.Changed = DateTime.Now;
siteToSave.Address.Line1 = siteSettings.Address1 ?? string.Empty;
siteToSave.Address.Line2 = siteSettings.Address2 ?? string.Empty;
siteToSave.Address.Line3 = siteSettings.Address3 ?? string.Empty;
siteToSave.Address.Line4 = siteSettings.Address4 ?? string.Empty;
siteToSave.Address.Lat = siteSettings.Lat;
siteToSave.Address.Long = siteSettings.Lng;
siteToSave.Address.AddressType = siteSettings.AddressType ?? string.Empty;
context.SaveChanges();
}
}
示例12: FetchPersonAutoComplete
public static AutoCompleteViewModel[] FetchPersonAutoComplete(string term, Person currentPerson, bool wholeChurch)
{
using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
{
var query = (from p in context.People.Include("PersonOptionalField").Include("Address")
from c in p.PersonChurches
join r in context.Roles
on c.RoleId equals r.RoleId
where c.ChurchId == currentPerson.ChurchId
&& r.ChurchId == currentPerson.ChurchId
select p);
if (term.Contains(" "))
{
var searchStrings = term.Split(' ');
var searchString1 = searchStrings[0];
var searchString2 = searchStrings[1];
query = query.Where(p => p.Firstname.Contains(searchString1) && p.Family.FamilyName.Contains(searchString2));
}
else
{
query = query.Where(p => p.Firstname.Contains(term) || p.Family.FamilyName.Contains(term));
}
if (!wholeChurch)
{
//Find out the persons role
if (currentPerson.HasPermission(Permissions.EditChurchPersonalDetails))
{
//No filter required
query = query.Take(12);
}
else if (currentPerson.HasPermission(Permissions.EditGroupPersonalDetails))
{
var grp = (from g in context.Groups
where g.LeaderId == currentPerson.PersonId
|| g.AdministratorId == currentPerson.PersonId
select g).FirstOrDefault();
if (grp == null)
{
return new AutoCompleteViewModel[0];
}
//Filter for the group
query = (from q in query
join pg in context.PersonGroups
on q.PersonId equals pg.PersonId
where pg.GroupId == grp.GroupId
select q).Take(12);
}
else
{
return new AutoCompleteViewModel[0];
}
}
return (from p in query.OrderBy(p => p.Firstname)
select new AutoCompleteViewModel
{
id = p.PersonId,
label = p.Firstname + " " + p.Family.FamilyName,
value = p.Firstname + " " + p.Family.FamilyName
}).ToArray();
}
}
示例13: SavePerson
public static int SavePerson(PersonViewModel person, Person currentPerson)
{
using (var context = new oikonomosEntities(ConfigurationManager.ConnectionStrings["oikonomosEntities"].ConnectionString))
{
if (!currentPerson.HasPermission(Permissions.EditChurchPersonalDetails))
{
if (currentPerson.HasPermission(Permissions.EditGroupPersonalDetails))
{
if (!CheckSavePermissionGroup(person, currentPerson, context)) { return person.PersonId; }
}
else if (currentPerson.HasPermission(Permissions.EditOwnDetails))
{
if (!CheckSavePermissionPersonal(person, currentPerson, context)) { return person.PersonId; }
}
else
{
return person.PersonId;
}
}
bool sendWelcomeEmail;
Church church;
Person personToSave;
GetPersonToSaveEntity(person, currentPerson, context, out sendWelcomeEmail, out church, out personToSave);
bool anniversaryHasChanged = SavePersonalDetails(person, currentPerson, context, personToSave);
SaveRole(person, currentPerson, context, personToSave);
bool addedToNewGroup = AddPersonToGroup(person, currentPerson, context, personToSave);
SaveContactInformation(person, personToSave);
SaveAddressInformation(person, personToSave);
UpdateRelationships(person, context, personToSave, anniversaryHasChanged);
context.SaveChanges();
personToSave = FetchPerson(personToSave.PersonId, context, currentPerson);
SaveWindowsLiveId(person, personToSave, context);
SendEmails(person, sendWelcomeEmail, church, personToSave);
EmailGroupLeader(person, currentPerson, context, church, personToSave, addedToNewGroup);
context.SaveChanges();
return personToSave.PersonId;
}
}
示例14: CheckSavePermissionGroup
private static bool CheckSavePermissionGroup(PersonViewModel person, Person currentPerson, oikonomosEntities context)
{
var canSave = false;
if (person.PersonId > 0)
{
var groupPerson = (from pg in context.PersonGroups
join g in context.Groups
on pg.GroupId equals g.GroupId
where pg.PersonId == person.PersonId
&& g.ChurchId == currentPerson.ChurchId
&& (g.LeaderId == currentPerson.PersonId || g.AdministratorId == currentPerson.PersonId)
select pg).FirstOrDefault();
if (groupPerson != null)
{
canSave = true;
}
}
else
{
canSave = currentPerson.HasPermission(Permissions.AddNewPerson);
}
return canSave;
}
示例15: CheckThatChurchIdsMatch
private static void CheckThatChurchIdsMatch(int personId, Person currentPerson, oikonomosEntities context)
{
if (currentPerson.HasPermission(Permissions.SystemAdministrator))
return;
if (!context.People.First(p => p.PersonId == personId).PersonChurches.Select(c => c.ChurchId).ToList().Contains(currentPerson.ChurchId))
throw new ApplicationException("ChurchId does not match currentPerson ChurchId");
}