public static async Task <string> RunOrchestrator(
            [OrchestrationTrigger] IDurableOrchestrationContext context)
        {
            var     tasks   = new List <Task>();
            Payment payment = context.GetInput <Payment>();
            string  paymentResult;

            if (payment is null)
            {
                throw new System.Exception("Invalid payment");
            }

            if (payment.Customer is null)
            {
                throw new System.Exception("Invalid Customer");
            }

            var paymentProcessingNotification = new CustomerNotification(payment.Customer, "Payment processing");

            var PaymentApprovalWorkflowTask = context.CallSubOrchestratorAsync <bool>("PaymentApprovalWorkflow", payment);

            tasks.Add(context.CallActivityAsync <Task>("NotifyCustomerActivity", paymentProcessingNotification));
            tasks.Add(PaymentApprovalWorkflowTask);

            await Task.WhenAll(tasks);

            paymentResult = (PaymentApprovalWorkflowTask.Result) ? "Payment Approved" : "Payment Rejected";

            return(paymentResult);
        }
예제 #2
0
        public CustomerNotificationDTM CNotificationToCNotificationDtmMap(CustomerNotification cNotification)
        {
            CustomerNotificationDTM customerNotificationDTM = new CustomerNotificationDTM();

            customerNotificationDTM.EmployeeId       = cNotification.EmployeeId;
            customerNotificationDTM.AfterBooked      = cNotification.AfterBooked;
            customerNotificationDTM.AfterRescheduled = cNotification.AfterRescheduled;
            customerNotificationDTM.AfterCancelled   = cNotification.AfterCancelled;
            return(customerNotificationDTM);
        }
예제 #3
0
        public static CustomerNotificationDTM changeToDTM(CustomerNotification cNotification)
        {
            CustomerNotificationDTM customerNotificationDTM = new CustomerNotificationDTM();

            customerNotificationDTM.EmployeeId       = cNotification.EmployeeId;
            customerNotificationDTM.AfterBooked      = cNotification.AfterBooked;
            customerNotificationDTM.AfterRescheduled = cNotification.AfterRescheduled;
            customerNotificationDTM.AfterCancelled   = cNotification.AfterCancelled;
            return(customerNotificationDTM);
        }
        public static async Task NotifyCustomer(
            [ActivityTrigger] CustomerNotification customerNotification,
            ILogger log)
        {
            log.LogInformation("NotifyCustomer begin");

            log.LogInformation($"Notifying customer {customerNotification.Customer.Name} on email {customerNotification.Customer.Email}");
            await SendEmail(customerNotification.Customer, customerNotification.Message, log);

            log.LogInformation("NotifyCustomer end");
        }
예제 #5
0
        public static CustomerNotification changeFromDTM(CustomerNotificationDTM cNoticeDtm)
        {
            CustomerNotification customerNotification = new CustomerNotification();

            customerNotification.EmployeeId       = cNoticeDtm.EmployeeId;
            customerNotification.AfterBooked      = cNoticeDtm.AfterBooked;
            customerNotification.AfterRescheduled = cNoticeDtm.AfterRescheduled;
            customerNotification.AfterCancelled   = cNoticeDtm.AfterCancelled;

            if (cNoticeDtm.Employee != null)
            {
                customerNotification.Employee = changeFromDTM(cNoticeDtm.Employee);
            }

            return(customerNotification);
        }
예제 #6
0
        public async Task <int> Create(EmployeeDTM item)
        {
            try
            {
                Employee employee = new Employee();
                employee.Business = await Database.Businesses.Get(item.Business.Id);

                employee.BusinessId = item.Business.Id;
                employee.User       = await Database.Users.Get(item.User.Id);

                employee.UserId  = item.User.Id;
                employee.IsOwner = item.IsOwner;

                await Database.Employees.Create(employee);

                if (employee.IsOwner == false)
                {
                    WorkingHour wHourDtm = new WorkingHour();
                    wHourDtm.Employee   = employee;
                    wHourDtm.EmployeeId = employee.Id;
                    await Database.WorkingHours.Create(wHourDtm);

                    Permission perm = new Permission();
                    perm.Employee   = employee;
                    perm.EmployeeId = employee.Id;
                    await Database.Permissions.Create(perm);

                    CalendarSetting cSetting = new CalendarSetting();
                    cSetting.Employee   = employee;
                    cSetting.EmployeeId = employee.Id;
                    await Database.CalendarSettings.Create(cSetting);

                    CustomerNotification cNotif = new CustomerNotification();
                    cNotif.Employee   = employee;
                    cNotif.EmployeeId = employee.Id;
                    await Database.CustomerNotifications.Create(cNotif);

                    TeamNotification tNotif = new TeamNotification();
                    tNotif.Employee   = employee;
                    tNotif.EmployeeId = employee.Id;
                    await Database.TeamNotifications.Create(tNotif);
                }

                return(employee.Id);
            }
            catch { return(0); }
        }
예제 #7
0
        public async Task <int> Create(CustomerNotificationDTM cNotificationDtm)
        {
            try
            {
                CustomerNotification customerNotification = new CustomerNotification();
                customerNotification.AfterBooked      = cNotificationDtm.AfterBooked;
                customerNotification.AfterRescheduled = cNotificationDtm.AfterRescheduled;
                customerNotification.AfterCancelled   = cNotificationDtm.AfterCancelled;

                customerNotification.Employee = await Database.Employees.Get(cNotificationDtm.EmployeeId);

                await Database.CustomerNotifications.Create(customerNotification);

                return(customerNotification.EmployeeId);
            }
            catch { return(0); }
        }
        private async Task OnMarkRead(CustomerNotification arg)
        {
            try
            {
                if (arg == null)
                {
                    return;
                }
                var isRead  = arg.IsRead.GetValueOrDefault();
                var message = isRead
                    ? nameof(AppResources.MarkNotReadMessage).Translate()
                    : nameof(AppResources.MarkReadMessage).Translate();

                var confirmation = await Alert
                                   .ShowMessageConfirmation(message,
                                                            null,
                                                            nameof(AppResources.Yes).Translate(),
                                                            nameof(AppResources.No).Translate());

                if (!confirmation)
                {
                    return;
                }
                IsBusy     = true;
                arg.IsRead = !isRead;
                var notificationRead = await Api.MarkNotificationRead(arg);

                if (notificationRead.Successful.GetValueOrDefault())
                {
                    await Load();

                    return;
                }

                await Alert.ShowMessage(notificationRead.ExceptionMessage);
            }
            catch (Exception e)
            {
                await Alert.DisplayError(e);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #9
0
        public async Task <bool> Update(CustomerNotificationDTM cNotificationDtm)
        {
            try
            {
                CustomerNotification customerNotification = new CustomerNotification();
                customerNotification.EmployeeId       = cNotificationDtm.EmployeeId;
                customerNotification.AfterBooked      = cNotificationDtm.AfterBooked;
                customerNotification.AfterRescheduled = cNotificationDtm.AfterRescheduled;
                customerNotification.AfterCancelled   = cNotificationDtm.AfterCancelled;
                if (cNotificationDtm.Employee != null)
                {
                    customerNotification.Employee = ModelFactory.changeFromDTM(cNotificationDtm.Employee);
                }

                return(await Database.CustomerNotifications.Update(customerNotification) ? true : false);
            }
            catch (Exception ex) { Console.Out.WriteLine(ex.Message); return(false); }
        }
예제 #10
0
        public static Employee changeFromDTM(EmployeeDTM employeeDtm)
        {
            Employee employee = new Employee();

            employee.Id         = employeeDtm.Id;
            employee.Business   = changeFromDTM(employeeDtm.Business);
            employee.BusinessId = employeeDtm.Business.Id;
            employee.User       = changeFromDTM(employeeDtm.User);
            employee.UserId     = employeeDtm.User.Id;
            employee.IsOwner    = employeeDtm.IsOwner;

            if (employeeDtm.CalendarSetting != null)
            {
                CalendarSetting cset = new CalendarSetting();
                cset = changeFromDTM(employeeDtm.CalendarSetting);
                employee.CalendarSetting = cset;
            }
            if (employeeDtm.CustomerNotification != null)
            {
                CustomerNotification cNotice = new CustomerNotification();
                cNotice = changeFromDTM(employeeDtm.CustomerNotification);
                employee.CustomerNotification = cNotice;
            }
            if (employeeDtm.TeamNotification != null)
            {
                TeamNotification tNotice = new TeamNotification();
                tNotice = changeFromDTM(employeeDtm.TeamNotification);
                employee.TeamNotification = tNotice;
            }
            if (employeeDtm.Permission != null)
            {
                Permission permission = new Permission();
                permission          = changeFromDTM(employeeDtm.Permission);
                employee.Permission = permission;
            }
            if (employeeDtm.WorkingHour != null)
            {
                WorkingHour wHour = new WorkingHour();
                wHour = changeFromDTM(employeeDtm.WorkingHour);
                employee.WorkingHour = wHour;
            }

            return(employee);
        }
예제 #11
0
 public List <CustomerNotification> GetSentItemsNotConsolidateNotification()
 {
     using (var db = new EntityContext())
     {
         var customers = customerUtility.GetAllCustomer(db);
         List <CustomerNotification> model = new List <CustomerNotification>();
         foreach (var customer in customers)
         {
             var ci = new CustomerNotification();
             ci.CustomerId          = customer.Id;
             ci.CustomerName        = customer.Name;
             ci.CustomerPhonenumber = customer.Phonenumber;
             ci.NumberOfItem        = itemsUtility.GetAllItem(db)
                                      .Where(i => i.Status.Id == 6 && i.Customer.Id == customer.Id &&
                                             !db.tbConsolidatedItems.Select(c => c.Items.Id).Contains(i.Id)).Count();
             model.Add(ci);
         }
         return(model);
     }
 }
예제 #12
0
        public async Task <IActionResult> Index(CustomerNotification model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string message  = model.description;
                    string title    = model.title;
                    var    storeobj = _customerRegistrationservices.GetAll().Where(x => x.isdeleted == false && x.deviceid != null).Select(x => x.deviceid).ToList();
                    //var storeobj =  _customerRegistrationservices.GetAll().Where(x => x.isdeleted == false && x.deviceid != null).Select(x => x.deviceid).ToList();

                    //  var storeobj = _customerRegistrationservices.GetAll().Where(x => x.isdeleted == false && x.deviceid != null).Select(x => x.deviceid).ToList();
                    //foreach (var item in storeobj)
                    //{
                    //    if (item.deviceid.Trim() == "" || item.deviceid == null)
                    //    { }
                    //    else
                    //    {


                    //        objfcmNotification.customerNotification(item.deviceid, message, "", title);

                    //    }



                    //}
                    objfcmNotification.BulkCustomerSendNotification(storeobj, message, "", title);
                    // objfcmNotification.BulkCustomerSendNotification(Enumerable.Repeat("test", 1010).ToList(), "tickerText", "contentTitle", "message");
                }
                catch { }

                TempData["success"] = "Notification Sent Successfully";
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View());
            }
        }
예제 #13
0
        public IActionResult Index()
        {
            var obj = new CustomerNotification();

            return(View(obj));
        }
        public async Task <int> Create(BusinessDTM businessDtm)
        {
            try
            {
                Business business = new Business();
                business.Name = businessDtm.Name;
                if (businessDtm.Country != null)
                {
                    business.Phone              = businessDtm.Phone;
                    business.Logo               = businessDtm.Logo;
                    business.Webpage            = businessDtm.Webpage;
                    business.Address            = businessDtm.Address;
                    business.City               = businessDtm.City;
                    business.State              = businessDtm.State;
                    business.ZipCode            = businessDtm.ZipCode;
                    business.RegistrationNumber = businessDtm.RegistrationNumber;
                    business.Country            = await Database.Countries.Get(businessDtm.Country.Id);

                    business.Currency = await Database.Currencies.Get(businessDtm.Currency.Id);

                    business.Time_zone = await Database.Time_zones.Get(businessDtm.Time_zone.Id);

                    business.Booking = businessDtm.Booking == null ? null : await Database.Bookings.Get(businessDtm.Booking.BusinessId);

                    business.Services  = null;
                    business.Clients   = null;
                    business.Employees = null;
                }
                await Database.Businesses.Create(business);

                User user = await Database.BllServices.GetUser(businessDtm.UserId);

                Booking booking = new Booking();
                booking.BusinessId = business.Id;
                await Database.Bookings.Create(booking);

                Employee employeeBoss = new Employee();
                employeeBoss.IsOwner  = true;
                employeeBoss.Business = business;
                employeeBoss.User     = user;
                await Database.Employees.Create(employeeBoss);

                WorkingHour wHourDtm = new WorkingHour();
                wHourDtm.Employee   = employeeBoss;
                wHourDtm.EmployeeId = employeeBoss.Id;
                await Database.WorkingHours.Create(wHourDtm);

                Permission perm = new Permission();
                perm.Employee   = employeeBoss;
                perm.EmployeeId = employeeBoss.Id;
                await Database.Permissions.Create(perm);

                CalendarSetting cSetting = new CalendarSetting();
                cSetting.Employee   = employeeBoss;
                cSetting.EmployeeId = employeeBoss.Id;
                await Database.CalendarSettings.Create(cSetting);

                CustomerNotification cNotif = new CustomerNotification();
                cNotif.Employee   = employeeBoss;
                cNotif.EmployeeId = employeeBoss.Id;
                await Database.CustomerNotifications.Create(cNotif);

                TeamNotification tNotif = new TeamNotification();
                tNotif.Employee   = employeeBoss;
                tNotif.EmployeeId = employeeBoss.Id;
                await Database.TeamNotifications.Create(tNotif);

                return(business.Id);
            }
            catch { return(0); }
        }
예제 #15
0
        public async Task <ApiResponseOfBoolean> MarkNotificationRead(CustomerNotification context)
        {
            var result = await AXClient.Instance.CustomerNotificationReadStateAsync(context);

            return(result);
        }