Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Navigational Workflows Unleashed in WWF/ASP.NET 3.5

, 21 Oct 2008 CPOL
Case-study on the internals of a Navigational Workflow engine for a fictional dating website called “World Wide Dating”.
datesite.zip
DateSite
App_Data
bin
database setup procedure
DateSite.csproj.user
Global.asax
images
complete.png
critical.png
logo2.png
warning.png
Profile.dbml
Profile.dbml.layout
Properties
Service References
NavigationWorkflow
bin
NavigationWorkflow.layout
Properties
Settings.settings
using System;
using System.Linq;

namespace DateSite
{
    /// <summary>
    /// Data layer for CRUD operations.
    /// </summary>
    public class Database
    {
        /// <summary>
        /// Returns the set of all corresponding pairs of Dating IDs and 
        /// navigational Workflow IDs from database.
        /// </summary>
        /// <returns></returns>
        public static object GetExistingProfiles()
        { 
            ProfileDataContext context = new ProfileDataContext();
            var workflows = from p in context.Profiles select new { p.DatingId, p.WorkflowId };
            var resultSet = workflows.ToList();
            context.Dispose();
            return resultSet;
        }

        /// <summary>
        /// Inserts the given profile into the database.
        /// </summary>
        /// <param name="profile"></param>
        public static void InsertProfile(Profile profile)
        {
            // insert the given profile into the database
            ProfileDataContext context = new ProfileDataContext();
            context.Profiles.InsertOnSubmit(profile);
            context.SubmitChanges();
            context.Dispose();
        }

        /// <summary>
        /// Takes the information in the given profile and updates the
        /// corresponding record in the database.
        /// </summary>
        /// <param name="profile"></param>
        public static void UpdateProfile(Profile profile)
        {
            // update the given profile
            ProfileDataContext context = new ProfileDataContext();
            context.Profiles.Attach(profile, true);
            context.SubmitChanges();
            context.Dispose();
        }

        /// <summary>
        /// Returns the profile object with the given dating id from the database.
        /// </summary>
        /// <param name="datingId"></param>
        /// <returns></returns>
        public static Profile SelectProfile(string datingId)
        {
            ProfileDataContext context = new ProfileDataContext();
            Profile profile = (from p in context.Profiles where p.DatingId.Equals(datingId) select p).First();
            context.Dispose();
            return profile;
        }

        /// <summary>
        /// Deletes the given dating id and workflow id records from the database.
        /// </summary>
        /// <param name="datingId"></param>
        /// <param name="workflowId"></param>
        public static void DeleteProfile(string datingId, Guid workflowId)
        {
            ProfileDataContext context = new ProfileDataContext();

            // delete the profile record
            var profile = from p in context.Profiles where p.DatingId.Equals(datingId) select p;
            context.Profiles.DeleteAllOnSubmit(profile);

            // delete the workflow record
            var workflow = from i in context.InstanceStates where i.uidInstanceID.Equals(workflowId) select i;
            context.InstanceStates.DeleteAllOnSubmit(workflow);

            // submit the changes and dispose of the context object
            context.SubmitChanges();
            context.Dispose();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Pero Matić
Software Developer (Senior) Plan A Software
United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 21 Oct 2008
Article Copyright 2008 by Pero Matić
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid