public async Task <StaffEducationOrganizationAssignmentAssociation> Update(StaffEducationOrganizationAssignmentAssociation staff)
        {
            _db.StaffEducationOrganizationAssignmentAssociation.Update(staff);
            await _db.SaveChangesAsync();

            if (staff.StaffClassificationDescriptorId == 40789)
            {
                var people = await _db.People.FirstOrDefaultAsync(x => x.Usi == staff.StaffUSI);

                if (people != null)
                {
                    var accessLevel = await _db.AccessLevelDefinition.FirstOrDefaultAsync(m => m.Email == people.ElectronicMailAddress);

                    if (accessLevel == null)
                    {
                        AccessLevelDefinition newAccess = new AccessLevelDefinition()
                        {
                            Email = people.ElectronicMailAddress
                        };
                        _db.AccessLevelDefinition.Add(newAccess);
                        await _db.SaveChangesAsync();
                    }
                }
            }


            return(staff);
        }
        public async Task <StaffEducationOrganizationAssignmentAssociation> Delete(StaffEducationOrganizationAssignmentAssociation staff)
        {
            _db.StaffEducationOrganizationAssignmentAssociation.Remove(staff);
            await _db.SaveChangesAsync();

            return(staff);
        }
            public void Should_not_return_values_from_optional_reference_until_all_of_the_references_properties_have_been_set()
            {
                _model          = new StaffEducationOrganizationAssignmentAssociation();
                _modelInterface = _model;

                // This property is "unified" with other references
                _modelInterface.StaffUniqueId = "ABC123";

                // Because it's shared by multiple references, this property should return its value
                // immediately (it's not **specific** to the optional reference)
                _modelInterface.StaffUniqueId.ShouldBe("ABC123");

                All_optional_reference_properties_should_still_return_null_values();

                // ---------------------------------------------------------
                // These properties are specific to the optional reference
                // ---------------------------------------------------------
                _modelInterface.EmploymentEducationOrganizationId = 123;
                All_optional_reference_properties_should_still_return_null_values();
                Optional_reference_should_still_be_null();

                _modelInterface.EmploymentStatusDescriptor = "XYZ";
                All_optional_reference_properties_should_still_return_null_values();
                Optional_reference_should_still_be_null();

                // After the last property specific to the optional reference is set, they should all return values (reference is complete)
                _modelInterface.EmploymentHireDate = DateTime.Today;
                All_of_the_optional_reference_properties_should_now_return_values();
                Optional_reference_should_NOT_be_null();
            }
 /// <summary>
 /// DEPRECATED. Build UserSessionProfileDTO manually through class properties instead
 /// </summary>
 /// <param name="staff"></param>
 /// <param name="association"></param>
 /// <returns></returns>
 public UserSessionProfile MapUserSessionProfile(StaffDTO staff, StaffEducationOrganizationAssignmentAssociation association)
 {
     return(new UserSessionProfile()
     {
         Staff = staff,
         StaffEducationOrganizationAssignmentAssociation = association,
     });
 }
            protected override void Act()
            {
                // Perform the action to be tested
                _model = new StaffEducationOrganizationAssignmentAssociation();

                // Populate the instance's value, including the shared FK value, but none of the optional reference's values
                _modelInterface = _model;

                // Set only the required "key" properties on the main model
                _modelInterface.StaffUniqueId =
                    "ABC123"; // This also serves as part of the optional reference, but is "unified" (or shared) from other references.

                _modelInterface.EducationOrganizationId       = 123;
                _modelInterface.StaffClassificationDescriptor = "Hello";
                _modelInterface.BeginDate = DateTime.Today;

                // NOTE: No other properties for the optional reference have been set

                _actualSerializedJson = JsonConvert.SerializeObject(_model);
            }
Exemplo n.º 6
0
        /// <summary>
        /// Creates or updates resources based on the natural key values of the supplied resource. The POST operation can be used to create or update resources. In database terms, this is often referred to as an &quot;upsert&quot; operation (insert + update).  Clients should NOT include the resource &quot;id&quot; in the JSON body because it will result in an error (you must use a PUT operation to update a resource by &quot;id&quot;). The web service will identify whether the resource already exists based on the natural key values provided, and update or create the resource appropriately.
        /// </summary>
        /// <param name="body">The JSON representation of the &quot;staffEducationOrganizationAssignmentAssociation&quot; resource to be created or updated.</param>
        /// <returns>A RestSharp <see cref="IRestResponse"/> instance containing the API response details.</returns>
        public IRestResponse PostStaffEducationOrganizationAssignmentAssociations(StaffEducationOrganizationAssignmentAssociation body)
        {
            var request = new RestRequest("/staffEducationOrganizationAssignmentAssociations", Method.POST);

            request.RequestFormat = DataFormat.Json;

            // verify required params are set
            if (body == null)
            {
                throw new ArgumentException("API method call is missing required parameters");
            }
            request.AddBody(body);
            var response = client.Execute(request);

            var location = response.Headers.FirstOrDefault(x => x.Name == "Location");

            if (location != null && !string.IsNullOrWhiteSpace(location.Value.ToString()))
            {
                body.id = location.Value.ToString().Split('/').Last();
            }
            return(response);
        }
        /// <summary>
        /// Updates or creates a resource based on the resource identifier. The PUT operation is used to update or create a resource by identifier.  If the resource doesn't exist, the resource will be created using that identifier.  Additionally, natural key values cannot be changed using this operation, and will not be modified in the database.  If the resource &quot;id&quot; is provided in the JSON body, it will be ignored as well.
        /// </summary>
        /// <param name="id">A resource identifier specifying the resource to be updated.</param>
        /// <param name="IfMatch">The ETag header value used to prevent the PUT from updating a resource modified by another consumer.</param>
        /// <param name="body">The JSON representation of the &quot;staffEducationOrganizationAssignmentAssociation&quot; resource to be updated.</param>
        /// <returns>A RestSharp <see cref="IRestResponse"/> instance containing the API response details.</returns>
        public IRestResponse PutStaffEducationOrganizationAssignmentAssociation(string id, string IfMatch, StaffEducationOrganizationAssignmentAssociation body)
        {
            var request = new RestRequest("/staffEducationOrganizationAssignmentAssociations/{id}", Method.PUT);

            request.RequestFormat = DataFormat.Json;

            request.AddUrlSegment("id", id);
            // verify required params are set
            if (id == null || body == null)
            {
                throw new ArgumentException("API method call is missing required parameters");
            }
            request.AddHeader("If-Match", IfMatch);
            request.AddBody(body);
            request.Parameters.First(param => param.Type == ParameterType.RequestBody).Name = "application/json";
            var response = client.Execute(request);

            var location = response.Headers.FirstOrDefault(x => x.Name == "Location");

            if (location != null && !string.IsNullOrWhiteSpace(location.Value.ToString()))
            {
                body.id = location.Value.ToString().Split('/').Last();
            }
            return(response);
        }
 protected void TestSetup()
 {
     _model          = new StaffEducationOrganizationAssignmentAssociation();
     _modelInterface = _model;
 }