예제 #1
0
        public async Task <HttpResponseMessage> Delete(GoalStepViewModel postedViewModel)
        {
            var mapper          = GetMapper();
            var entityDeleteing = mapper.Map <GoalStep>(postedViewModel);
            var result          = await businessService.DeleteGoalStepAsync(entityDeleteing);

            if (result.ReturnStatus == false)
            {
                return(CreateErrorResponse(result));
            }

            return(CreateViewModelResponse(postedViewModel, result));
        }
예제 #2
0
        public async Task <HttpResponseMessage> Add(GoalStepViewModel postedViewModel)
        {
            var mapper         = GetMapper();
            var entityCreating = mapper.Map <GoalStep>(postedViewModel);
            var entityCreated  = await businessService.CreateGoalStepAsync(entityCreating);

            if (entityCreated.ReturnStatus == false)
            {
                return(CreateErrorResponse(entityCreated));
            }
            postedViewModel = mapper.Map <GoalStepViewModel>(entityCreated.ResultValue);
            return(CreateViewModelResponse(postedViewModel, entityCreated));
        }
예제 #3
0
        public async Task <HttpResponseMessage> Edit(GoalStepViewModel postedViewModel)
        {
            var mapper         = GetMapper();
            var entityUpdating = mapper.Map <GoalStep>(postedViewModel);
            var actionResult   = await businessService.UpdateGoalStepAsync(entityUpdating);

            if (actionResult.ReturnStatus == false)
            {
                return(CreateErrorResponse(actionResult));
            }

            return(CreateViewModelResponse(postedViewModel, actionResult));
        }
예제 #4
0
        public async Task <HttpResponseMessage> GetDataList(GoalStepViewModel postedViewModel)
        {
            var entities = await businessService.EntityListLoader.LoadListAsync(where : x => x.GoalId == postedViewModel.GoalId);

            if (entities.ReturnStatus == false)
            {
                return(CreateErrorResponse(entities));
            }
            var mapper = GetMapper();
            var result = mapper.Map <List <GoalStep>, List <GoalStepViewModel> >(entities.ResultValue);

            return(CreateSuccessedListResponse <GoalStepViewModel>(result));
        }