/// <summary> /// Obtiene una colección de categoryEntity /// </summary> /// <param name="loadRelation">true si desea guardar las relaciones</param> /// <param name="session">Identificador de sesion.</param> /// <returns>Collection de CategoryEntity</returns> /// <exception cref="UtnEmallBusinessLogicException"> /// Si una excepción UtnEmallDataAccessException ocurre en el data model. /// </exception> public Collection <CategoryEntity> GetAllCategory(bool loadRelation) { try { return(categoryDataAccess.LoadAll(loadRelation)); } catch (UtnEmallDataAccessException utnEmallDataAccessException) { throw new UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException); } }
public static void AddNewPreferencesDueToNewCustomer(CustomerEntity customer) { // Add all the categories as preferences. CustomerDataAccess customerDataAccess = new CustomerDataAccess(); CategoryDataAccess categoryDataAccess = new CategoryDataAccess(); foreach (CategoryEntity category in categoryDataAccess.LoadAll(false)) { PreferenceEntity preference = new PreferenceEntity(); preference.Active = true; preference.Level = 0; preference.Category = category; preference.IdCustomer = customer.Id; preference.IsNew = true; customer.Preferences.Add(preference); } customerDataAccess.Save(customer); }
/// <summary> /// Get collection of all categoryEntity /// </summary> /// <param name="loadRelation">true to load the relations</param> /// <param name="session">User's session identifier.</param> /// <returns>Collection of all CategoryEntity</returns> /// <exception cref="UtnEmallBusinessLogicException"> /// If an UtnEmallDataAccessException occurs in DataModel. /// </exception> public Collection <CategoryEntity> GetAllCategory(bool loadRelation, string session) { bool permited = ValidationService.Instance.ValidatePermission(session, "read", "Category"); if (!permited) { ExceptionDetail detail = new ExceptionDetail(new UtnEmall.Server.BusinessLogic.UtnEmallPermissionException("The user hasn't permissions to read an entity")); throw new FaultException <ExceptionDetail>(detail); } try { return(categoryDataAccess.LoadAll(loadRelation)); } catch (UtnEmallDataAccessException utnEmallDataAccessException) { throw new UtnEmall.Server.BusinessLogic.UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException); } }