public async Task <TestGetViewModel> Post([FromBody] TestCreateViewModel testModel)
        {
            var entity = new Test();

            SetClientIp(entity);
            testModel.Hydrate(entity);
            var view = new TestGetViewModel(entity);
            await _testService.Create(entity);

            return(view);
        }
        public async Task <TestGetViewModel> Get(Guid id)
        {
            var entity = await _testService.Get(id);

            var viewItem = new TestGetViewModel();

            if (entity != null)
            {
                viewItem = new TestGetViewModel(entity);
            }
            return(viewItem);
        }
        public async Task <IEnumerable <TestGetViewModel> > GetAll()
        {
            var list = await _testService.GetAll();

            var view = new HashSet <TestGetViewModel>();

            foreach (var entity in list)
            {
                var viewItem = new TestGetViewModel(entity);
                view.Add(viewItem);
            }
            return(view);
        }
        public async Task <TestGetViewModel> Put([FromBody] TestGetViewModel testModel, Guid id)
        {
            if (id.Equals(null))
            {
                Response.StatusCode = 402;
                return(new TestGetViewModel());
            }
            var record = await _testService.Get(id);

            if (record != null)
            {
                var entity = new Test();
                testModel.Hydrate(entity);
                entity.Id = id;
                entity    = await _testService.Update(entity);

                var view = new TestGetViewModel(entity);
                return(view);
            }
            Response.StatusCode = (int)HttpStatusCode.OK;
            return(new TestGetViewModel());
        }