Example #1
0
        /*
         * public static void UpdateActivity(ProviderEDSC.ActivityDTRow drDetail, ProviderEDSC.ActivityContactDetailDTRow contactDetails, ProviderEDSC.ActivityGroupingDTRow drActGrouping, ProviderEDSC.ActivityScheduleDTDataTable dtActSchedule)
         * {
         *  ProviderDAC dac = new ProviderDAC();
         *
         *
         *  dac.UpdateActivities(drDetail);
         *  dac.UpdateActivityContactDetail(contactDetails);
         *  dac.DeleteActivitySchedules(drDetail.ID);
         *  foreach (var drActSchedule in dtActSchedule)
         *      dac.CreateActivitySchedule(drActSchedule);
         *  dac.UpdateActivityGrouping(drActGrouping);
         *
         *
         * }
         *
         * public static void UpdateActivity(ProviderEDSC.ActivityDTRow drDetail, ProviderEDSC.ActivityContactDetailDTRow contactDetails, ProviderEDSC.ActivityGroupingDTRow drActGrouping)
         * {
         *  ProviderDAC dac = new ProviderDAC();
         *
         *
         *  dac.UpdateActivities(drDetail);
         *  dac.UpdateActivityContactDetail(contactDetails);
         *  dac.DeleteActivitySchedules(drDetail.ID);
         *  dac.UpdateActivityGrouping(drActGrouping);
         * }
         *
         * public static void SaveActivity(ProviderEDSC.ActivityDTRow ActivityDetailDR, ProviderEDSC.ActivityContactDetailDTRow contactDetailsDR, ProviderEDSC.ActivityGroupingDTRow ActGroupingDR, ProviderEDSC.ActivityScheduleDTDataTable ActScheduleDT, out int activityID)
         * {
         *  ProviderDAC dac = new ProviderDAC();
         *
         *  using (TransactionScope trans = new TransactionScope())
         *  {
         *      activityID = 0;
         *      dac.CreateActivities(ActivityDetailDR, out activityID);
         *
         *      //Activity was Created, update all foreign key
         *      contactDetailsDR.ActivityID = activityID;
         *      ActGroupingDR.ActivityID = activityID;
         *
         *      //CreateContactDetails
         *      dac.CreateActivityContactDetail(contactDetailsDR);
         *
         *      //Create Schedule
         *      foreach (var ActScheduleDR in ActScheduleDT)
         *      {
         *          ActScheduleDR.ActivityID = activityID;
         *          dac.CreateActivitySchedule(ActScheduleDR);
         *      }
         *      //Create Grouping
         *      dac.CreateActivityGrouping(ActGroupingDR);
         *
         *      trans.Complete();
         *
         *  }
         * }
         *
         * public static void SaveActivity(ProviderEDSC.ActivityDTRow ActivityDetailDR, ProviderEDSC.ActivityContactDetailDTRow contactDetailsDR, ProviderEDSC.ActivityGroupingDTRow ActGroupingDR, out int activityID)
         * {
         *  ProviderDAC dac = new ProviderDAC();
         *
         *  using (TransactionScope trans = new TransactionScope())
         *  {
         *      activityID = 0;
         *      dac.CreateActivities(ActivityDetailDR, out activityID);
         *
         *      //Activity was Created, update all foreign key
         *      contactDetailsDR.ActivityID = activityID;
         *      ActGroupingDR.ActivityID = activityID;
         *
         *      //CreateContactDetails
         *      dac.CreateActivityContactDetail(contactDetailsDR);
         *
         *      //Create Grouping
         *      dac.CreateActivityGrouping(ActGroupingDR);
         *
         *      trans.Complete();
         *
         *  }
         * }
         */
        public static void SaveActivity(ProviderEDSC.ActivityDTRow ActivityDetailDR, ProviderEDSC.ActivityContactDetailDTRow contactDetailsDR, ProviderEDSC.ActivityGroupingDTRow ActGroupingDR, ProviderEDSC.ActivityScheduleDTDataTable ActScheduleDT, ProviderEDSC.ActivityImageDTRow ImageDetail, ProviderEDSC.ActivityImageDetailDTDataTable Images, out int activityID)
        {
            ProviderDAC dac = new ProviderDAC();

            using (TransactionScope trans = new TransactionScope())
            {
                activityID = 0;
                dac.CreateActivities(ActivityDetailDR, out activityID);

                //Activity was Created, Creat other
                contactDetailsDR.ActivityID = activityID;
                ActGroupingDR.ActivityID    = activityID;

                //CreateContactDetails
                dac.CreateActivityContactDetail(contactDetailsDR);

                if (ActScheduleDT != null)
                {
                    //Create Schedule
                    foreach (var ActScheduleDR in ActScheduleDT)
                    {
                        ActScheduleDR.ActivityID = activityID;
                        dac.CreateActivitySchedule(ActScheduleDR);
                    }
                }
                //Create Grouping
                dac.CreateActivityGrouping(ActGroupingDR);

                //Create Images
                if (ImageDetail.ImageAmount != 0)
                {
                    ImageDetail.ActivityID = activityID;
                    int imgDetID = 0;
                    dac.createActivityImageInformation(ImageDetail, out imgDetID);
                    int count = 1;
                    foreach (var drImageDetail in Images)
                    {
                        if (count == 1)
                        {
                            drImageDetail.isPrimaryImage = true;
                        }
                        drImageDetail.ActivityID      = activityID;
                        drImageDetail.ActivityImageID = imgDetID;
                        dac.CreateActivityImage(drImageDetail);
                        count++;
                    }
                }
                trans.Complete();
            }
        }