Ejemplo n.º 1
0
 /// <summary>
 /// Saves/Updates a <see cref="OrganizationComponent"/> the user.
 /// </summary>
 /// <remarks>
 /// If this method is passed a SmartUser with a non-zero OrganizationComponent.ComponentId, it will update the corresponding OrganizationComponent in the repo. If this method is passed a OrganizationComponent with a OrganizationComponent.ComponentId = 0, then it will create a new OrganizationComponent in the repo.
 /// </remarks>
 /// <param name="component">The <see cref="OrganizationComponent"/> to be added/updated.</param>
 public void SaveComponent(OrganizationComponent component)
 {
     if (component.ComponentId == 0)
     {
         context.Components.Add(component);
     }
     else
     {
         OrganizationComponent dbComponent = context.Components.FirstOrDefault(x => x.ComponentId == component.ComponentId);
         dbComponent.Name           = component.Name;
         dbComponent.Address        = component.Address;
         dbComponent.DepartmentCode = component.DepartmentCode;
     }
     context.SaveChanges();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Removes a <see cref="OrganizationComponent"/>.
 /// </summary>
 /// <param name="component">The <see cref="OrganizationComponent"/> to remove.</param>
 public void RemoveComponent(OrganizationComponent component)
 {
     context.Components.Remove(component);
     context.SaveChanges();
 }