public static bool PeopleMatch(Person forPerson, List <long> personsInSchedule) { List <long> personInConstraint = new List <long>(); if (forPerson.Self is PersonGroup) { PersonGroup pGroup = (PersonGroup)forPerson.Self; personInConstraint = pGroup.Users.Select(a => a.Id).ToList(); } else if (forPerson.Self is IndividualPerson) { IndividualPerson iPerson = (IndividualPerson)forPerson.Self; personInConstraint.Add(iPerson.Person.Id); } var diff = personInConstraint.Intersect(personsInSchedule); if (diff.Count() > 0) { return(true); } else { return(false); } }
private List <Schedule> FilterSchedulesForUser(List <Schedule> scheduleList, long userId) { List <Schedule> filteredScheduleList = new List <Schedule>(); using (var uow = this.GetUnitOfWork()) { foreach (Schedule s in scheduleList) { var forPerson = uow.GetReadOnlyRepository <Person>().Get(s.ForPerson.Id); if (forPerson is PersonGroup) { PersonGroup pg = (PersonGroup)forPerson; foreach (User u in pg.Users) { if (u.Id == userId) { filteredScheduleList.Add(s); break; } } } else if (forPerson is IndividualPerson) { IndividualPerson ip = (IndividualPerson)forPerson; if (ip.Person.Id == userId) { filteredScheduleList.Add(s); break; } } } } return(filteredScheduleList.Distinct().ToList()); }
public BlockingConstraintModel(BlockingConstraint constraint) { Id = constraint.Id; Index = constraint.Index; Negated = constraint.Negated; SelectedMode = constraint.Mode; Description = constraint.Description; AllUsers = constraint.AllUsers; ForEver = constraint.ForEver; ForTimeInterval = new TimeInterval(); if (constraint.ForPeriodicTimeInterval != null) { if (constraint.ForPeriodicTimeInterval.Id != 0) { ForPeriodicTimeInterval = new PeriodicTimeIntervalModel(constraint.ForPeriodicTimeInterval, (DateTime)constraint.ForTimeInterval.StartTime.Instant, constraint.ForTimeInterval.EndTime.Instant); ForPeriodicTimeInterval.IsSet = true; ForPeriodicTimeInterval.Index = constraint.Index; } else { ForPeriodicTimeInterval = new PeriodicTimeIntervalModel(); } } if (constraint.ForPerson != null) { if (constraint.ForPerson.Self is PersonGroup) { PersonGroup pGroup = (PersonGroup)constraint.ForPerson.Self; // pGroup.Users.ToList().ForEach(u => ForPersons.Add(new PersonInConstraint(u, pGroup.Id, constraint.Index))); } else if (constraint.ForPerson.Self is IndividualPerson) { IndividualPerson iPerson = (IndividualPerson)constraint.ForPerson.Self; ForPersons.Add(new PersonInConstraint(iPerson.Person, iPerson.Id, constraint.Index)); } } if (constraint.ForTimeInterval != null) { TimeInterval timeInterval = new TimeInterval(); timeInterval = constraint.ForTimeInterval.Self; timeInterval.StartTime = constraint.ForTimeInterval.StartTime.Self; timeInterval.EndTime = constraint.ForTimeInterval.EndTime.Self; ForTimeInterval = timeInterval; } else { ForTimeInterval = new TimeInterval(); } }
public IndividualPerson UpdateIndividualPerson(IndividualPerson individualPerson) { Contract.Requires(individualPerson != null); using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <IndividualPerson> repo = uow.GetRepository <IndividualPerson>(); repo.Merge(individualPerson); var merged = repo.Get(individualPerson.Id); repo.Put(merged); uow.Commit(); } return(individualPerson); }
//public ScheduleListModel(Schedule s) public ScheduleListModel(long eventId, string bookingEventName, string bookingEventDescription, string resourceName, DateTime start, DateTime end, string quantity, Person forPerson, ICollection <Activity> activities, string contactPerson) { EventID = eventId; EventName = bookingEventName; EventDescription = bookingEventDescription; ResourceName = resourceName; StartDate = start; EndDate = end; Quantity = quantity; ContactPerson = contactPerson; if (forPerson is PersonGroup) { PersonGroup pg = (PersonGroup)forPerson; int count = 1; foreach (User u in pg.Users) { //string reservedForName = getPartyName(u.Id); //if (reservedForName != "false") // { // u.Name = reservedForName; // } if (count < pg.Users.Count()) { ReservedFor += u.DisplayName + ", "; } else { ReservedFor += u.DisplayName; } count++; } } else if (forPerson is IndividualPerson) { IndividualPerson ip = (IndividualPerson)forPerson; ReservedFor = ip.Person.DisplayName; } Activities = string.Join(", ", activities.Select(a => a.Name)); }
/// <summary> /// Creates an IndividualPerson <seealso cref="IndividualPerson"/> and persists the entity in the database. /// </summary> public IndividualPerson CreateIndividualPerson(User user) { IndividualPerson individualPerson = new IndividualPerson(user); individualPerson.Contact = user; using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <IndividualPerson> repo = uow.GetRepository <IndividualPerson>(); repo.Put(individualPerson); uow.Commit(); } return(individualPerson); }
public bool DeleteIndividualPerson(IndividualPerson individualPerson) { Contract.Requires(individualPerson != null); Contract.Requires(individualPerson.Id >= 0); using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <IndividualPerson> repo = uow.GetRepository <IndividualPerson>(); individualPerson = repo.Reload(individualPerson); repo.Delete(individualPerson); uow.Commit(); } return(true); }
static void Main(string[] args) { Person[] people; Console.Write("Entre com a quantidade de pagadores: "); int n = int.Parse(Console.ReadLine()); people = new Person[n]; Console.WriteLine(); for (int i = 0; i < n; i++) { Console.WriteLine($"Entre com os dados do {i + 1}º: "); Console.Write("Física ou Jurídica (f/j)? "); char d = char.Parse(Console.ReadLine()); Console.Write("Nome: "); string name = Console.ReadLine(); Console.Write("Renda anual: "); double annualIncome = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); if (d == 'f') { Console.Write("Despesas médicas: "); double medicalExpenses = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); people[i] = new IndividualPerson(name, annualIncome, medicalExpenses); } else if (d == 'j') { Console.Write("Número de empregados: "); int numEmployees = int.Parse(Console.ReadLine()); people[i] = new LegalPerson(name, annualIncome, numEmployees); } Console.WriteLine(); } Console.WriteLine("Imposto pago:"); foreach (Person person in people) { Console.WriteLine(person); } }
public Schedule CreateSchedule(DateTime startDate, DateTime endDate, BookingEvent thisEvent, R.SingleResource resource, Person forPerson, Person byPerson, IEnumerable <long> activities, int quantity, int index) { Schedule schedule = new Schedule(); schedule.Activities = new List <Activity>(); schedule.StartDate = startDate.Date; schedule.EndDate = endDate.Date; schedule.BookingEvent = thisEvent; schedule.Resource = resource; //schedule.Activities = activities; schedule.Index = index; schedule.Quantity = quantity; if (forPerson is PersonGroup) { PersonGroup pGroup = (PersonGroup)forPerson; schedule.ForPerson = pGroup; } else { IndividualPerson iPerson = (IndividualPerson)forPerson; schedule.ForPerson = iPerson; } IndividualPerson iPersonBy = (IndividualPerson)byPerson; schedule.ByPerson = iPersonBy; using (IUnitOfWork uow = this.GetUnitOfWork()) { //load activites activities.ToList().ForEach(a => schedule.Activities.Add(uow.GetReadOnlyRepository <Activity>().Get(a))); IRepository <Schedule> repo = uow.GetRepository <Schedule>(); repo.Put(schedule); uow.Commit(); } return(schedule); }
private void SendNotification(Notification notification, List <Schedule> affectedSchedules) { List <string> userToNotify = new List <string>(); foreach (Schedule s in affectedSchedules) { if (s.ForPerson.Self is PersonGroup) { PersonGroup pGroup = (PersonGroup)s.ForPerson.Self; foreach (User u in pGroup.Users) { if (!userToNotify.Contains(u.Email)) { userToNotify.Add(u.Email); } } } if (s.ForPerson.Self is IndividualPerson) { IndividualPerson iPerson = (IndividualPerson)s.ForPerson.Self; if (!userToNotify.Contains(iPerson.Person.Email)) { userToNotify.Add(iPerson.Person.Email); } } } string subject = "Resource Notification - " + notification.Subject; string message = ""; message += "<b>" + notification.Subject + "</b><br/><br/>"; message += "Startdate: " + notification.StartDate.ToString("yyyy-MM-dd") + "<br/>"; message += "EndDate: " + notification.EndDate.ToString("yyyy-MM-dd") + "<br/><br/>"; message += "<p>" + notification.Message + "</p>" + "<br/>"; SendNotificationHelper.SendNotification(userToNotify, message, subject); }
public Guid Handle() { try { IndividualPerson individualPerson = Mapper.Map <IndividualPerson>(_query.AdressManagementDetailDomainModel); if (individualPerson == null) { throw new DataException("Could not Map AdressManagementDetailDomainModel to IndividualPerson"); } Guid individualPersonUid = Guid.NewGuid(); Guid adressUid = Guid.NewGuid(); Guid memberinformationUid = Guid.NewGuid(); individualPerson.UID = individualPersonUid; individualPerson.Person.UID = individualPersonUid; individualPerson.AdressUID = adressUid; if (individualPerson.MemberInformation != null) { individualPerson.MemberInformation.UID = memberinformationUid; if (individualPerson.MemberInformation.MemberInformationToMemberships != null) { foreach (var memberInformationToMembership in individualPerson.MemberInformation.MemberInformationToMemberships) { memberInformationToMembership.MemberInformationUID = memberinformationUid; memberInformationToMembership.UID = Guid.NewGuid(); } } } if (individualPerson.Adress != null) { individualPerson.Adress.UID = adressUid; } foreach (var phone in individualPerson.Phones) { phone.IndividualPersonUID = individualPersonUid; phone.UID = Guid.NewGuid(); } foreach (var email in individualPerson.Emails) { email.IndividualPersonUID = individualPersonUid; email.UID = Guid.NewGuid(); } foreach (var personToMandator in individualPerson.Person.PersonToMandators) { personToMandator.PersonUID = individualPersonUid; personToMandator.UID = Guid.NewGuid(); } _uow.IndividualPersonRepository.Insert(_query.MandatorUIDs, individualPerson); _uow.Commit(); return(individualPerson.UID); } catch (DataException e) { throw new Exception("Internal Server Error", e); } catch (Exception) { throw new Exception("Internal Server Error"); } }
public void Handle() { try { IndividualPerson individualPerson = _uow.IndividualPersonRepository.Get(_query.MandatorUIDs, _query.IndividualPersonUID); if (individualPerson == null) { throw new DataException("No Entity found to UID : " + _query.IndividualPersonUID); } if (individualPerson.Phones != null && individualPerson.Phones.Any()) { DeletePhones(_query.MandatorUIDs, individualPerson.Phones.Select(p => p.UID).ToList()); } if (individualPerson.Emails != null && individualPerson.Emails.Any()) { DeleteEmails(_query.MandatorUIDs, individualPerson.Emails.Select(p => p.UID).ToList()); } List <Guid> personToMandatorsToDeleteUids = individualPerson.Person.PersonToMandators.Select(p => p.UID).ToList(); if (individualPerson.Person.Login != null) { if (individualPerson.Person.Login.Sessions != null && individualPerson.Person.Login.Sessions.Any()) { throw new DataException("Could not Delete, because there are active Sessions existing"); //DeleteSessions(individualPerson.Person.Login.Sessions.Select(s => s.UID).ToList()); } _uow.LoginRepository.Delete(_query.MandatorUIDs, individualPerson.Person.Login.UID); } _uow.IndividualPersonRepository.Delete(_query.MandatorUIDs, _query.IndividualPersonUID); if (individualPerson.Person != null && individualPerson.Person.IndividualPerson != null && individualPerson.Person.SystemPerson == null) { _uow.PersonRepository.Delete(_query.MandatorUIDs, individualPerson.Person.UID); } if (personToMandatorsToDeleteUids != null && personToMandatorsToDeleteUids.Any()) { DeletePersonToMandators(personToMandatorsToDeleteUids); } else { throw new DataException("No MandatorUDIs found for Entity with the UID : " + _query.IndividualPersonUID); } if (individualPerson.MemberInformationUID != null) { if (individualPerson.MemberInformation.MemberInformationToMemberships != null && individualPerson.MemberInformation.MemberInformationToMemberships.Any()) { DeleteMemberInformationToMemberships(individualPerson.MemberInformation.MemberInformationToMemberships.Select(m => m.UID).ToList()); } DeleteMemberInformation(_query.MandatorUIDs, individualPerson.MemberInformationUID.Value); } DeleteAdress(individualPerson.AdressUID); } catch (DataException e) { throw new Exception("Internal Server Error", e); } catch (Exception e) { throw new Exception("Internal Server Error"); } try { _uow.Commit(); } catch (DataException e) { throw new Exception("Internal Server Error during Saving changes", e); } catch (Exception) { throw new Exception("Internal Server Error during Saving changes"); } }
public ScheduleEventModel(Schedule schedule) { ScheduleId = schedule.Id; ResourceId = schedule.Resource.Id; ResourceName = schedule.Resource.Name; ResourceDescription = schedule.Resource.Description; ResourceAttributeValues = schedule.Resource.ResourceAttributeValues; Files = new List <FileValueModel>(); WithActivity = schedule.Resource.WithActivity; //Get File to Resource if exsist foreach (ResourceAttributeUsage usage in schedule.Resource.ResourceStructure.ResourceAttributeUsages) { if (usage.IsFileDataType) { using (ResourceStructureAttributeManager valueManager = new ResourceStructureAttributeManager()) { ResourceAttributeValue value = valueManager.GetValueByUsageAndResource(usage.Id, schedule.Resource.Id); if (value is FileValue) { FileValue fileValue = (FileValue)value; FileValueModel fvm = new FileValueModel(fileValue); Files.Add(fvm); if (!usage.IsValueOptional) { ResourceHasFiles = true; } } } } } ScheduleDurationModel scheduleDurationModel = new ScheduleDurationModel(); scheduleDurationModel.StartDate = schedule.StartDate; scheduleDurationModel.EndDate = schedule.EndDate; scheduleDurationModel.DurationValue = schedule.Resource.Duration.Value; scheduleDurationModel.TimeUnit = schedule.Resource.Duration.TimeUnit; ScheduleDurationModel = scheduleDurationModel; ScheduleQuantity = schedule.Quantity; ResourceQuantity = schedule.Resource.Quantity; Status = schedule.Resource.ResourceStatus.ToString(); //get Persons ForPersons = new List <PersonInSchedule>(); if (schedule.ForPerson.Self is PersonGroup) { PersonGroup pGroup = (PersonGroup)schedule.ForPerson.Self; Contact = new PersonInSchedule(pGroup.Id, pGroup.Contact, true); ContactName = pGroup.Contact.DisplayName; foreach (User u in pGroup.Users) { if (u.Id == pGroup.Contact.Id) { ForPersons.Add(new PersonInSchedule(pGroup.Id, u, true)); } else { ForPersons.Add(new PersonInSchedule(pGroup.Id, u, false)); } } } else if (schedule.ForPerson.Self is IndividualPerson) { IndividualPerson iPerson = (IndividualPerson)schedule.ForPerson.Self; Contact = new PersonInSchedule(iPerson.Id, iPerson.Contact, true); ContactName = iPerson.Contact.DisplayName; ForPersons.Add(new PersonInSchedule(iPerson.Id, iPerson.Person, true)); } if (schedule.ByPerson.Self is IndividualPerson) { IndividualPerson iPersonBy = (IndividualPerson)schedule.ByPerson.Self; ByPerson = iPersonBy.Person.DisplayName; } }