Ejemplo n.º 1
0
        public Person(IDocument document,
                      string name,
                      PersonRole role,
                      IWeekSchedule schedule,
                      IEnumerable<DayOfWeekDismiss> dayOfWeekDismisses,
                      IEnumerable<TemporaryDismiss> temporaryDismisses)
        {
            if (document == null)
                throw new ArgumentNullException(nameof(document));
            if (name == null)
                throw new ArgumentNullException(nameof(name));
            if (schedule == null)
                throw new ArgumentNullException(nameof(schedule));
            if (dayOfWeekDismisses == null)
                throw new ArgumentNullException(nameof(dayOfWeekDismisses));
            if (temporaryDismisses == null)
                throw new ArgumentNullException(nameof(temporaryDismisses));

            Identifier = document;
            Name = name;
            Role = role;
            Schedule = schedule;
            _dayOfWeekDismisses = dayOfWeekDismisses.ToArray();
            _temporaryDismisses = temporaryDismisses.ToArray();
        }
Ejemplo n.º 2
0
 public Person(string name, string surname, DateTime birthDate, string email, PersonRole role, IEnumerable<ISubject> subjects, IClass klass)
 {
     this.Name = name;
     this.Surname = surname;
     this.BirthDate = birthDate;
     this.Email = email;
     this.Role = role;
     this.Subjects = subjects;
     this.Class = klass;
 }
        public void AddPerson(PersonDTO item)
        {
            Person person = new Person()
            {
                Email        = item.Email,
                Password     = item.Password,
                FistName     = item.FistName,
                LastName     = item.LastName,
                CreationDate = DateTime.Now
            };

            var        role       = _testStoreContext.Roles.Find(2);
            PersonRole personRole = new PersonRole()
            {
                PersonId = person.Id,
                RolesId  = role.Id
            };

            _testStoreContext.Persons.Add(person);
            _testStoreContext.PersonsRoles.Add(personRole);
        }
Ejemplo n.º 4
0
        //Role/AddPerson
        //To add Person to Role
        public IActionResult AddPerson(int?roleId, int?personId)
        {
            if (roleId == null || personId == null)
            {
                return(BadRequest());
            }

            Person     person     = _context.People.Find(personId);
            Role       role       = _context.Roles.Find(roleId);
            PersonRole personRole = new PersonRole
            {
                PersonId = (int)personId,
                Person   = person,
                RoleId   = (int)roleId,
                Role     = role
            };

            _context.Entry(person).Collection(i => i.PersonRole).Load();
            if (person.PersonRole == null)
            {
                person.PersonRole = new List <PersonRole>();
            }

            if (role.PersonRole == null)
            {
                role.PersonRole = new List <PersonRole>();
            }
            role.PersonRole.Add(personRole);
            person.PersonRole.Add(personRole);

            if (ModelState.IsValid)
            {
                _context.Entry(role).State   = EntityState.Modified;
                _context.Entry(person).State = EntityState.Modified;
                _context.Add(personRole);
                _context.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(role));
        }
Ejemplo n.º 5
0
        public PersonRole CreateNewPersonRole()
        {
            StringInputDialog addPersonRoleDialog = new StringInputDialog();

            addPersonRoleDialog.Title   = "Creazione nuovo Ruolo Persona";
            addPersonRoleDialog.Message = "Nome:";

            if (addPersonRoleDialog.ShowDialog() != true)
            {
                return(null);
            }

            PersonRole newRole = new PersonRole
            {
                Name        = addPersonRoleDialog.InputString,
                Description = ""
            };

            using (LInstContext entities = _dbContextFactory.CreateDbContext(new string[] { }))
            {
                entities.PersonRoles.Add(newRole);

                foreach (Person per in entities.People)
                {
                    PersonRoleMapping newMapping = new PersonRoleMapping
                    {
                        Person     = per,
                        IsSelected = false
                    };
                    newRole.RoleMappings.Add(newMapping);
                }

                entities.SaveChanges();
            }

            return(newRole);
        }
Ejemplo n.º 6
0
    protected void ButtonAddOrgRole_Click(object sender, EventArgs e)
    {
        int personId      = (Person.FromIdentity(Convert.ToInt32("" + Request["id"]))).Identity;
        int currentUserId = Convert.ToInt32(HttpContext.Current.User.Identity.Name);

        RoleType roleType       = (RoleType)Enum.Parse(typeof(RoleType), DropRolesOrg.SelectedValue);
        int      nodeId         = Geography.RootIdentity;
        int      organizationId = Convert.ToInt32(DropOrganizationsOrg.SelectedValue);

        if (!_authority.HasPermission(Permission.CanEditOrganisationalRoles, organizationId, nodeId, Authorization.Flag.Default))
        {
            Page.ClientScript.RegisterStartupScript(typeof(Page), "ErrorMessage",
                                                    "alert ('You do not have permissions to add organisation roles for that organisation.');",
                                                    true);
            return;
        }

        if ((roleType == RoleType.OrganizationMemberService ||
             roleType == RoleType.OrganizationMemberServiceLead) &&
            organizationId != Organization.PPSEid)
        {
            Page.ClientScript.RegisterStartupScript(typeof(Page), "ErrorMessage",
                                                    "alert ('That role is only valid for PPSE.');",
                                                    true);
            return;
        }



        int roleId = PersonRole.Create(personId, roleType, organizationId, nodeId).Identity;

        // If we made it this far, add the role
        Activizr.Logic.Support.PWEvents.CreateEvent(EventSource.PirateWeb, EventType.AddedRole, currentUserId, organizationId,
                                                    nodeId, personId, (int)roleType, string.Empty);

        this.GridOrgRoles.DataBind();
    }
Ejemplo n.º 7
0
 public PersonRole Add(PersonRole pt)
 {
     _unitOfWork.Repository <PersonRole>().Insert(pt);
     return(pt);
 }
Ejemplo n.º 8
0
 public void Update(PersonRole pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <PersonRole>().Update(pt);
 }
Ejemplo n.º 9
0
        public bool Update(PersonRole personrole, int old_personRoleId)
        {
            PersonRoleDAC personroleComponent = new PersonRoleDAC();

            return(personroleComponent.UpdatePersonRole(personrole.RoleId, personrole.PersonId, personrole.ModifiedDate, old_personRoleId));
        }
        /// <summary>
        /// Persist the <see cref="PersonRole"/> containment tree to the ORM layer. Update if it already exists.
        /// This is typically used during the import of existing data to the Database.
        /// </summary>
        /// <param name="transaction">
        /// The current <see cref="NpgsqlTransaction"/> to the database.
        /// </param>
        /// <param name="partition">
        /// The database partition (schema) where the requested resource will be stored.
        /// </param>
        /// <param name="personRole">
        /// The <see cref="PersonRole"/> instance to persist.
        /// </param>
        /// <returns>
        /// True if the persistence was successful.
        /// </returns>
        private bool UpsertContainment(NpgsqlTransaction transaction, string partition, PersonRole personRole)
        {
            var results = new List <bool>();

            foreach (var alias in this.ResolveFromRequestCache(personRole.Alias))
            {
                results.Add(this.AliasService.UpsertConcept(transaction, partition, alias, personRole));
            }

            foreach (var definition in this.ResolveFromRequestCache(personRole.Definition))
            {
                results.Add(this.DefinitionService.UpsertConcept(transaction, partition, definition, personRole));
            }

            foreach (var hyperLink in this.ResolveFromRequestCache(personRole.HyperLink))
            {
                results.Add(this.HyperLinkService.UpsertConcept(transaction, partition, hyperLink, personRole));
            }

            foreach (var personPermission in this.ResolveFromRequestCache(personRole.PersonPermission))
            {
                results.Add(this.PersonPermissionService.UpsertConcept(transaction, partition, personPermission, personRole));
            }

            return(results.All(x => x));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PersonRoleDialogViewModel"/> class.
 /// </summary>
 /// <param name="personRole">
 /// The <see cref="PersonRole"/> that is the subject of the current view-model. This is the object
 /// that will be either created, or edited.
 /// </param>
 /// <param name="transaction">
 /// The <see cref="ThingTransaction"/> that contains the log of recorded changes.
 /// </param>
 /// <param name="session">
 /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated
 /// </param>
 /// <param name="isRoot">
 /// Assert if this <see cref="PersonRoleDialogViewModel"/> is the root of all dialogs
 /// </param>
 /// <param name="dialogKind">
 /// The kind of operation this <see cref="PersonRoleDialogViewModel"/> performs
 /// </param>
 /// <param name="thingDialogNavigationService">
 /// The <see cref="IThingDialogNavigationService"/> that allows to navigate to <see cref="Thing"/> dialog view models
 /// </param>
 /// <param name="container">The container <see cref="Thing"/> for the created <see cref="Thing"/></param>
 /// <param name="chainOfContainers">
 /// The optional chain of containers that contains the <paramref name="container"/> argument
 /// </param>
 public PersonRoleDialogViewModel(PersonRole personRole, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers = null)
     : base(personRole, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers)
 {
 }
Ejemplo n.º 12
0
        public void SetUp()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.permissionService            = new Mock <IPermissionService>();
            this.session = new Mock <ISession>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);

            this.personRole = new PersonRole(Guid.NewGuid(), this.cache, this.uri)
            {
                Name      = "Admimistrator",
                ShortName = "Admin"
            };
            this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "site directory"
            };
            this.person = new Person(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "test",
                Role      = this.personRole
            };
            this.siteDir.Person.Add(this.person);

            this.systemEngineering = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "SYS",
                Name      = "System"
            };
            this.powerEngineering = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "PWR",
                Name      = "Power"
            };

            this.participantRole = new ParticipantRole(Guid.NewGuid(), this.cache, this.uri)
            {
                ShortName = "DomainExpert",
                Name      = "Domain Expert"
            };

            this.engineeringModelSetup           = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.engineeringModelSetup.ShortName = "testmodel";
            this.engineeringModelSetup.Name      = "test model";

            this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri)
            {
                Person = this.person,
                Role   = this.participantRole
            };
            this.participant.Domain.Add(this.systemEngineering);
            this.participant.Domain.Add(this.powerEngineering);

            this.engineeringModelSetup.Participant.Add(this.participant);

            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString());
            this.session.Setup(x => x.ActivePerson).Returns(this.person);

            this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);

            this.cache.TryAdd(new CacheKey(this.siteDir.Iid, null), new Lazy <Thing>(() => this.siteDir));
        }
Ejemplo n.º 13
0
    protected void ButtonAddRole_Click(object sender, EventArgs e)
    {
        int personId      = (Person.FromIdentity(Convert.ToInt32("" + Request["id"]))).Identity;
        int currentUserId = Convert.ToInt32(HttpContext.Current.User.Identity.Name);

        RoleType roleType       = (RoleType)Enum.Parse(typeof(RoleType), DropRolesLocal.SelectedValue);
        int      nodeId         = Convert.ToInt32(DropGeographies.SelectedValue);
        int      organizationId = Convert.ToInt32(DropOrganizationsLocal.SelectedValue);

        if (!_authority.HasPermission(Permission.CanEditLocalRoles, organizationId, nodeId, Authorization.Flag.Default))
        {
            Page.ClientScript.RegisterStartupScript(typeof(Page), "ErrorMessage",
                                                    "alert ('You do not have permissions to add local roles for that combination of organisation and geography.');",
                                                    true);
            return;
        }

        /* Fix for Ticket #46 */

        // Check if role being added is lead, if so check if lead is already filled, if so return error, else continue
        if (roleType == RoleType.LocalLead)
        {
            List <Person> aggregate = new List <Person>();
            RoleLookup    lead      = RoleLookup.FromGeographyAndOrganization(nodeId, organizationId);
            foreach (PersonRole role in lead[RoleType.LocalLead])
            {
                aggregate.Add(role.Person);
            }

            // If we have one or more people in this role already, throw error (typically it should only be filled by one other person)
            if (aggregate.Count > 0)
            {
                string name = aggregate[0].Name;

                // Handle multiple users with this role
                if (aggregate.Count > 1)
                {
                    name = String.Empty;
                    int count = 0;
                    foreach (Person person in aggregate)
                    {
                        count++;
                        name += person.Name;
                        if (count < aggregate.Count)
                        {
                            name += ", ";
                        }
                    }
                }

                Page.ClientScript.RegisterStartupScript(typeof(Page), "ErrorMessage",
                                                        "alert ('This role is already filled by " + name + ". To assign a new user to this role please remove the old user first.');",
                                                        true);

                return;
            }
        }

        int roleId = PersonRole.Create(personId, roleType, organizationId, nodeId).Identity;

        // If we made it this far, add the role
        Activizr.Logic.Support.PWEvents.CreateEvent(EventSource.PirateWeb, EventType.AddedRole, currentUserId, organizationId,
                                                    nodeId, personId, (int)roleType, string.Empty);

        this.GridLocalRoles.DataBind();
    }
 /// <summary>
 /// Add an Person Role row view model to the list of <see cref="PersonRole"/>
 /// </summary>
 /// <param name="personRole">
 /// The <see cref="PersonRole"/> that is to be added
 /// </param>
 private PersonRoleRowViewModel AddPersonRoleRowViewModel(PersonRole personRole)
 {
     return(new PersonRoleRowViewModel(personRole, this.Session, this));
 }
 //SetSession is applying  the session  u choose is  GetCurrentSession
 public void SetSession(PersonRole role)
 {
     Role            = role;
     IsBoss          = role == PersonRole.Boss;
     IsAuthenticated = true;
 }
        //[ValidateAntiForgeryToken]
        public ActionResult _CreatePost(PersonViewModel PersonVm)
        {
            if (ModelState.IsValid)
            {
                if (PersonVm.PersonID == 0)
                {
                    Person         person         = Mapper.Map <PersonViewModel, Person>(PersonVm);
                    BusinessEntity businessentity = Mapper.Map <PersonViewModel, BusinessEntity>(PersonVm);
                    PersonAddress  personaddress  = Mapper.Map <PersonViewModel, PersonAddress>(PersonVm);
                    LedgerAccount  account        = Mapper.Map <PersonViewModel, LedgerAccount>(PersonVm);

                    person.IsActive     = true;
                    person.CreatedDate  = DateTime.Now;
                    person.ModifiedDate = DateTime.Now;
                    person.CreatedBy    = User.Identity.Name;
                    person.ModifiedBy   = User.Identity.Name;
                    person.ObjectState  = Model.ObjectState.Added;
                    new PersonService(_unitOfWork).Create(person);


                    int CurrentDivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];
                    int CurrentSiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];

                    string Divisions = PersonVm.DivisionIds;
                    if (Divisions != null)
                    {
                        Divisions = "|" + Divisions.Replace(",", "|,|") + "|";
                    }
                    else
                    {
                        Divisions = "|" + CurrentDivisionId.ToString() + "|";
                    }

                    businessentity.DivisionIds = Divisions;

                    string Sites = PersonVm.SiteIds;
                    if (Sites != null)
                    {
                        Sites = "|" + Sites.Replace(",", "|,|") + "|";
                    }
                    else
                    {
                        Sites = "|" + CurrentSiteId.ToString() + "|";
                    }

                    businessentity.SiteIds = Sites;


                    new  BusinessEntityService(_unitOfWork).Create(businessentity);

                    personaddress.AddressType  = null;
                    personaddress.CreatedDate  = DateTime.Now;
                    personaddress.ModifiedDate = DateTime.Now;
                    personaddress.CreatedBy    = User.Identity.Name;
                    personaddress.ModifiedBy   = User.Identity.Name;
                    personaddress.ObjectState  = Model.ObjectState.Added;
                    new PersonAddressService(_unitOfWork).Create(personaddress);


                    account.LedgerAccountId      = db.LedgerAccount.Max(i => i.LedgerAccountId) + 1;
                    account.LedgerAccountName    = person.Name;
                    account.LedgerAccountSuffix  = person.Suffix;
                    account.LedgerAccountGroupId = PersonVm.LedgerAccountGroupId;
                    account.IsActive             = true;
                    account.CreatedDate          = DateTime.Now;
                    account.ModifiedDate         = DateTime.Now;
                    account.CreatedBy            = User.Identity.Name;
                    account.ModifiedBy           = User.Identity.Name;
                    account.ObjectState          = Model.ObjectState.Added;
                    new LedgerAccountService(_unitOfWork).Create(account);


                    if (PersonVm.CstNo != "" && PersonVm.CstNo != null)
                    {
                        PersonRegistration personregistration = new PersonRegistration();
                        personregistration.RegistrationType = PersonRegistrationType.CstNo;
                        personregistration.RegistrationNo   = PersonVm.CstNo;
                        personregistration.CreatedDate      = DateTime.Now;
                        personregistration.ModifiedDate     = DateTime.Now;
                        personregistration.CreatedBy        = User.Identity.Name;
                        personregistration.ModifiedBy       = User.Identity.Name;
                        personregistration.ObjectState      = Model.ObjectState.Added;
                        new PersonRegistrationService(_unitOfWork).Create(personregistration);
                    }

                    if (PersonVm.TinNo != "" && PersonVm.TinNo != null)
                    {
                        PersonRegistration personregistration = new PersonRegistration();
                        personregistration.RegistrationType = PersonRegistrationType.TinNo;
                        personregistration.RegistrationNo   = PersonVm.TinNo;
                        personregistration.CreatedDate      = DateTime.Now;
                        personregistration.ModifiedDate     = DateTime.Now;
                        personregistration.CreatedBy        = User.Identity.Name;
                        personregistration.ModifiedBy       = User.Identity.Name;
                        personregistration.ObjectState      = Model.ObjectState.Added;
                        new PersonRegistrationService(_unitOfWork).Create(personregistration);
                    }

                    if (PersonVm.PanNo != "" && PersonVm.PanNo != null)
                    {
                        PersonRegistration personregistration = new PersonRegistration();
                        personregistration.RegistrationType = PersonRegistrationType.PANNo;
                        personregistration.RegistrationNo   = PersonVm.PanNo;
                        personregistration.CreatedDate      = DateTime.Now;
                        personregistration.ModifiedDate     = DateTime.Now;
                        personregistration.CreatedBy        = User.Identity.Name;
                        personregistration.ModifiedBy       = User.Identity.Name;
                        personregistration.ObjectState      = Model.ObjectState.Added;
                        new PersonRegistrationService(_unitOfWork).Create(personregistration);
                    }


                    if (PersonVm.GstNo != "" && PersonVm.GstNo != null)
                    {
                        PersonRegistration personregistration = new PersonRegistration();
                        personregistration.RegistrationType = PersonRegistrationType.GstNo;
                        personregistration.RegistrationNo   = PersonVm.GstNo;
                        personregistration.CreatedDate      = DateTime.Now;
                        personregistration.ModifiedDate     = DateTime.Now;
                        personregistration.CreatedBy        = User.Identity.Name;
                        personregistration.ModifiedBy       = User.Identity.Name;
                        personregistration.ObjectState      = Model.ObjectState.Added;
                        new PersonRegistrationService(_unitOfWork).Create(personregistration);
                    }


                    if (PersonVm.AadharNo != "" && PersonVm.AadharNo != null)
                    {
                        PersonRegistration personregistration = new PersonRegistration();
                        personregistration.RegistrationType = PersonRegistrationType.AadharNo;
                        personregistration.RegistrationNo   = PersonVm.AadharNo;
                        personregistration.CreatedDate      = DateTime.Now;
                        personregistration.ModifiedDate     = DateTime.Now;
                        personregistration.CreatedBy        = User.Identity.Name;
                        personregistration.ModifiedBy       = User.Identity.Name;
                        personregistration.ObjectState      = Model.ObjectState.Added;
                        new PersonRegistrationService(_unitOfWork).Create(personregistration);
                    }


                    PersonRole personrole = new PersonRole();
                    personrole.PersonRoleId  = -1;
                    personrole.PersonId      = person.PersonID;
                    personrole.RoleDocTypeId = person.DocTypeId;
                    personrole.CreatedDate   = DateTime.Now;
                    personrole.ModifiedDate  = DateTime.Now;
                    personrole.CreatedBy     = User.Identity.Name;
                    personrole.ModifiedBy    = User.Identity.Name;
                    personrole.ObjectState   = Model.ObjectState.Added;
                    new PersonRoleService(_unitOfWork).Create(personrole);

                    int ProspectDocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.Prospect).DocumentTypeId;
                    if (person.DocTypeId == ProspectDocTypeId)
                    {
                        int CustomerDocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.Customer).DocumentTypeId;

                        PersonRole personrole1 = new PersonRole();
                        personrole.PersonRoleId   = -2;
                        personrole1.PersonId      = person.PersonID;
                        personrole1.RoleDocTypeId = CustomerDocTypeId;
                        personrole1.CreatedDate   = DateTime.Now;
                        personrole1.ModifiedDate  = DateTime.Now;
                        personrole1.CreatedBy     = User.Identity.Name;
                        personrole1.ModifiedBy    = User.Identity.Name;
                        personrole1.ObjectState   = Model.ObjectState.Added;
                        new PersonRoleService(_unitOfWork).Create(personrole1);
                    }


                    int ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Sales).ProcessId;

                    PersonProcess personprocess = new PersonProcess();
                    personprocess.PersonId     = person.PersonID;
                    personprocess.ProcessId    = ProcessId;
                    personprocess.CreatedDate  = DateTime.Now;
                    personprocess.ModifiedDate = DateTime.Now;
                    personprocess.CreatedBy    = User.Identity.Name;
                    personprocess.ModifiedBy   = User.Identity.Name;
                    personprocess.ObjectState  = Model.ObjectState.Added;
                    new PersonProcessService(_unitOfWork).Create(personprocess);


                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View(PersonVm));
                    }

                    return(Json(new { success = true, PersonId = person.PersonID, Name = person.Name + ", " + person.Suffix + " [" + person.Code + "]" }));
                }
                else
                {
                    //string tempredirect = (Request["Redirect"].ToString());
                    Person             person         = Mapper.Map <PersonViewModel, Person>(PersonVm);
                    BusinessEntity     businessentity = Mapper.Map <PersonViewModel, BusinessEntity>(PersonVm);
                    PersonAddress      personaddress  = new PersonAddressService(_unitOfWork).Find(PersonVm.PersonAddressID);
                    LedgerAccount      account        = new LedgerAccountService(_unitOfWork).Find(PersonVm.AccountId);
                    PersonRegistration PersonCst      = new PersonRegistrationService(_unitOfWork).Find(PersonVm.PersonRegistrationCstNoID ?? 0);
                    PersonRegistration PersonTin      = new PersonRegistrationService(_unitOfWork).Find(PersonVm.PersonRegistrationTinNoID ?? 0);
                    PersonRegistration PersonPAN      = new PersonRegistrationService(_unitOfWork).Find(PersonVm.PersonRegistrationPanNoID ?? 0);
                    PersonRegistration PersonGst      = new PersonRegistrationService(_unitOfWork).Find(PersonVm.PersonRegistrationGstNoID ?? 0);
                    PersonRegistration PersonAadhar   = new PersonRegistrationService(_unitOfWork).Find(PersonVm.PersonRegistrationAadharNoID ?? 0);



                    person.IsActive     = true;
                    person.ModifiedDate = DateTime.Now;
                    person.ModifiedBy   = User.Identity.Name;
                    new PersonService(_unitOfWork).Update(person);


                    new BusinessEntityService(_unitOfWork).Update(businessentity);

                    personaddress.Address      = PersonVm.Address;
                    personaddress.CityId       = PersonVm.CityId;
                    personaddress.Zipcode      = PersonVm.Zipcode;
                    personaddress.ModifiedDate = DateTime.Now;
                    personaddress.ModifiedBy   = User.Identity.Name;
                    personaddress.ObjectState  = Model.ObjectState.Modified;
                    new PersonAddressService(_unitOfWork).Update(personaddress);


                    account.LedgerAccountName   = person.Name;
                    account.LedgerAccountSuffix = person.Suffix;
                    account.ModifiedDate        = DateTime.Now;
                    account.ModifiedBy          = User.Identity.Name;
                    new LedgerAccountService(_unitOfWork).Update(account);

                    if (PersonVm.CstNo != null && PersonVm.CstNo != "")
                    {
                        if (PersonCst != null)
                        {
                            PersonCst.RegistrationNo = PersonVm.CstNo;
                            new PersonRegistrationService(_unitOfWork).Update(PersonCst);
                        }
                        else
                        {
                            PersonRegistration personregistration = new PersonRegistration();
                            personregistration.PersonId         = PersonVm.PersonID;
                            personregistration.RegistrationType = PersonRegistrationType.CstNo;
                            personregistration.RegistrationNo   = PersonVm.CstNo;
                            personregistration.CreatedDate      = DateTime.Now;
                            personregistration.ModifiedDate     = DateTime.Now;
                            personregistration.CreatedBy        = User.Identity.Name;
                            personregistration.ModifiedBy       = User.Identity.Name;
                            personregistration.ObjectState      = Model.ObjectState.Added;
                            new PersonRegistrationService(_unitOfWork).Create(personregistration);
                        }
                    }

                    if (PersonVm.TinNo != null && PersonVm.TinNo != "")
                    {
                        if (PersonTin != null)
                        {
                            PersonTin.RegistrationNo = PersonVm.TinNo;
                            new PersonRegistrationService(_unitOfWork).Update(PersonTin);
                        }
                        else
                        {
                            PersonRegistration personregistration = new PersonRegistration();
                            personregistration.PersonId         = PersonVm.PersonID;
                            personregistration.RegistrationType = PersonRegistrationType.TinNo;
                            personregistration.RegistrationNo   = PersonVm.TinNo;
                            personregistration.CreatedDate      = DateTime.Now;
                            personregistration.ModifiedDate     = DateTime.Now;
                            personregistration.CreatedBy        = User.Identity.Name;
                            personregistration.ModifiedBy       = User.Identity.Name;
                            personregistration.ObjectState      = Model.ObjectState.Added;
                            new PersonRegistrationService(_unitOfWork).Create(personregistration);
                        }
                    }

                    if (PersonVm.PanNo != null && PersonVm.PanNo != "")
                    {
                        if (PersonPAN != null)
                        {
                            PersonPAN.RegistrationNo = PersonVm.PanNo;
                            new PersonRegistrationService(_unitOfWork).Update(PersonPAN);
                        }
                        else
                        {
                            PersonRegistration personregistration = new PersonRegistration();
                            personregistration.PersonId         = PersonVm.PersonID;
                            personregistration.RegistrationType = PersonRegistrationType.PANNo;
                            personregistration.RegistrationNo   = PersonVm.PanNo;
                            personregistration.CreatedDate      = DateTime.Now;
                            personregistration.ModifiedDate     = DateTime.Now;
                            personregistration.CreatedBy        = User.Identity.Name;
                            personregistration.ModifiedBy       = User.Identity.Name;
                            personregistration.ObjectState      = Model.ObjectState.Added;
                            new PersonRegistrationService(_unitOfWork).Create(personregistration);
                        }
                    }

                    if (PersonVm.GstNo != null && PersonVm.GstNo != "")
                    {
                        if (PersonGst != null)
                        {
                            PersonGst.RegistrationNo = PersonVm.GstNo;
                            new PersonRegistrationService(_unitOfWork).Update(PersonGst);
                        }
                        else
                        {
                            PersonRegistration personregistration = new PersonRegistration();
                            personregistration.PersonId         = PersonVm.PersonID;
                            personregistration.RegistrationType = PersonRegistrationType.GstNo;
                            personregistration.RegistrationNo   = PersonVm.GstNo;
                            personregistration.CreatedDate      = DateTime.Now;
                            personregistration.ModifiedDate     = DateTime.Now;
                            personregistration.CreatedBy        = User.Identity.Name;
                            personregistration.ModifiedBy       = User.Identity.Name;
                            personregistration.ObjectState      = Model.ObjectState.Added;
                            new PersonRegistrationService(_unitOfWork).Create(personregistration);
                        }
                    }

                    if (PersonVm.AadharNo != null && PersonVm.AadharNo != "")
                    {
                        if (PersonAadhar != null)
                        {
                            PersonAadhar.RegistrationNo = PersonVm.AadharNo;
                            new PersonRegistrationService(_unitOfWork).Update(PersonAadhar);
                        }
                        else
                        {
                            PersonRegistration personregistration = new PersonRegistration();
                            personregistration.PersonId         = PersonVm.PersonID;
                            personregistration.RegistrationType = PersonRegistrationType.AadharNo;
                            personregistration.RegistrationNo   = PersonVm.AadharNo;
                            personregistration.CreatedDate      = DateTime.Now;
                            personregistration.ModifiedDate     = DateTime.Now;
                            personregistration.CreatedBy        = User.Identity.Name;
                            personregistration.ModifiedBy       = User.Identity.Name;
                            personregistration.ObjectState      = Model.ObjectState.Added;
                            new PersonRegistrationService(_unitOfWork).Create(personregistration);
                        }
                    }


                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", PersonVm));
                    }

                    return(Json(new { success = true, PersonId = person.PersonID, Name = person.Name + ", " + person.Suffix + " [" + person.Code + "]" }));
                }
            }
            return(View(PersonVm));
        }
Ejemplo n.º 17
0
        private void FillRelations(IEnumerable <Person> persons)
        {
            if (Guard.IsEmptyIEnumerable(persons))
            {
                return;
            }

            IEnumerable <Team>         teams         = new Team[0];
            IEnumerable <City>         cities        = new City[0];
            IEnumerable <PersonRole>   personRoles   = new PersonRole[0];
            IEnumerable <PersonCareer> personCareers = new PersonCareer[0];

            if (FillTeams)
            {
                var teamDal = new TeamDal();
                teamDal.FillCities = true;
                teamDal.SetContext(Context);

                var teamIds = new List <int>();
                teamIds.AddRange(persons.Where(p => p.teamId.HasValue).Select(p => p.teamId.Value).Distinct());

                teams = teamDal.GetTeams(teamIds).ToList();
            }

            if (FillCities)
            {
                var cityDal = new CityDal();
                cityDal.FillCountries = true;
                cityDal.SetContext(Context);

                var cityIds = new List <int>();
                cityIds.AddRange(persons.Where(p => p.cityId.HasValue).Select(p => p.cityId.Value).Distinct());

                cities = cityDal.GetCities(cityIds).ToList();
            }

            if (FillPersonRoles)
            {
                var personRoleDal = new PersonRoleDal();
                personRoleDal.SetContext(Context);

                var personRoleIds = new List <int>();
                personRoleIds.AddRange(persons.Where(p => p.roleId.HasValue).Select(p => (int)p.roleId.Value).Distinct());

                personRoles = personRoleDal.GetPersonRoles(personRoleIds).ToList();
            }

            if (FillPersonCareer)
            {
                var personCareerDal = new PersonCareerDal();
                personCareerDal.SetContext(Context);

                var personIds = new List <int>();
                personIds.AddRange(persons.Select(p => p.Id).Distinct());

                personCareers = personCareerDal.GetPersonCareer(personIds).ToList();
            }

            if (teams.Any() || cities.Any() || personRoles.Any() || personCareers.Any())
            {
                foreach (Person person in persons)
                {
                    if (FillTeams && teams.Any())
                    {
                        person.team = teams.FirstOrDefault(t => t.Id == person.teamId);
                        if (person.teamId.HasValue && person.team == null)
                        {
                            throw new DalMappingException(nameof(person.team), typeof(Person));
                        }
                    }

                    if (FillCities && cities.Any())
                    {
                        person.city = cities.FirstOrDefault(c => c.Id == person.cityId);
                        if (person.cityId.HasValue && person.city == null)
                        {
                            throw new DalMappingException(nameof(person.city), typeof(Person));
                        }
                    }

                    if (FillPersonRoles && personRoles.Any())
                    {
                        person.role = personRoles.FirstOrDefault(pr => pr.Id == person.roleId);
                        if (person.roleId.HasValue && person.role == null)
                        {
                            throw new DalMappingException(nameof(person.role), typeof(Person));
                        }
                    }

                    if (FillPersonCareer && personCareers.Any())
                    {
                        person.PersonCareer = personCareers.Where(pc => pc.personId == person.Id).ToList();
                    }
                }
            }
        }
        public async Task Included_Resources_Are_Correct()
        {
            // Arrange
            var role     = new PersonRole();
            var assignee = new Person {
                Role = role
            };
            var collectionOwner = new Person();
            var someOtherOwner  = new Person();
            var collection      = new TodoItemCollection {
                Owner = collectionOwner
            };
            var todoItem1 = new TodoItem {
                Collection = collection, Assignee = assignee
            };
            var todoItem2 = new TodoItem {
                Collection = collection, Assignee = assignee
            };
            var todoItem3 = new TodoItem {
                Collection = collection, Owner = someOtherOwner
            };
            var todoItem4 = new TodoItem {
                Collection = collection, Owner = assignee
            };

            var context = _fixture.GetService <AppDbContext>();

            ResetContext(context);

            context.TodoItems.Add(todoItem1);
            context.TodoItems.Add(todoItem2);
            context.TodoItems.Add(todoItem3);
            context.TodoItems.Add(todoItem4);
            context.PersonRoles.Add(role);
            context.People.Add(assignee);
            context.People.Add(collectionOwner);
            context.People.Add(someOtherOwner);
            context.TodoItemCollections.Add(collection);


            await context.SaveChangesAsync();

            string route =
                "/api/v1/todoItems/" + todoItem1.Id + "?include=" +
                "collection.owner," +
                "assignee.role," +
                "assignee.assignedTodoItems";

            // Act
            var response = await _fixture.Client.GetAsync(route);

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var body = await response.Content.ReadAsStringAsync();

            var documents = JsonConvert.DeserializeObject <Document>(body);
            var included  = documents.Included;

            // 1 collection, 1 owner,
            // 1 assignee, 1 assignee role,
            // 2 assigned todo items (including the primary resource)
            Assert.Equal(6, included.Count);

            var collectionDocument = included.FindResource("todoCollections", collection.Id);
            var ownerDocument      = included.FindResource("people", collectionOwner.Id);
            var assigneeDocument   = included.FindResource("people", assignee.Id);
            var roleDocument       = included.FindResource("personRoles", role.Id);
            var assignedTodo1      = included.FindResource("todoItems", todoItem1.Id);
            var assignedTodo2      = included.FindResource("todoItems", todoItem2.Id);

            Assert.NotNull(assignedTodo1);
            Assert.Equal(todoItem1.Id.ToString(), assignedTodo1.Id);

            Assert.NotNull(assignedTodo2);
            Assert.Equal(todoItem2.Id.ToString(), assignedTodo2.Id);

            Assert.NotNull(collectionDocument);
            Assert.Equal(collection.Id.ToString(), collectionDocument.Id);

            Assert.NotNull(ownerDocument);
            Assert.Equal(collectionOwner.Id.ToString(), ownerDocument.Id);

            Assert.NotNull(assigneeDocument);
            Assert.Equal(assignee.Id.ToString(), assigneeDocument.Id);

            Assert.NotNull(roleDocument);
            Assert.Equal(role.Id.ToString(), roleDocument.Id);
        }
Ejemplo n.º 19
0
        public void SetUp()
        {
            this.siteDirectory = new SiteDirectory(Guid.NewGuid(), null, null);

            var domain1 = new DomainOfExpertise(Guid.NewGuid(), null, null);

            this.siteDirectory.Domain.Add(domain1);
            var domain2 = new DomainOfExpertise(Guid.NewGuid(), null, null);

            this.siteDirectory.Domain.Add(domain2);

            var alias = new Alias(Guid.NewGuid(), null, null);

            domain1.Alias.Add(alias);

            var domainGroup1 = new DomainOfExpertiseGroup(Guid.NewGuid(), null, null);

            this.siteDirectory.DomainGroup.Add(domainGroup1);
            var domainGroup2 = new DomainOfExpertiseGroup(Guid.NewGuid(), null, null);

            this.siteDirectory.DomainGroup.Add(domainGroup2);

            var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), null, null);

            this.siteDirectory.Model.Add(engineeringModelSetup);
            var iterationSetup = new IterationSetup(Guid.NewGuid(), null, null);

            engineeringModelSetup.IterationSetup.Add(iterationSetup);

            var naturalLanguage1 = new NaturalLanguage(Guid.NewGuid(), null, null);

            this.siteDirectory.NaturalLanguage.Add(naturalLanguage1);
            var naturalLanguage2 = new NaturalLanguage(Guid.NewGuid(), null, null);

            this.siteDirectory.NaturalLanguage.Add(naturalLanguage2);

            var organization1 = new Organization(Guid.NewGuid(), null, null);

            this.siteDirectory.Organization.Add(organization1);
            var organization2 = new Organization(Guid.NewGuid(), null, null);

            this.siteDirectory.Organization.Add(organization2);

            var participantRole1 = new ParticipantRole(Guid.NewGuid(), null, null);

            this.siteDirectory.ParticipantRole.Add(participantRole1);
            var participantRole2 = new ParticipantRole(Guid.NewGuid(), null, null);

            this.siteDirectory.ParticipantRole.Add(participantRole2);

            this.person1 = new Person(Guid.NewGuid(), null, null);
            this.siteDirectory.Person.Add(this.person1);
            this.person2 = new Person(Guid.NewGuid(), null, null);
            this.siteDirectory.Person.Add(this.person2);

            var personRole1 = new PersonRole(Guid.NewGuid(), null, null);

            this.siteDirectory.PersonRole.Add(personRole1);
            var personRole2 = new PersonRole(Guid.NewGuid(), null, null);

            this.siteDirectory.PersonRole.Add(personRole2);

            var siteReferenceDataLibrary1 = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null);

            this.siteDirectory.SiteReferenceDataLibrary.Add(siteReferenceDataLibrary1);
            var siteReferenceDataLibrary2 = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null);

            this.siteDirectory.SiteReferenceDataLibrary.Add(siteReferenceDataLibrary2);

            this.engineeringModel = new EngineeringModel(Guid.NewGuid(), null, null);
            this.engineeringModel.EngineeringModelSetup = engineeringModelSetup;
            engineeringModelSetup.EngineeringModelIid   = this.engineeringModel.Iid;

            this.iteration = new Iteration(Guid.NewGuid(), null, null);
            this.iteration.IterationSetup = iterationSetup;
            iterationSetup.IterationIid   = this.iteration.Iid;

            this.engineeringModel.Iteration.Add(this.iteration);

            var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), null, null);

            modelReferenceDataLibrary.RequiredRdl = siteReferenceDataLibrary1;

            engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary);

            var participant = new Participant(Guid.NewGuid(), null, null);

            participant.Person = this.person1;
            participant.Domain.Add(domain1);
            participant.Role = participantRole1;

            engineeringModelSetup.Participant.Add(participant);

            var elementDefinition1 = new ElementDefinition(Guid.NewGuid(), null, null);

            this.iteration.Element.Add(elementDefinition1);
            var elementDefinition2 = new ElementDefinition(Guid.NewGuid(), null, null);

            this.iteration.Element.Add(elementDefinition2);

            var elementUsage = new ElementUsage(Guid.NewGuid(), null, null);

            elementDefinition1.ContainedElement.Add(elementUsage);
            elementUsage.ElementDefinition = elementDefinition2;
        }
Ejemplo n.º 20
0
        // This should run daily, suggested right after midnight.

        public static void ChurnExpiredMembers()
        {
            Organizations organizations = Organizations.GetAll();

            foreach (Organization organization in organizations)
            {
                Memberships memberships = Memberships.GetExpired(organization);
                // Mail each expiring member

                foreach (Membership membership in memberships)
                {
                    //only remove expired memberships
                    if (membership.Expires > DateTime.Now.Date)
                    {
                        continue;
                    }

                    Person person = membership.Person;

                    // Remove all roles and responsibilities for this person in the org

                    Authority authority = person.GetAuthority();

                    foreach (BasicPersonRole basicRole in authority.LocalPersonRoles)
                    {
                        PersonRole personRole = PersonRole.FromBasic(basicRole);
                        if (personRole.OrganizationId == membership.OrganizationId)
                        {
                            PWEvents.CreateEvent(EventSource.PirateBot, EventType.DeletedRole, person.Identity,
                                                 personRole.OrganizationId, personRole.GeographyId, person.Identity,
                                                 (int)personRole.Type,
                                                 string.Empty);
                            personRole.Delete();
                        }
                    }

                    // Mail

                    Memberships personMemberships   = person.GetMemberships();
                    Memberships membershipsToDelete = new Memberships();
                    foreach (Membership personMembership in personMemberships)
                    {
                        if (personMembership.Expires <= DateTime.Now.Date)
                        {
                            membershipsToDelete.Add(personMembership);
                        }
                    }


                    ExpiredMail expiredmail    = new ExpiredMail();
                    string      membershipsIds = "";

                    if (membershipsToDelete.Count > 1)
                    {
                        foreach (Membership personMembership in membershipsToDelete)
                        {
                            membershipsIds += "," + personMembership.MembershipId;
                        }
                        membershipsIds = membershipsIds.Substring(1);
                        string expiredMemberships = "";
                        foreach (Membership personMembership in membershipsToDelete)
                        {
                            if (personMembership.OrganizationId != organization.Identity)
                            {
                                expiredMemberships += ", " + personMembership.Organization.Name;
                            }
                        }
                        expiredMemberships      += ".  ";
                        expiredmail.pMemberships = expiredMemberships.Substring(2).Trim();
                    }

                    //TODO: URL for renewal, recieving end of this is NOT yet implemented...
                    // intended to recreate the memberships in MID
                    string tokenBase = person.PasswordHash + "-" + membership.Expires.Year;
                    string stdLink   = "https://pirateweb.net/Pages/Public/SE/People/MemberRenew.aspx?MemberId=" +
                                       person.Identity +
                                       "&SecHash=" + SHA1.Hash(tokenBase).Replace(" ", "").Substring(0, 8) +
                                       "&MID=" + membershipsIds;

                    expiredmail.pStdRenewLink = stdLink;
                    expiredmail.pOrgName      = organization.MailPrefixInherited;

                    person.SendNotice(expiredmail, organization.Identity);

                    person.DeleteSubscriptionData();

                    string orgIdString = string.Empty;

                    foreach (Membership personMembership in membershipsToDelete)
                    {
                        if (personMembership.Active)
                        {
                            orgIdString += " " + personMembership.OrganizationId;

                            personMembership.Terminate(EventSource.PirateBot, null, "Member churned in housekeeping.");
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
        private WorkItem ImportWorkItem(ISOTask isoPrescribedTask)
        {
            WorkItem workItem = new WorkItem();

            //Task ID
            ImportIDs(workItem.Id, isoPrescribedTask.TaskID);

            //Grower ID
            workItem.GrowerId = TaskDataMapper.InstanceIDMap.GetADAPTID(isoPrescribedTask.CustomerIdRef);

            //Farm ID
            workItem.FarmId = TaskDataMapper.InstanceIDMap.GetADAPTID(isoPrescribedTask.FarmIdRef);

            //Field/CropZone
            int?pfdID = TaskDataMapper.InstanceIDMap.GetADAPTID(isoPrescribedTask.PartFieldIdRef);

            if (pfdID.HasValue)
            {
                if (DataModel.Catalog.CropZones.Any(c => c.Id.ReferenceId == pfdID.Value))
                {
                    workItem.CropZoneId = pfdID.Value;
                }
                else
                {
                    workItem.FieldId = pfdID.Value;
                    if (DataModel.Catalog.CropZones.Count(c => c.FieldId == pfdID) == 1)
                    {
                        //There is a single cropZone for the field.
                        workItem.CropZoneId = DataModel.Catalog.CropZones.Single(c => c.FieldId == pfdID).Id.ReferenceId;
                    }
                }
            }

            //Status
            workItem.StatusUpdates = new List <StatusUpdate>()
            {
                new StatusUpdate()
                {
                    Status = ImportStatus(isoPrescribedTask.TaskStatus)
                }
            };

            //Responsible Worker
            if (!string.IsNullOrEmpty(isoPrescribedTask.ResponsibleWorkerIdRef))
            {
                ISOWorker worker   = ISOTaskData.ChildElements.OfType <ISOWorker>().FirstOrDefault(w => w.WorkerId == isoPrescribedTask.ResponsibleWorkerIdRef);
                int?      personID = TaskDataMapper.InstanceIDMap.GetADAPTID(isoPrescribedTask.ResponsibleWorkerIdRef);
                if (personID.HasValue)
                {
                    //Create a Role
                    PersonRole role = new PersonRole()
                    {
                        PersonId = personID.Value
                    };

                    //Add to Catalog
                    DataModel.Catalog.PersonRoles.Add(role);
                    if (workItem.PeopleRoleIds == null)
                    {
                        workItem.PeopleRoleIds = new List <int>();
                    }

                    //Add to Task
                    workItem.PeopleRoleIds.Add(role.Id.ReferenceId);
                }
            }

            //Worker Allocation
            if (isoPrescribedTask.WorkerAllocations.Any())
            {
                WorkerAllocationMapper wanMapper   = new WorkerAllocationMapper(TaskDataMapper);
                List <PersonRole>      personRoles = wanMapper.ImportWorkerAllocations(isoPrescribedTask.WorkerAllocations).ToList();

                //Add to Catalog
                DataModel.Catalog.PersonRoles.AddRange(personRoles);

                //Add to Task
                if (workItem.PeopleRoleIds == null)
                {
                    workItem.PeopleRoleIds = new List <int>();
                }
                workItem.PeopleRoleIds.AddRange(personRoles.Select(p => p.Id.ReferenceId));
            }

            if (isoPrescribedTask.GuidanceAllocations.Any())
            {
                GuidanceAllocationMapper  ganMapper   = new GuidanceAllocationMapper(TaskDataMapper);
                List <GuidanceAllocation> allocations = ganMapper.ImportGuidanceAllocations(isoPrescribedTask.GuidanceAllocations).ToList();

                //Add to Catalog
                List <GuidanceAllocation> guidanceAllocations = DataModel.Documents.GuidanceAllocations as List <GuidanceAllocation>;
                if (guidanceAllocations != null)
                {
                    guidanceAllocations.AddRange(allocations);
                }

                //Add to Task
                if (workItem.GuidanceAllocationIds == null)
                {
                    workItem.GuidanceAllocationIds = new List <int>();
                }
                workItem.GuidanceAllocationIds.AddRange(allocations.Select(p => p.Id.ReferenceId));
            }

            //Comments
            if (isoPrescribedTask.CommentAllocations.Any())
            {
                CommentAllocationMapper canMapper = new CommentAllocationMapper(TaskDataMapper);
                workItem.Notes = canMapper.ImportCommentAllocations(isoPrescribedTask.CommentAllocations).ToList();
            }

            //Prescription
            if (isoPrescribedTask.HasPrescription)
            {
                Prescription rx = PrescriptionMapper.ImportPrescription(isoPrescribedTask, workItem);

                if (rx == null)
                {
                    return(workItem);
                }
                //Add to the Prescription the Catalog
                List <Prescription> prescriptions = DataModel.Catalog.Prescriptions as List <Prescription>;
                prescriptions?.Add(rx);

                //Add A WorkItemOperation
                WorkItemOperation operation = new WorkItemOperation();
                operation.PrescriptionId = rx.Id.ReferenceId;

                //Add the operation to the Documents and reference on the WorkItem
                List <WorkItemOperation> operations =
                    DataModel.Documents.WorkItemOperations as List <WorkItemOperation>;
                operations?.Add(operation);

                workItem.WorkItemOperationIds.Add(operation.Id.ReferenceId);

                //Track any prescription IDs to map to any completed TimeLog data
                _rxIDsByTask.Add(isoPrescribedTask.TaskID, rx.Id.ReferenceId);
            }

            return(workItem);
        }
Ejemplo n.º 22
0
 public Person(int id, string name, string surname, double height, DateTime birthdate, DateTime lastAccess, PersonRole role)
 {
     Id         = id;
     Name       = name;
     Surname    = surname;
     Height     = height;
     Birthdate  = birthdate;
     LastAccess = lastAccess;
     Role       = role;
     Age        = (int)((DateTime.Today - birthdate).TotalDays / 365);
 }
Ejemplo n.º 23
0
        public ISOTask ExportPrescription(WorkItem workItem, int gridType, Prescription prescription)
        {
            ISOTask task = new ISOTask();

            //Task ID
            string taskID = workItem.Id.FindIsoId() ?? GenerateId();

            task.TaskID = taskID;
            ExportIDs(workItem.Id, taskID);

            //Designator
            task.TaskDesignator = prescription.Description;

            //Customer Ref
            if (workItem.GrowerId.HasValue)
            {
                task.CustomerIdRef = TaskDataMapper.InstanceIDMap.GetISOID(workItem.GrowerId.Value);
            }

            //Farm Ref
            if (workItem.FarmId.HasValue)
            {
                task.FarmIdRef = TaskDataMapper.InstanceIDMap.GetISOID(workItem.FarmId.Value);
            }

            //Partfield Ref
            if (workItem.CropZoneId.HasValue)
            {
                task.PartFieldIdRef = TaskDataMapper.InstanceIDMap.GetISOID(workItem.CropZoneId.Value);
            }
            else if (workItem.FieldId.HasValue)
            {
                task.PartFieldIdRef = TaskDataMapper.InstanceIDMap.GetISOID(workItem.FieldId.Value);
            }

            //Comments
            if (workItem.Notes.Any())
            {
                CommentAllocationMapper canMapper = new CommentAllocationMapper(TaskDataMapper);
                task.CommentAllocations = canMapper.ExportCommentAllocations(workItem.Notes).ToList();
            }

            //Worker Allocations
            if (workItem.PeopleRoleIds.Any())
            {
                WorkerAllocationMapper workerAllocationMapper = new WorkerAllocationMapper(TaskDataMapper);
                List <PersonRole>      personRoles            = new List <PersonRole>();
                foreach (int id in workItem.PeopleRoleIds)
                {
                    PersonRole personRole = DataModel.Catalog.PersonRoles.FirstOrDefault(p => p.Id.ReferenceId == id);
                    if (personRole != null)
                    {
                        personRoles.Add(personRole);
                    }
                }
                task.WorkerAllocations = workerAllocationMapper.ExportWorkerAllocations(personRoles).ToList();
            }

            //Guidance Allocations
            if (workItem.GuidanceAllocationIds.Any())
            {
                GuidanceAllocationMapper  guidanceAllocationMapper = new GuidanceAllocationMapper(TaskDataMapper);
                List <GuidanceAllocation> allocations = new List <GuidanceAllocation>();
                foreach (int id in workItem.GuidanceAllocationIds)
                {
                    GuidanceAllocation allocation = DataModel.Documents.GuidanceAllocations.FirstOrDefault(p => p.Id.ReferenceId == id);
                    if (allocation != null)
                    {
                        allocations.Add(allocation);
                    }
                }
                task.GuidanceAllocations = guidanceAllocationMapper.ExportGuidanceAllocations(allocations).ToList();
            }

            //Connections
            if (workItem.EquipmentConfigurationGroup != null)
            {
                task.Connections = _connectionMapper.ExportConnections(workItem.Id.ReferenceId, workItem.EquipmentConfigurationGroup.EquipmentConfigurations).ToList();
            }

            //Status
            if (workItem.StatusUpdates == null || workItem.StatusUpdates.Count == 0)
            {
                task.TaskStatus = ISOEnumerations.ISOTaskStatus.Planned;
            }
            else if (workItem.StatusUpdates.Count == 1)
            {
                StatusUpdate lastStatus = workItem.StatusUpdates.OrderByDescending(su => su.TimeStamp).Last();
                task.TaskStatus = ExportStatus(lastStatus.Status);
            }

            //Prescription
            if (prescription is RasterGridPrescription)
            {
                ExportRasterPrescription(task, prescription as RasterGridPrescription, gridType);
            }
            else if (prescription is VectorPrescription)
            {
                ExportVectorPrescription(task, prescription as VectorPrescription);
            }
            else if (prescription is ManualPrescription)
            {
                ExportManualPresciption(task, prescription as ManualPrescription);
            }

            return(task);
        }
Ejemplo n.º 24
0
 public IActionResult UpdateRole([FromBody] PersonRole role)
 {
     _personService.Save(role);
     return(Json(role));
 }
Ejemplo n.º 25
0
        public void SetUp()
        {
            this.serviceLocator = new Mock <IServiceLocator>();
            ServiceLocator.SetLocatorProvider(new ServiceLocatorProvider(() => this.serviceLocator.Object));
            this.serviceLocator.Setup(x => x.GetInstance <IMetaDataProvider>()).Returns(new MetaDataProvider());
            var siteDirectory = new SiteDirectory(Guid.NewGuid(), null, null);

            var domain1 = new DomainOfExpertise(Guid.NewGuid(), null, null);

            siteDirectory.Domain.Add(domain1);
            var domain2 = new DomainOfExpertise(Guid.NewGuid(), null, null);

            siteDirectory.Domain.Add(domain2);

            var alias = new Alias(Guid.NewGuid(), null, null);

            domain1.Alias.Add(alias);

            var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), null, null);

            siteDirectory.Model.Add(engineeringModelSetup);
            var iterationSetup = new IterationSetup(Guid.NewGuid(), null, null);

            engineeringModelSetup.IterationSetup.Add(iterationSetup);

            var participantRole1 = new ParticipantRole(Guid.NewGuid(), null, null);

            siteDirectory.ParticipantRole.Add(participantRole1);
            var participantRole2 = new ParticipantRole(Guid.NewGuid(), null, null);

            siteDirectory.ParticipantRole.Add(participantRole2);

            var person1 = new Person(Guid.NewGuid(), null, null);

            siteDirectory.Person.Add(person1);

            var personRole1 = new PersonRole(Guid.NewGuid(), null, null);

            siteDirectory.PersonRole.Add(personRole1);

            var siteReferenceDataLibrary1 = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null);

            siteDirectory.SiteReferenceDataLibrary.Add(siteReferenceDataLibrary1);

            var engineeringModel = new EngineeringModel(Guid.NewGuid(), null, null);

            engineeringModel.EngineeringModelSetup    = engineeringModelSetup;
            engineeringModelSetup.EngineeringModelIid = engineeringModel.Iid;

            this.iteration = new Iteration(Guid.NewGuid(), null, null);
            this.iteration.IterationSetup = iterationSetup;
            iterationSetup.IterationIid   = this.iteration.Iid;

            engineeringModel.Iteration.Add(this.iteration);

            var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), null, null);

            modelReferenceDataLibrary.RequiredRdl = siteReferenceDataLibrary1;

            engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary);

            var participant = new Participant(Guid.NewGuid(), null, null);

            participant.Person = person1;
            participant.Domain.Add(domain1);
            participant.Role = participantRole1;

            engineeringModelSetup.Participant.Add(participant);

            var elementDefinition1 = new ElementDefinition(Guid.NewGuid(), null, null);

            this.iteration.Element.Add(elementDefinition1);
            var elementDefinition2 = new ElementDefinition(Guid.NewGuid(), null, null);

            this.iteration.Element.Add(elementDefinition2);

            var elementUsage = new ElementUsage(Guid.NewGuid(), null, null);

            elementDefinition1.ContainedElement.Add(elementUsage);
            elementUsage.ElementDefinition = elementDefinition2;
        }
Ejemplo n.º 26
0
        private ISOTask Export(LoggedData loggedData)
        {
            ISOTask task = null;

            //Try to map to a pre-existing Work Item task where appropriate
            if (loggedData.OperationData.All(o => o.PrescriptionId.HasValue) &&
                loggedData.OperationData.Select(o => o.PrescriptionId.Value).Distinct().Count() == 1)
            {
                int rxID = loggedData.OperationData.First().PrescriptionId.Value;
                if (_taskIDsByPrescription.ContainsKey(rxID))
                {
                    task = ISOTaskData.ChildElements.OfType <ISOTask>().FirstOrDefault(t => t.TaskID == _taskIDsByPrescription[rxID]);
                }
            }

            if (task == null)
            {
                task = new ISOTask();

                //Task ID
                string taskID = loggedData.Id.FindIsoId() ?? GenerateId();
                task.TaskID = taskID;
            }


            if (!ExportIDs(loggedData.Id, task.TaskID))
            {
                //Update the mapping to represent the completed task
                TaskDataMapper.InstanceIDMap.ReplaceADAPTID(task.TaskID, loggedData.Id.ReferenceId);
            }

            //Task Designator
            task.TaskDesignator = loggedData.Description;

            //Customer Ref
            if (loggedData.GrowerId.HasValue)
            {
                task.CustomerIdRef = TaskDataMapper.InstanceIDMap.GetISOID(loggedData.GrowerId.Value);
            }

            //Farm Ref
            if (loggedData.FarmId.HasValue)
            {
                task.FarmIdRef = TaskDataMapper.InstanceIDMap.GetISOID(loggedData.FarmId.Value);
            }

            //Partfield Ref
            if (loggedData.CropZoneId.HasValue)
            {
                task.PartFieldIdRef = TaskDataMapper.InstanceIDMap.GetISOID(loggedData.CropZoneId.Value);
            }
            else if (loggedData.FieldId.HasValue)
            {
                task.PartFieldIdRef = TaskDataMapper.InstanceIDMap.GetISOID(loggedData.FieldId.Value);
            }

            //Status
            task.TaskStatus = ISOEnumerations.ISOTaskStatus.Completed;

            if (loggedData.OperationData.Any())
            {
                //Time Logs
                task.TimeLogs = TimeLogMapper.ExportTimeLogs(loggedData.OperationData, TaskDataPath).ToList();

                //Connections
                IEnumerable <int> taskEquipmentConfigIDs = loggedData.OperationData.SelectMany(o => o.EquipmentConfigurationIds);
                if (taskEquipmentConfigIDs.Any())
                {
                    IEnumerable <EquipmentConfiguration> taskEquipmentConfigs = DataModel.Catalog.EquipmentConfigurations.Where(d => taskEquipmentConfigIDs.Contains(d.Id.ReferenceId));
                    task.Connections = ConnectionMapper.ExportConnections(loggedData.Id.ReferenceId, taskEquipmentConfigs).ToList();
                }
            }

            //Summaries
            if (loggedData.SummaryId.HasValue)
            {
                Summary summary = DataModel.Documents.Summaries.FirstOrDefault(s => s.Id.ReferenceId == loggedData.SummaryId.Value);
                if (summary != null)
                {
                    task.Times.AddRange(ExportSummary(summary));
                }

                List <ISOProductAllocation> productAllocations = GetProductAllocationsForSummary(summary);
                if (productAllocations != null)
                {
                    task.ProductAllocations.AddRange(productAllocations);
                }
            }

            //Comments
            if (loggedData.Notes.Any())
            {
                CommentAllocationMapper canMapper = new CommentAllocationMapper(TaskDataMapper);
                task.CommentAllocations = canMapper.ExportCommentAllocations(loggedData.Notes).ToList();
            }

            //Worker Allocations
            if (loggedData.PersonRoleIds.Any())
            {
                WorkerAllocationMapper workerAllocationMapper = new WorkerAllocationMapper(TaskDataMapper);
                List <PersonRole>      personRoles            = new List <PersonRole>();
                foreach (int id in loggedData.PersonRoleIds)
                {
                    PersonRole personRole = DataModel.Catalog.PersonRoles.FirstOrDefault(p => p.Id.ReferenceId == id);
                    if (personRole != null)
                    {
                        personRoles.Add(personRole);
                    }
                }
                task.WorkerAllocations = workerAllocationMapper.ExportWorkerAllocations(personRoles).ToList();
            }

            //Guidance Allocations
            if (loggedData.GuidanceAllocationIds.Any())
            {
                GuidanceAllocationMapper  guidanceAllocationMapper = new GuidanceAllocationMapper(TaskDataMapper);
                List <GuidanceAllocation> allocations = new List <GuidanceAllocation>();
                foreach (int id in loggedData.GuidanceAllocationIds)
                {
                    GuidanceAllocation allocation = DataModel.Documents.GuidanceAllocations.FirstOrDefault(p => p.Id.ReferenceId == id);
                    if (allocation != null)
                    {
                        allocations.Add(allocation);
                    }
                }
                task.GuidanceAllocations = guidanceAllocationMapper.ExportGuidanceAllocations(allocations).ToList();
            }

            return(task);
        }
Ejemplo n.º 27
0
        public void Setup()
        {
            this.assembler = new Assembler(this.uri);
            this.session   = new Mock <ISession>();
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            var dal = new Mock <IDal>();

            dal.Setup(x => x.IsReadOnly).Returns(false);
            this.session.Setup(x => x.Dal).Returns(dal.Object);

            this.sitedir         = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup      = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup  = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.person          = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain1         = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain2         = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.personRole      = new PersonRole(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.participant     = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.participantRole = new ParticipantRole(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.model           = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                IterationSetup = this.iterationSetup
            };
            this.definition   = new Definition(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.srdl         = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.booleanpt    = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.person2      = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.elementDef   = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.relationship = new BinaryRelationship(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.parameter    = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.valueset     = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.requirementsSpecification = new RequirementsSpecification(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.requirement     = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.commonFileStore = new CommonFileStore(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.sitedir.Model.Add(this.modelsetup);
            this.sitedir.Person.Add(this.person);
            this.sitedir.Person.Add(this.person2);
            this.sitedir.PersonRole.Add(this.personRole);
            this.sitedir.Domain.Add(this.domain1);
            this.sitedir.Domain.Add(this.domain2);
            this.modelsetup.IterationSetup.Add(this.iterationSetup);
            this.modelsetup.Participant.Add(this.participant);
            this.sitedir.ParticipantRole.Add(this.participantRole);
            this.model.Iteration.Add(this.iteration);
            this.person.Role        = this.personRole;
            this.participant.Person = this.person;
            this.participant.Role   = this.participantRole;
            this.participant.Domain.Add(this.domain1);
            this.modelsetup.Definition.Add(this.definition);
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.srdl.ParameterType.Add(this.booleanpt);
            this.iteration.Element.Add(this.elementDef);
            this.iteration.Relationship.Add(this.relationship);
            this.elementDef.Parameter.Add(this.parameter);
            this.parameter.ValueSet.Add(this.valueset);

            this.modelsetup.EngineeringModelIid = this.model.Iid;
            this.iterationSetup.IterationIid    = this.iteration.Iid;
            this.elementDef.Owner   = this.domain1;
            this.relationship.Owner = this.domain1;
            this.parameter.Owner    = this.domain1;
            this.requirementsSpecification.Requirement.Add(this.requirement);
            this.iteration.RequirementsSpecification.Add(this.requirementsSpecification);
            this.model.CommonFileStore.Add(this.commonFileStore);

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >
            {
                { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain1, this.participant) }
            });

            this.permissionService = new PermissionService(this.session.Object);
        }
Ejemplo n.º 28
0
        private LoggedData ImportLoggedData(ISOTask isoLoggedTask)
        {
            LoggedData loggedData = new LoggedData();

            loggedData.OperationData = new List <OperationData>();

            //Task ID
            if (!ImportIDs(loggedData.Id, isoLoggedTask.TaskID))
            {
                //In the case where a TSK contains both TZN and TLG data, we'll store the LoggedData as the mapped Task.
                //The Prescription ID will be assigned to the OperationData objects by means of the dictionary in this class.
                TaskDataMapper.InstanceIDMap.ReplaceADAPTID(isoLoggedTask.TaskID, loggedData.Id.ReferenceId);
            }

            //Task Name
            loggedData.Description = isoLoggedTask.TaskDesignator;

            //Grower ID
            loggedData.GrowerId = TaskDataMapper.InstanceIDMap.GetADAPTID(isoLoggedTask.CustomerIdRef);

            //Farm ID
            loggedData.FarmId = TaskDataMapper.InstanceIDMap.GetADAPTID(isoLoggedTask.FarmIdRef);

            //Field ID
            int?pfdID = TaskDataMapper.InstanceIDMap.GetADAPTID(isoLoggedTask.PartFieldIdRef);

            if (pfdID.HasValue)
            {
                if (DataModel.Catalog.CropZones.Any(c => c.Id.ReferenceId == pfdID.Value))
                {
                    loggedData.CropZoneId = pfdID.Value;
                }
                else
                {
                    loggedData.FieldId = pfdID.Value;
                    if (DataModel.Catalog.CropZones.Count(c => c.FieldId == pfdID) == 1)
                    {
                        //There is a single cropZone for the field.
                        loggedData.CropZoneId = DataModel.Catalog.CropZones.Single(c => c.FieldId == pfdID).Id.ReferenceId;
                    }
                }
            }

            //Responsible Worker
            if (!string.IsNullOrEmpty(isoLoggedTask.ResponsibleWorkerIdRef))
            {
                ISOWorker worker   = ISOTaskData.ChildElements.OfType <ISOWorker>().FirstOrDefault(w => w.WorkerId == isoLoggedTask.ResponsibleWorkerIdRef);
                int?      personID = TaskDataMapper.InstanceIDMap.GetADAPTID(isoLoggedTask.ResponsibleWorkerIdRef);
                if (personID.HasValue)
                {
                    //Create a Role
                    PersonRole role = new PersonRole()
                    {
                        PersonId = personID.Value
                    };

                    //Add to Catalog
                    DataModel.Catalog.PersonRoles.Add(role);
                    if (loggedData.PersonRoleIds == null)
                    {
                        loggedData.PersonRoleIds = new List <int>();
                    }

                    //Add to Task
                    loggedData.PersonRoleIds.Add(role.Id.ReferenceId);
                }
            }

            //Worker Allocations
            if (isoLoggedTask.WorkerAllocations.Any())
            {
                WorkerAllocationMapper wanMapper   = new WorkerAllocationMapper(TaskDataMapper);
                List <PersonRole>      personRoles = wanMapper.ImportWorkerAllocations(isoLoggedTask.WorkerAllocations).ToList();

                //Add to Catalog
                DataModel.Catalog.PersonRoles.AddRange(personRoles);
                if (loggedData.PersonRoleIds == null)
                {
                    loggedData.PersonRoleIds = new List <int>();
                }

                //Add to Task
                loggedData.PersonRoleIds.AddRange(personRoles.Select(p => p.Id.ReferenceId));
            }

            //Guidance Allocations
            if (isoLoggedTask.GuidanceAllocations.Any())
            {
                GuidanceAllocationMapper  ganMapper   = new GuidanceAllocationMapper(TaskDataMapper);
                List <GuidanceAllocation> allocations = ganMapper.ImportGuidanceAllocations(isoLoggedTask.GuidanceAllocations).ToList();

                //Add to Catalog
                List <GuidanceAllocation> guidanceAllocations = DataModel.Documents.GuidanceAllocations as List <GuidanceAllocation>;
                if (guidanceAllocations != null)
                {
                    guidanceAllocations.AddRange(allocations);
                }

                //Add to Task
                if (loggedData.GuidanceAllocationIds == null)
                {
                    loggedData.GuidanceAllocationIds = new List <int>();
                }
                loggedData.GuidanceAllocationIds.AddRange(allocations.Select(p => p.Id.ReferenceId));
            }

            //Comments
            if (isoLoggedTask.CommentAllocations.Any())
            {
                CommentAllocationMapper canMapper = new CommentAllocationMapper(TaskDataMapper);
                loggedData.Notes = canMapper.ImportCommentAllocations(isoLoggedTask.CommentAllocations).ToList();
            }

            //Summaries
            if (isoLoggedTask.Times.Any(t => t.HasStart && t.HasType)) //Nothing added without a Start & Type attribute
            {
                //An ADAPT LoggedData has exactly one summary.   This is what necessitates that ISO Task maps to LoggedData and ISO TimeLog maps to one or more Operation Data objects
                Summary summary = ImportSummary(isoLoggedTask, loggedData);
                if (DataModel.Documents.Summaries == null)
                {
                    DataModel.Documents.Summaries = new List <Summary>();
                }
                (DataModel.Documents.Summaries as List <Summary>).Add(summary);
                loggedData.SummaryId = summary.Id.ReferenceId;
            }

            //Operation Data
            if (isoLoggedTask.TimeLogs.Any())
            {
                //Find ID for any Prescription that may also be tied to this task
                int?rxID = null;
                if (_rxIDsByTask.ContainsKey(isoLoggedTask.TaskID))
                {
                    rxID = _rxIDsByTask[isoLoggedTask.TaskID];
                }

                loggedData.OperationData = TimeLogMapper.ImportTimeLogs(isoLoggedTask, rxID);
            }

            //Connections
            if (isoLoggedTask.Connections.Any())
            {
                IEnumerable <EquipmentConfiguration> equipConfigs = ConnectionMapper.ImportConnections(isoLoggedTask);

                loggedData.EquipmentConfigurationGroup = new EquipmentConfigurationGroup();
                loggedData.EquipmentConfigurationGroup.EquipmentConfigurations = equipConfigs.ToList();

                //Make a reference to the IDs on the OperationData
                foreach (OperationData operationData in loggedData.OperationData)
                {
                    operationData.EquipmentConfigurationIds.AddRange(equipConfigs.Select(e => e.Id.ReferenceId));
                }

                DataModel.Catalog.EquipmentConfigurations.AddRange(equipConfigs);
            }

            return(loggedData);
        }
Ejemplo n.º 29
0
 public PersonRole Create(PersonRole pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <PersonRole>().Insert(pt);
     return(pt);
 }
Ejemplo n.º 30
0
 public static PersonRoleDTO Convert(PersonRole role)
 {
     return (PersonRoleDTO)role;
 }
Ejemplo n.º 31
0
 public void Delete(PersonRole pt)
 {
     _unitOfWork.Repository <PersonRole>().Delete(pt);
 }
Ejemplo n.º 32
0
 public async Task<ICollection<T>> AllByType<T>(PersonRole role)
 {
    return await personRepository.AllByType<T>(Convert.ToInt16(role));
 }
Ejemplo n.º 33
0
 public SkydiverBuilder WithRole(PersonRole role)
 {
     Item.Role = role;
     return(MySelf);
 }