public PartyCongressCandidatesListViewModel(List <CongressCandidate> candidates, IPartyService partyService, Entities.Party party) : base(candidates) { PartyRole = PartyRoleEnum.NotAMember; if (SessionHelper.CurrentEntity.Citizen != null) { PartyRole = partyService.GetPartyRole(SessionHelper.LoggedCitizen, party); if (partyService.CanAcceptCongressCandidates(SessionHelper.CurrentEntity.Citizen, party)) { CanAcceptCandidates = true; } } }
public MethodResult CanCropUpload(Upload upload, Entity entity, Entity currentEntity, Citizen currentCitizen, CropRectangle crop) { if (upload.UploadedByCitizenID != currentCitizen.ID) { return(new MethodResult("This is not your upload!")); } switch (entity.GetEntityType()) { case EntityTypeEnum.Citizen: if (entity.EntityID != currentEntity.EntityID) { return(new MethodResult("You cannot do that!")); } break; case EntityTypeEnum.Company: { var rights = companyService.GetCompanyRights(entity.Company, currentEntity, currentCitizen); if (rights.CanSwitch == false) { return(new MethodResult("You cannot do that!")); } break; } case EntityTypeEnum.Newspaper: { var rights = newspaperService.GetNewspaperRights(entity.Newspaper, currentEntity, currentCitizen); if (rights != NewspaperRightsEnum.Full) { return(new MethodResult("You cannot do that!")); } break; } case EntityTypeEnum.Party: { var role = partyService.GetPartyRole(currentCitizen, entity.Party); if (role < PartyRoleEnum.Manager) { return(new MethodResult("You cannot do that!")); } break; } } if (crop.X < 0 || crop.Y < 0) { return(new MethodResult("Wrong crop!")); } using (var image = Image.FromFile(GetFilePathForLocation(upload))) { if (crop.X + crop.Width > image.Width || crop.Y + crop.Height > image.Height) { return(new MethodResult("Wrong crop!")); } } return(MethodResult.Success); }