Ejemplo n.º 1
0
        public async Task <ServiceResponse <CakeOrderViewModel> > UpdateOrderStatusAsync(CakeOrderViewModel vm)
        {
            var serviceResponse = new ServiceResponse <CakeOrderViewModel>();
            var entity          = await _cakeOrderRepository.GetById(vm.Id);

            entity.OrderStatus = vm.OrderStatus;
            var cakeOrderEntity = await _cakeOrderRepository.Update(entity);

            serviceResponse.ServiceResponseStatus = ServiceResponseStatus.Ok;
            serviceResponse.Content = vm;

            await _notificationHandler.SendNotification(cakeOrderEntity.Id);

            return(serviceResponse);
        }
Ejemplo n.º 2
0
        public async Task <ServiceResponse <CakeOrderViewModel> > UpdateCakeOrderAsync(CakeOrderViewModel cakeOrder)
        {
            var response = new ServiceResponse <CakeOrderViewModel>();

            var entity = await _cakeOrderRepository.GetCakeOrderByIdAsync(cakeOrder.Id);

            entity.OrderStatus = cakeOrder.OrderStatus;

            var cakeOrderEntity = await _cakeOrderRepository.UpdateAsync(entity);

            var serviceResponse = await _notificationHandler.SendNotification(cakeOrderEntity);

            response.Content = cakeOrder;
            response.ServiceResponseStatus = serviceResponse.ServiceResponseStatus;
            response.Message = serviceResponse.Message;

            return(response);
        }
Ejemplo n.º 3
0
        public async Task <ServiceResponse <CakeOrderViewModel> > UpdateCakeOrderAsync(CakeOrderViewModel cakeOrder)
        {
            var response = new ServiceResponse <CakeOrderViewModel>();

            var entity = await _cakeOrderRepository.GetCakeOrderByIdAsync(cakeOrder.Id);

            entity.OrderStatus = cakeOrder.OrderStatus; // update de sadece status ü günceleyebiliyoruz şu an için. O yüzden o alanın viewden gelen değerini entity deki değere atıyoruz.// burada statu admin tarafından yönetim panelinden accepted e çevrilecek. ve sonrasında email göndereceğiz.

            //if (entity.OrderStatus == OrderStatus.Accepted) // bu bölümü NotificationHandler oluşturunca yorum haliine getirdik. Aşağıda notificationHandler ı çağırıp oradan dönen serviceResponse ile işlem iyapıyoruz artık. Mesaj gönderme ve email gönderme order ın statuüsne göre otomatik olacak.. accepted ise email, completed ise whatsapp mesajı gidecek otomatik olarak Twilio üzerinden.
            //{
            //    var emailResponse = await _emailService.SendEmail(entity);
            //}

            var cakeOrderEntity = await _cakeOrderRepository.UpdateAsync(entity);

            var serviceResponse = await _notificationHandler.SendNotification(cakeOrderEntity);

            response.Content = cakeOrder;
            response.ServiceResponseStatus = serviceResponse.ServiceResponseStatus;
            response.Message = serviceResponse.Message;

            return(response);
        }