Beispiel #1
0
        public virtual IResultObjectModel <TModel> Get(TKey id)
        {
            ResultObjectModel <TModel> resultObjectModel = new ResultObjectModel <TModel>();

            try
            {
                TModel dto = GetByCache(id);
                dto = GetByDb(id, dto);
                resultObjectModel = new ResultObjectModel <TModel>(dto);
                SetNullMessage(resultObjectModel, dto);
            }
            catch (System.Exception ex)
            {
                resultObjectModel.IsSuccess = false;
                ExceptionManager exceptionManager = new ExceptionManager(ex);
                resultObjectModel.Messages.AddRange(exceptionManager.GetMessages());
            }
            resultObjectModel.SetResult();
            return(resultObjectModel);
        }
Beispiel #2
0
        public IResultObjectModel <UserDto> Edit(IUserInputModel inputModel)
        {
            IResultObjectModel <UserDto> resultObjectModel = new ResultObjectModel <UserDto>();

            try
            {
                //UserEditInputModel için özel bir validationOperation'da tercih edilebilir.
                UserEditInputModel           userEditInputModel = (UserEditInputModel)inputModel;
                IResultObjectModel <UserDto> editResult         = EditUserDtoByInputModel(inputModel, userEditInputModel);
                resultObjectModel = UpdateByEditResult(resultObjectModel, editResult);
            }
            catch (System.Exception ex)
            {
                resultObjectModel.IsSuccess = false;
                ExceptionManager exceptionManager = new ExceptionManager(ex);
                resultObjectModel.Messages.AddRange(exceptionManager.GetMessages());
            }
            resultObjectModel.SetResult();
            return(resultObjectModel);
        }
Beispiel #3
0
        public virtual IResultObjectModel <TModel> Insert(TModel dto)
        {
            ResultObjectModel <TModel> resultObjectModel = new ResultObjectModel <TModel>();

            try
            {
                InsertValidationOperation(dto);
                TEntity entity = Mapper.Map <TModel, TEntity>(dto);
                entity = DataOperation.Insert(entity);
                resultObjectModel.Data = Mapper.Map <TEntity, TModel>(entity);
                SetCacheByInsert(resultObjectModel.Data);
            }
            catch (System.Exception ex)
            {
                resultObjectModel.IsSuccess = false;
                ExceptionManager exceptionManager = new ExceptionManager(ex);
                resultObjectModel.Messages.AddRange(exceptionManager.GetMessages());
            }
            resultObjectModel.SetResult();
            return(resultObjectModel);
        }
Beispiel #4
0
        public IResultObjectModel <UserDto> Register(IUserInputModel inputModel)
        {
            IResultObjectModel <UserDto> resultObjectModel = new ResultObjectModel <UserDto>();

            try
            {
                RegisterInputValidation(inputModel);
                UserDto userDto = CreateUserDtoByRegisterInputModel(inputModel);
                userDto           = EncryptUserDtoPassword(userDto);
                resultObjectModel = Insert(userDto);
                SendWelcomeMailOperation(resultObjectModel);
            }
            catch (System.Exception ex)
            {
                resultObjectModel.IsSuccess = false;
                ExceptionManager exceptionManager = new ExceptionManager(ex);
                resultObjectModel.Messages.AddRange(exceptionManager.GetMessages());
            }
            resultObjectModel.SetResult();
            return(resultObjectModel);
        }