Ejemplo n.º 1
0
        public OperationResult <bool> EditSubCategory(ISubCategoriesDTO sub)
        {
            OperationResult <bool> retVal = null;

            try
            {
                // functionality to insert notice
                EmployeePortalValidationResult validationResult = Validator <SubCategoryManagerValidator, ISubCategoriesDTO> .Validate(sub, "AddSubCategory");

                if (!validationResult.IsValid)
                {
                    retVal = OperationResult <bool> .CreateFailureResult(validationResult);
                }
                else
                {
                    IEcommerceManagerDAC employeeManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC);
                    bool employeeDTO = employeeManagerDAC.EditSubCategory(sub);

                    retVal = OperationResult <bool> .CreateSuccessResult(employeeDTO);
                }
            }
            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);
        }
Ejemplo n.º 2
0
        public OperationResult <int> addSubCategory(ISubCategoriesDTO category)
        {
            OperationResult <int> retVal = null;

            try
            {
                EmployeePortalValidationResult validationResult = Validator <SubCategoryManagerValidator, ISubCategoriesDTO> .Validate(category, "AddSubCategory");

                if (!validationResult.IsValid)
                {
                    retVal = OperationResult <int> .CreateFailureResult(validationResult);
                }
                else
                {
                    IEcommerceManagerDAC employeeManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC);
                    int employeeId = employeeManagerDAC.addSubCategory(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);
        }
Ejemplo n.º 3
0
        public bool EditSubCategory(ISubCategoriesDTO sub)
        {
            bool retVal = false;

            using (EcommerceEntities employeePortalEntities = new EcommerceEntities())
            {
                try
                {
                    var employeeEntity = employeePortalEntities.SubCategories.FirstOrDefault(employee => employee.SubCategotyId == sub.SubCategotyId);
                    if (employeeEntity != null)
                    {
                        employeeEntity.CategotyId      = sub.CategotyId;
                        employeeEntity.SubCategoryName = sub.SubCategoryName;
                        employeePortalEntities.SaveChanges();
                        retVal = true;
                    }
                }
                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                    throw new DACException(ex.Message, ex);
                }
            }
            return(retVal);
        }
Ejemplo n.º 4
0
        public IList <ISubCategoriesDTO> GetAllSubCategories(int categoryId)
        {
            IList <ISubCategoriesDTO> employeeDTOList = new List <ISubCategoriesDTO>();
            ISubCategoriesDTO         employeeDTO     = null;

            using (EcommerceEntities employeePortalEntities = new EcommerceEntities())
            {
                try
                {
                    var employeeEntity = (employeePortalEntities.SubCategories).Where(subcategory => subcategory.CategotyId == categoryId);

                    foreach (var emp in employeeEntity)
                    {
                        employeeDTO = (ISubCategoriesDTO)DTOFactory.Instance.Create(DTOType.SubCategory);
                        EntityConverter.FillDTOFromEntity(emp, employeeDTO);
                        employeeDTOList.Add(employeeDTO);
                    }
                }
                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                    throw new DACException(ex.Message, ex);
                }
            }
            return(employeeDTOList);
        }
Ejemplo n.º 5
0
        private static void editSubCategory()
        {
            ISubCategoriesDTO subCategoryDTO = (ISubCategoriesDTO)DTOFactory.Instance.Create(DTOType.SubCategory, null);

            subCategoryDTO.SubCategotyId   = 1;
            subCategoryDTO.SubCategoryName = "subsub";
            subCategoryDTO.CategotyId      = 2;

            IEcommerceManagerFacade subCategoryManagerFacade = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager, null);
            OperationResult <bool>  operationResult          = subCategoryManagerFacade.EditSubCategory(subCategoryDTO);

            if (operationResult.IsValid())
            {
                System.Console.WriteLine("Successfully updated");
            }
            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 ActionResult EditSubCategory(SubCategory sub)
        {
            JsonResult retVal;

            if (ModelState.IsValid)
            {
                sub.SubCategotyId = updateSubCategoryId;
                IEcommerceManagerFacade employeeFacade = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager);

                ISubCategoriesDTO subCategoryDTO = (ISubCategoriesDTO)DTOFactory.Instance.Create(DTOType.SubCategory);
                subCategoryDTO.SubCategotyId   = sub.SubCategotyId;
                subCategoryDTO.SubCategoryName = sub.SubCategoryName;
                subCategoryDTO.CategotyId      = sub.CategotyId;
                OperationResult <bool> result = employeeFacade.EditSubCategory(subCategoryDTO);

                if (result.IsValid())
                {
                    retVal = new JsonResult()
                    {
                        Data = "Sucessfully Updated",
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    };
                }
                else if (result.HasValidationFailed() && result.ValidationResult != null)
                {
                    this.HandleValidationFailure(result);
                    return(EditSubCategory(updateSubCategoryId));
                }
                else
                {
                    OperationResult <int> succes = OperationResult <int> .CreateFailureResult("SubCategory can't be Edited. Please try after sometime.");

                    succes.IsValid();
                    retVal = new JsonResult()
                    {
                        Data = succes
                    };
                }
            }
            else
            {
                retVal = new JsonResult()
                {
                    Data = "Not Updated",
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
            }
            return(retVal);
        }
Ejemplo n.º 7
0
        public OperationResult <ISubCategoriesDTO> getSubCategory(int employeeId)
        {
            OperationResult <ISubCategoriesDTO> retVal = null;

            try
            {
                IEcommerceManagerDAC employeeManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC);
                ISubCategoriesDTO    employeeDTO        = employeeManagerDAC.getSubCategory(employeeId);

                retVal = OperationResult <ISubCategoriesDTO> .CreateSuccessResult(employeeDTO);
            }
            catch (DACException dacEx)
            {
                retVal = OperationResult <ISubCategoriesDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                retVal = OperationResult <ISubCategoriesDTO> .CreateErrorResult(ex.Message, ex.StackTrace);
            }

            return(retVal);
        }
        public int addSubCategory(ISubCategoriesDTO category)
        {
            int retVal = default(int);

            using (EcommerceEntities employeePortalEntities = new EcommerceEntities())
            {
                try
                {
                    SubCategory employee = new SubCategory();
                    EntityConverter.FillEntityFromDTO(category, employee);
                    SubCategory addedEmployee = employeePortalEntities.SubCategories.Add(employee);
                    employeePortalEntities.SaveChanges();
                    retVal = addedEmployee.SubCategotyId;
                }
                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                    throw new DACException(ex.Message, ex);
                }
            }

            return retVal;
        }
Ejemplo n.º 9
0
        public int addSubCategory(ISubCategoriesDTO category)
        {
            int retVal = default(int);

            using (EcommerceEntities employeePortalEntities = new EcommerceEntities())
            {
                try
                {
                    SubCategory employee = new SubCategory();
                    EntityConverter.FillEntityFromDTO(category, employee);
                    SubCategory addedEmployee = employeePortalEntities.SubCategories.Add(employee);
                    employeePortalEntities.SaveChanges();
                    retVal = addedEmployee.SubCategotyId;
                }
                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                    throw new DACException(ex.Message, ex);
                }
            }

            return(retVal);
        }
Ejemplo n.º 10
0
        public ISubCategoriesDTO getSubCategory(int employeeId)
        {
            ISubCategoriesDTO employeeDTO = null;

            using (EcommerceEntities employeePortalEntities = new EcommerceEntities())
            {
                try
                {
                    var employeeEntity = employeePortalEntities.SubCategories.FirstOrDefault(employee => employee.SubCategotyId == employeeId);
                    if (employeeEntity != null)
                    {
                        employeeDTO = (ISubCategoriesDTO)DTOFactory.Instance.Create(DTOType.SubCategory);
                        EntityConverter.FillDTOFromEntity(employeeEntity, employeeDTO);
                    }
                }

                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                    throw new DACException(ex.Message, ex);
                }
            }
            return(employeeDTO);
        }
 public OperationResult<bool> EditSubCategory(ISubCategoriesDTO sub)
 {
     IEcommerceManagerBDC employeeManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager);
     return employeeManagerBDC.EditSubCategory(sub);
 }
        public OperationResult<int> addSubCategory(ISubCategoriesDTO category)
        {
            IEcommerceManagerBDC employeeManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager);

            return employeeManagerBDC.addSubCategory(category);
        }
Ejemplo n.º 13
0
        public OperationResult <int> addSubCategory(ISubCategoriesDTO category)
        {
            IEcommerceManagerBDC employeeManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager);

            return(employeeManagerBDC.addSubCategory(category));
        }
        public OperationResult<int> addSubCategory(ISubCategoriesDTO category)
        {
            OperationResult<int> retVal = null;
            try
            {
                EmployeePortalValidationResult validationResult = Validator<SubCategoryManagerValidator, ISubCategoriesDTO>.Validate(category, "AddSubCategory");

                if (!validationResult.IsValid)
                {
                    retVal = OperationResult<int>.CreateFailureResult(validationResult);

                }
                else
                {
                    IEcommerceManagerDAC employeeManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC);
                    int employeeId = employeeManagerDAC.addSubCategory(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 OperationResult<bool> EditSubCategory(ISubCategoriesDTO sub)
        {
            OperationResult<bool> retVal = null;
            try
            {
                // functionality to insert notice
                EmployeePortalValidationResult validationResult = Validator<SubCategoryManagerValidator, ISubCategoriesDTO>.Validate(sub, "AddSubCategory");
                if (!validationResult.IsValid)
                {
                    retVal = OperationResult<bool>.CreateFailureResult(validationResult);
                }
                else
                {
                    IEcommerceManagerDAC employeeManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC);
                    bool employeeDTO = employeeManagerDAC.EditSubCategory(sub);

                    retVal = OperationResult<bool>.CreateSuccessResult(employeeDTO);
                }

            }
            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;
        }
        public bool EditSubCategory(ISubCategoriesDTO sub)
        {
            bool retVal = false;
            using (EcommerceEntities employeePortalEntities = new EcommerceEntities())
            {
                try
                {
                    var employeeEntity = employeePortalEntities.SubCategories.FirstOrDefault(employee => employee.SubCategotyId == sub.SubCategotyId);
                    if (employeeEntity != null)
                    {

                        employeeEntity.CategotyId = sub.CategotyId;
                        employeeEntity.SubCategoryName = sub.SubCategoryName;
                        employeePortalEntities.SaveChanges();
                        retVal = true;
                    }
                }
                catch (Exception ex)
                {
                    ExceptionManager.HandleException(ex);
                    throw new DACException(ex.Message, ex);
                }
            }
            return retVal;
        }
Ejemplo n.º 17
0
        public OperationResult <bool> EditSubCategory(ISubCategoriesDTO sub)
        {
            IEcommerceManagerBDC employeeManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager);

            return(employeeManagerBDC.EditSubCategory(sub));
        }