public OperationResult <bool> removeCategory(int categoryId) { OperationResult <bool> retVal = null; try { ICategoriesDTO categoryDTO = (ICategoriesDTO)DTOFactory.Instance.Create(DTOType.Category, null); categoryDTO.CategotyId = categoryId; IEcommerceManagerDAC categoryManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC, null); bool isRemoved = categoryManagerDAC.removeCategory(categoryId); retVal = OperationResult <bool> .CreateSuccessResult(isRemoved); } catch (DACException dacEx) { retVal = OperationResult <bool> .CreateErrorResult(dacEx.Message, dacEx.StackTrace); } catch (Exception ex) { ExceptionManager.HandleException(ex); retVal = OperationResult <bool> .CreateErrorResult(ex.Message, ex.StackTrace); } return(retVal); }
private static void addCategory() { ICategoriesDTO categoryDTO = (ICategoriesDTO)DTOFactory.Instance.Create(DTOType.Category, null); categoryDTO.CategoryName = "Food"; IEcommerceManagerFacade categoryManagerFacade = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager, null); OperationResult <int> operationResult = categoryManagerFacade.addCategory(categoryDTO); if (operationResult.IsValid()) { System.Console.WriteLine(operationResult.Data); } else if (operationResult.HasValidationFailed() && operationResult.ValidationResult != null) { foreach (EmployeePortalValidationFailure error in operationResult.ValidationResult.Errors) { System.Console.WriteLine(error.PropertyName + " " + error.ErrorMessage); } } else if (operationResult.Message != String.Empty && operationResult.StackTrace != String.Empty) { System.Console.WriteLine(operationResult.Message + " " + operationResult.StackTrace); } }
public IList <ICategoriesDTO> GetAllCategories() { IList <ICategoriesDTO> employeeDTOList = new List <ICategoriesDTO>(); ICategoriesDTO employeeDTO = null; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = (employeePortalEntities.Categories); foreach (var emp in employeeEntity) { employeeDTO = (ICategoriesDTO)DTOFactory.Instance.Create(DTOType.Category); EntityConverter.FillDTOFromEntity(emp, employeeDTO); employeeDTOList.Add(employeeDTO); } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return(employeeDTOList); }
public OperationResult <int> addCategory(ICategoriesDTO category) { OperationResult <int> retVal = null; try { EmployeePortalValidationResult validationResult = Validator <CategoryManagerValidator, ICategoriesDTO> .Validate(category, "addCategory"); if (!validationResult.IsValid) { retVal = OperationResult <int> .CreateFailureResult(validationResult); } else { IEcommerceManagerDAC employeeManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC); int employeeId = employeeManagerDAC.addCategory(category); retVal = OperationResult <int> .CreateSuccessResult(employeeId); } } catch (DACException dacEx) { retVal = OperationResult <int> .CreateErrorResult(dacEx.Message, dacEx.StackTrace); } catch (Exception ex) { ExceptionManager.HandleException(ex); retVal = OperationResult <int> .CreateErrorResult(ex.Message, ex.StackTrace); } return(retVal); }
public ICategoriesDTO editCategory(ICategoriesDTO categoryDTO) { ICategoriesDTO retVal = null; try { using (var database = new EcommerceEntities()) { var category = database.Categories.Where(c => c.CategotyId == categoryDTO.CategotyId).FirstOrDefault(); if (category != null) { category.CategoryName = categoryDTO.CategoryName; database.SaveChanges(); retVal = (ICategoriesDTO)DTOFactory.Instance.Create(DTOType.Category, null); EntityConverter.FillDTOFromEntity(category, retVal); } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } return(retVal); }
public OperationResult<int> addCategory(ICategoriesDTO category) { OperationResult<int> retVal = null; try { EmployeePortalValidationResult validationResult = Validator<CategoryManagerValidator, ICategoriesDTO>.Validate(category, "addCategory"); if (!validationResult.IsValid) { retVal = OperationResult<int>.CreateFailureResult(validationResult); } else { IEcommerceManagerDAC employeeManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC); int employeeId = employeeManagerDAC.addCategory(category); retVal = OperationResult<int>.CreateSuccessResult(employeeId); } } catch (DACException dacEx) { retVal = OperationResult<int>.CreateErrorResult(dacEx.Message, dacEx.StackTrace); } catch (Exception ex) { ExceptionManager.HandleException(ex); retVal = OperationResult<int>.CreateErrorResult(ex.Message, ex.StackTrace); } return retVal; }
public int addCategory(ICategoriesDTO category) { int retVal = default(int); using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { Category employee = new Category(); EntityConverter.FillEntityFromDTO(category, employee); Category addedEmployee = employeePortalEntities.Categories.Add(employee); employeePortalEntities.SaveChanges(); retVal = addedEmployee.CategotyId; } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return retVal; }
public int addCategory(ICategoriesDTO category) { int retVal = default(int); using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { Category employee = new Category(); EntityConverter.FillEntityFromDTO(category, employee); Category addedEmployee = employeePortalEntities.Categories.Add(employee); employeePortalEntities.SaveChanges(); retVal = addedEmployee.CategotyId; } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return(retVal); }
public OperationResult<ICategoriesDTO> editCategory(ICategoriesDTO categoryDTO) { IEcommerceManagerBDC categoryManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager, null); return categoryManagerBDC.editCategory(categoryDTO); }
public OperationResult<int> addCategory(ICategoriesDTO category) { IEcommerceManagerBDC employeeManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager); return employeeManagerBDC.addCategory(category); }
public ICategoriesDTO editCategory(ICategoriesDTO categoryDTO) { ICategoriesDTO retVal = null; try { using (var database = new EcommerceEntities()) { var category = database.Categories.Where(c => c.CategotyId == categoryDTO.CategotyId).FirstOrDefault(); if (category != null) { category.CategoryName = categoryDTO.CategoryName; database.SaveChanges(); retVal = (ICategoriesDTO)DTOFactory.Instance.Create(DTOType.Category, null); EntityConverter.FillDTOFromEntity(category, retVal); } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } return retVal; }
public OperationResult <int> addCategory(ICategoriesDTO category) { IEcommerceManagerBDC employeeManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager); return(employeeManagerBDC.addCategory(category)); }
public OperationResult <ICategoriesDTO> editCategory(ICategoriesDTO categoryDTO) { IEcommerceManagerBDC categoryManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager, null); return(categoryManagerBDC.editCategory(categoryDTO)); }