Exemplo n.º 1
0
        public async Task <ServiceResponse <CakeOrderViewModel> > GetOrderByIdAsync(int id)
        {
            var orderEntity = await _cakeOrderRepository
                              .GetCakeOrderByIdAsync(id);

            var response = new ServiceResponse <CakeOrderViewModel>();

            if (orderEntity is null)
            {
                response.ServiceResponseStatus = ServiceResponseStatus.NotFound;
                response.Message = "no record available";
                return(response);
            }

            response.Content = new CakeOrderViewModel(orderEntity, orderEntity.User);

            response.ServiceResponseStatus = ServiceResponseStatus.Ok;

            return(response);
        }
Exemplo n.º 2
0
        public async Task <ServiceResponse <CakeOrderViewModel> > GetOrderByIdAsync(int id)
        {
            var orderEntity = await _cakeOrderRepository
                              .GetCakeOrderByIdAsync(id);

            var response = new ServiceResponse <CakeOrderViewModel>();

            if (orderEntity is null)
            {
                response.ServiceResponseStatus = ServiceResponseStatus.NotFound;
                response.Message = "no record available";
                return(response); // this returns to CakeOrderController
            }

            response.Content = new CakeOrderViewModel(orderEntity, orderEntity.User); // burada repositoryden gelen order entiti ve içindeki user ı yukarıda oluşturduğumuz boş responde var ına altarıyoruz ve response.un contentinin dolduruyoruz. Aşağıda da response ı controller e gönderiyoruz

            response.ServiceResponseStatus = ServiceResponseStatus.Ok;

            return(response); // this returns to CakeOrderController
        }