public async Task <HttpResponseMessage> GetPersonById(Guid id)
        {
            var        mapper = restPersonMapperConfig.CreateMapper();
            RestPerson person = mapper.Map <RestPerson>(await defaultService.ReturnPersonById(id));

            if (person == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, String.Format("There is no person with Id: {0}", id)));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, person));
        }
        public async Task <HttpResponseMessage> PutById(Guid id, RestPerson restPerson)
        {
            var    config = new MapperConfiguration(cfg => cfg.CreateMap <RestPerson, Person>());
            var    mapper = config.CreateMapper();
            Person person = mapper.Map <Person>(restPerson);
            bool   flag   = await defaultService.UpdatePersonById(id, person);

            if (!flag)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, String.Format("There is no person with Id: {0}", id)));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, restPerson));
        }
        public async Task <HttpResponseMessage> GetPersonsReceiptsByPersonsId(Guid id)
        {
            Tuple <Person, List <Receipt> > tuple = await defaultService.ReturnPersonsReceipts(id);

            if (tuple == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, String.Format("There are no receipts for person with Id: {0}", id)));
            }

            var                personMapper  = restPersonMapperConfig.CreateMapper();
            var                receiptMapper = restReceiptMapperConfig.CreateMapper();
            RestPerson         restPerson    = personMapper.Map <RestPerson>(tuple.Item1);
            List <RestReceipt> restReceipts  = receiptMapper.Map <List <RestReceipt> >(tuple.Item2);
            Tuple <RestPerson, List <RestReceipt> > restTuple = new Tuple <RestPerson, List <RestReceipt> >(restPerson, restReceipts);

            return(Request.CreateResponse(HttpStatusCode.OK, restTuple));
        }