Exemplo n.º 1
0
 public ScheduleEventModel()
 {
     //ByPerson = new PersonInSchedule();
     ForPersons            = new List <PersonInSchedule>();
     Contact               = new PersonInSchedule();
     Activities            = new List <ActivityEventModel>();
     ScheduleDurationModel = new ScheduleDurationModel();
 }
 public PersonInSchedule(PersonInSchedule personInSchedule, int newIndex)
 {
     Id              = personInSchedule.Id;
     UserId          = personInSchedule.UserId;
     UserFullName    = personInSchedule.UserFullName;
     MobileNumber    = personInSchedule.MobileNumber;
     IsContactPerson = personInSchedule.IsContactPerson;
     IsSelected      = personInSchedule.IsSelected;
     EditAccess      = personInSchedule.EditAccess;
     EditMode        = personInSchedule.EditMode;
     Index           = newIndex;
 }
Exemplo n.º 3
0
        public ScheduleEventModel(R.SingleResource resource)
        {
            ResourceId          = resource.Id;
            ResourceName        = resource.Name;
            ResourceDescription = resource.Description;
            WithActivity        = resource.WithActivity;
            ResourceQuantity    = resource.Quantity;

            ScheduleDurationModel scheduleDurationModel = new ScheduleDurationModel();

            scheduleDurationModel.DurationValue = resource.Duration.Value;
            scheduleDurationModel.TimeUnit      = resource.Duration.TimeUnit;
            ScheduleDurationModel = scheduleDurationModel;

            //ByPerson = new PersonInSchedule();
            ForPersons = new List <PersonInSchedule>();
            Contact    = new PersonInSchedule();
            Activities = new List <ActivityEventModel>();
            Files      = new List <FileValueModel>();

            //Get File to Resource if exsist
            foreach (ResourceAttributeUsage usage in resource.ResourceStructure.ResourceAttributeUsages)
            {
                if (usage.IsFileDataType)
                {
                    using (ResourceStructureAttributeManager valueManager = new ResourceStructureAttributeManager())
                    {
                        ResourceAttributeValue value = valueManager.GetValueByUsageAndResource(usage.Id, resource.Id);
                        if (value is FileValue)
                        {
                            FileValue      fileValue = (FileValue)value;
                            FileValueModel fvm       = new FileValueModel(fileValue);
                            Files.Add(fvm);
                            //if (!usage.IsValueOptional)
                            if (fvm.Data != null)
                            {
                                ResourceHasFiles = true;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public BookingEventModel(List <ResourceCart> cart)
        {
            using (var userManager = new UserManager())
                using (var rManager = new ResourceManager())
                {
                    Schedules        = new List <ScheduleEventModel>();
                    DeletedSchedules = new List <long>();

                    foreach (ResourceCart rc in cart)
                    {
                        SingleResource     resource = rManager.GetResourceById(rc.Id);
                        ScheduleEventModel s        = new ScheduleEventModel(resource);
                        s.ScheduleDurationModel.Index     = rc.Index;
                        s.ScheduleQuantity                = 1; // allways selct one by default
                        s.ResourceAttributeValues         = resource.ResourceAttributeValues;
                        s.ResourceQuantity                = resource.Quantity;
                        s.ScheduleDurationModel.StartDate = DateTime.Now;
                        s.ScheduleDurationModel.EndDate   = DateTime.Now;
                        s.ByPerson   = rc.ByPersonName;
                        s.EditAccess = true;
                        s.EditMode   = true;


                        //add as default resvered by user as reserved for user
                        var userTask = userManager.FindByIdAsync(rc.ByPersonUserId);
                        userTask.Wait();
                        var user = userTask.Result;

                        PersonInSchedule byPerson = new PersonInSchedule(0, user, false);
                        byPerson.IsContactPerson = true;
                        s.Contact     = byPerson;
                        s.ContactName = rc.ByPersonName;
                        s.ForPersons.Add(byPerson);

                        s.Index = rc.Index;
                        Schedules.Add(s);
                    }
                }
        }
Exemplo n.º 5
0
        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;
            }
        }