internal IValidationResult Component(Component component) { IValidationResult validationResult = new ValidationResult(); // Is the component id valid? if (component.ComponentId <= 0 || component.ComponentId > int.MaxValue) { validationResult.AddError("ComponentId.Range_" + component.ComponentId.ToString(), "ComponentId can not be less than or equal to 0. Also, the upper limit cannot exceed the max value of the int data type."); } // Does the component already exist in the database? if (this.doctrineShipsRepository.GetComponent(component.ComponentId) != null) { validationResult.AddError("ComponentId.Exists_" + component.ComponentId.ToString(), "ComponentId already exists in the database."); } return validationResult; }
/// <summary> /// Adds a component based upon its name. /// </summary> /// <param name="componentName">The name of a component to be added.</param> /// <returns>Returns a populated component object or null if the process fails.</returns> internal Component AddComponent(string componentName) { int componentId = 0; Component component = null; // Does the component name successfully resolve to an id? componentId = eveDataSource.GetTypeId(componentName); if (componentId != 0) { // Does the component already exist in the database? If not, add it. component = this.doctrineShipsRepository.GetComponent(componentId); if (component == null) { component = new Component(); component.ComponentId = componentId; // Resolve the id back to the name to get correct capitalisation etc component.Name = eveDataSource.GetTypeName(componentId); component.ImageUrl = eveDataSource.GetTypeImageUrl(componentId); component.Volume = eveDataSource.GetTypeVolume(componentId); // Validate the new component. if (this.doctrineShipsValidation.Component(component).IsValid == true) { // Add the new component and read it back. component = this.doctrineShipsRepository.CreateComponent(component); this.doctrineShipsRepository.Save(); } } } return component; }
public void UpdateComponent(Component component) { ComponentOperations.UpdateComponent(component); }
public Component CreateComponent(Component component) { return ComponentOperations.CreateComponent(component); }
public Component AddComponent(Component component) { return ComponentOperations.AddComponent(component); }
internal void UpdateComponent(Component component) { component.ObjectState = ObjectState.Modified; this.unitOfWork.Repository<Component>().Update(component); }
internal Component CreateComponent(Component component) { component.ObjectState = ObjectState.Added; this.unitOfWork.Repository<Component>().Insert(component); return component; }
internal Component AddComponent(Component component) { this.unitOfWork.Repository<Component>().Insert(component); return component; }
public IValidationResult Component(Component component) { return ShipFitCheck.Component(component); }