Esempio 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);
        }
Esempio n. 2
0
        public OperationResult <int> addItem(IItemDTO category)
        {
            OperationResult <int> retVal = null;

            try
            {
                EmployeePortalValidationResult validationResult = Validator <ItemManagerValidator, IItemDTO> .Validate(category);

                if (!validationResult.IsValid)
                {
                    retVal = OperationResult <int> .CreateFailureResult(validationResult);
                }
                else
                {
                    IEcommerceManagerDAC employeeManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC);
                    int employeeId = employeeManagerDAC.addItem(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);
        }
Esempio n. 3
0
        public OperationResult <ICategoriesDTO> editCategory(ICategoriesDTO categoryDTO)
        {
            OperationResult <ICategoriesDTO> retVal = null;

            try
            {
                EmployeePortalValidationResult validationResult = Validator <CategoryManagerValidator, ICategoriesDTO> .Validate(categoryDTO, "addCategory");

                if (!validationResult.IsValid)
                {
                    retVal = OperationResult <ICategoriesDTO> .CreateFailureResult(validationResult);
                }
                else
                {
                    IEcommerceManagerDAC categoryManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC, null);
                    ICategoriesDTO       addedCategory      = categoryManagerDAC.editCategory(categoryDTO);
                    retVal = OperationResult <ICategoriesDTO> .CreateSuccessResult(addedCategory);
                }
            }
            catch (DACException dacEx)
            {
                retVal = OperationResult <ICategoriesDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                retVal = OperationResult <ICategoriesDTO> .CreateErrorResult(ex.Message, ex.StackTrace);
            }
            return(retVal);
        }
Esempio n. 4
0
        public OperationResult <INoticeDTO> UpdateNotice(INoticeDTO noticeDTO)
        {
            OperationResult <INoticeDTO> updateNoticeReturnValue = null;

            try
            {
                INoticeDAC noticeDAC = (INoticeDAC)DACFactory.Instance.Create(DACType.NoticeManagerDAC);

                EmployeePortalValidationResult validationResult = Validator <NoticeValidator, INoticeDTO> .Validate(noticeDTO, ValidationConstants.Common);

                if (!validationResult.IsValid)
                {
                    updateNoticeReturnValue = OperationResult <INoticeDTO> .CreateFailureResult(validationResult);
                }
                else
                {
                    INoticeDTO returnedNoticeDTO = noticeDAC.UpdateNotice(noticeDTO);
                    if (returnedNoticeDTO != null)
                    {
                        updateNoticeReturnValue = OperationResult <INoticeDTO> .CreateSuccessResult(returnedNoticeDTO, "Notice updated successfully");
                    }
                }
            }
            catch (DACException dacEx)
            {
                updateNoticeReturnValue = OperationResult <INoticeDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                updateNoticeReturnValue = OperationResult <INoticeDTO> .CreateErrorResult(ex.Message, ex.StackTrace);
            }

            return(updateNoticeReturnValue);
        }
        public OperationResult <IUserDTO> UpdateProfile(IUserDTO userDTO)
        {
            OperationResult <IUserDTO> updateProfileReturnValue = null;

            try
            {
                EmployeePortalValidationResult validationResult = Validator <UserValidator, IUserDTO> .Validate(userDTO, ValidationConstants.CommomUservalidations);

                if (!validationResult.IsValid)
                {
                    updateProfileReturnValue = OperationResult <IUserDTO> .CreateFailureResult(validationResult);
                }
                else
                {
                    IUserDAC userDAC         = (IUserDAC)DACFactory.Instance.Create(DACType.UserManagerDAC);
                    IUserDTO returnedUserDTO = userDAC.UpdateProfile(userDTO);
                    if (returnedUserDTO != null)
                    {
                        updateProfileReturnValue = OperationResult <IUserDTO> .CreateSuccessResult(returnedUserDTO, "Profile updated successfully");
                    }
                }
            }
            catch (DACException dacEx)
            {
                updateProfileReturnValue = OperationResult <IUserDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                updateProfileReturnValue = OperationResult <IUserDTO> .CreateErrorResult(ex.Message, ex.StackTrace);
            }

            return(updateProfileReturnValue);
        }
        public OperationResult <IIssueHistoryDTO> UpdateIssueByAdmin(IIssueHistoryDTO issueDTO)
        {
            OperationResult <IIssueHistoryDTO> retVal = null;

            try
            {
                EmployeePortalValidationResult validationResult = Validator <IssueHistoryValidator, IIssueHistoryDTO> .Validate(issueDTO, ValidationConstants.UpdateIssueHistory);

                if (!validationResult.IsValid)
                {
                    retVal = OperationResult <IIssueHistoryDTO> .CreateFailureResult(validationResult);
                }
                else
                {
                    IIssueDAC        issueDAC       = (IIssueDAC)DACFactory.Instance.Create(DACType.IssueManagerDAC);
                    IIssueHistoryDTO resultIssueDTO = issueDAC.UpdateIssueByAdmin(issueDTO);

                    if (resultIssueDTO != null)
                    {
                        retVal = OperationResult <IIssueHistoryDTO> .CreateSuccessResult(resultIssueDTO);
                    }
                    else
                    {
                        retVal = OperationResult <IIssueHistoryDTO> .CreateFailureResult("Update issue by admin Failed!");
                    }
                }
            }
            catch (DACException dacEx)
            {
                retVal = OperationResult <IIssueHistoryDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                retVal = OperationResult <IIssueHistoryDTO> .CreateErrorResult(ex.Message, ex.StackTrace);
            }

            return(retVal);
        }
Esempio n. 7
0
        public OperationResult <IUserDto> CreateUser(IUserDto userDto)
        {
            OperationResult <IUserDto> createUserReturnValue = null;

            try
            {
                EmployeePortalValidationResult validationResult = Validator <UserValidator, IUserDto> .Validate(userDto, Constants.UserMessage.CreateUserEmail);

                if (!validationResult.IsValid)
                {
                    createUserReturnValue = OperationResult <IUserDto> .CreateFailureResult(validationResult);
                }
                else
                {
                    IUserDac employeeDac     = (IUserDac)DacFactory.Instance.Create(DacType.UserDac);
                    IUserDto returnedUserDto = employeeDac.CreateUser(userDto);
                    if (returnedUserDto != null)
                    {
                        createUserReturnValue = OperationResult <IUserDto> .CreateSuccessResult(returnedUserDto, Constants.UserMessage.Usercreatedsuccessfully);
                    }
                    else
                    {
                        createUserReturnValue = OperationResult <IUserDto> .CreateFailureResult(Constants.UserMessage.InsertionFialed);
                    }
                }
            }
            catch (DacException dacEx)
            {
                createUserReturnValue = OperationResult <IUserDto> .CreateErrorResult(dacEx.Message, dacEx.StackTrace);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                createUserReturnValue = OperationResult <IUserDto> .CreateErrorResult(ex.Message, ex.StackTrace);
            }

            return(createUserReturnValue);
        }
        public OperationResult <IUserDTO> CreateEmployeeBySProc(IUserDTO userDTO)
        {
            OperationResult <IUserDTO> getUserReturnValue = null;

            try
            {
                EmployeePortalValidationResult validationResult = Validator <UserValidator, IUserDTO> .Validate(userDTO, ValidationConstants.CreateEmployee + "," + ValidationConstants.CommomUservalidations + "," + ValidationConstants.UpdateCreateUser);

                if (!validationResult.IsValid)
                {
                    getUserReturnValue = OperationResult <IUserDTO> .CreateFailureResult(validationResult);
                }
                else
                {
                    IUserDAC userDAC = (IUserDAC)DACFactory.Instance.Create(DACType.UserManagerDAC);
                    userDTO = userDAC.CreateEmployeeBySProc(userDTO);
                    if (userDTO != null)
                    {
                        getUserReturnValue = OperationResult <IUserDTO> .CreateSuccessResult(userDTO);
                    }
                    else
                    {
                        getUserReturnValue = OperationResult <IUserDTO> .CreateFailureResult("creation Failed");
                    }
                }
            }
            catch (DACException dacEx)
            {
                getUserReturnValue = OperationResult <IUserDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                getUserReturnValue = OperationResult <IUserDTO> .CreateErrorResult(ex.Message, ex.StackTrace);
            }
            return(getUserReturnValue);
        }