Saturday 31 December 2016

.asp webpage download file by iis

downloads take place on several client computers simultaneously, they can be paused and resume.


create .asp webform project

//default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="download._default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">

        <div>
            <asp:Button ID="Button1" runat="server" Text="download" OnClick="Button1_Click" />
        </div>

    </form>
</body>
</html>

------------------------------------------------------------------
//default.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace download
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Clear();
            Response.ClearHeaders();
            Response.ClearContent();
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + "office2010破解版.7z" + ";");
            Response.Flush();
            Response.TransmitFile(Server.MapPath("~/files/office2010破解版.7z"));
            Response.End();
        }
    }
}

-----------------------------------------------------------------------
//web.config

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2"/>

    <httpRuntime targetFramework="4.5.2" />

  </system.web>
  
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs"
        type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
        type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
    </compilers>
  </system.codedom>
</configuration>

create files folder under visual studio download project -> copy office2010破解版.7z into files folder for debugging

publish download project

open iis -> right click on download -> explore


create files folder -> copy office2010破解版.7z into files folder for client download


reference:

https://www.youtube.com/watch?v=h48Le6EB6Yc
http://ctrlcvprogrammer.blogspot.ca/2012/02/normal-0-false-false-false-en-us-x-none_18.html

Friday 30 December 2016

.asp upload to server by iis

client sends file


service receives file



create .asp web project

//default.asp

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="game_mine._default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">

        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    
        <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Always" runat="server">
            <ContentTemplate>
                <asp:FileUpload ID="FileUpload1" runat="server" />
                <asp:Button ID="UploadButton" runat="server" Text="Upload Selected File" OnClick="UploadButton_Click" />
                <asp:Label ID="UploadDetails" runat="server" Text=""></asp:Label>
            </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger ControlID="UploadButton" />
            </Triggers>
        </asp:UpdatePanel>

    </form>
</body>
</html>

------------------------------------------------------------------------------
//default.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace game_mine
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void UploadButton_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile == false)
            {
                UploadDetails.Text = "Please first select a file to upload...";
            }
            else
            {
                string FileName = FileUpload1.FileName;
                UploadDetails.Text = string.Format(
                        @"Uploaded file: {0}<br />
              File size (in bytes): {1:N0}<br />
              Content-type: {2}",
                          FileName,
                          FileUpload1.FileBytes.Length,
                          FileUpload1.PostedFile.ContentType);

                // Save the file
               // for visual studio debug upload folder address is the project address
               //C:\Users\xxxxxx\Documents\Visual Studio 2015\Projects\game_mine\game_mine

                string filePath = Server.MapPath("~/upload/" + FileUpload1.FileName);
                FileUpload1.SaveAs(filePath);
            }
        }
    }
}

add upload folder in project directory for debugging


//web.config

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2"/>

    <!--maxRequestLength for file transfer 1MB = 1024  5MB-->
    <httpRuntime targetFramework="4.5.2" maxRequestLength="5120"/>
 
    <customErrors mode="Off"></customErrors>
 
  </system.web>

  <system.webServer>
    
    <security>
      <requestFiltering>
        
        <!--maxAllowedContentLength (maximum number of bytes in an IIS Request) 1KB = 1024  10MB-->
        <requestLimits maxAllowedContentLength="10485760" />
        
      </requestFiltering>           
    </security>
  </system.webServer>

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs"
        type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
        type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
    </compilers>
  </system.codedom>
</configuration>


open iis->right click on website->explore

make a new upload folder which is at same iis map path(~/upload) for receiving client files

publish project

try to send file larger than -maxRequestLength that server is set to receive (5Mb) on client side


reference:

http://stackoverflow.com/questions/9682737/fileupload-hasfile-is-always-false
http://asp.net-tutorials.com/controls/file-upload-control/
http://stackoverflow.com/questions/1989334/how-do-i-enable-upload-of-large-files-in-classic-asp-on-iis-7
http://stackoverflow.com/questions/3853767/maximum-request-length-exceeded

Thursday 29 December 2016

Access localhost from the internet ngrok

https://ngrok.com/

install -> start

type: ngrok http 80 -> copy address paste into exployer to replace localhost

external web user can access local computer service






close ngrok -> address expire





Thursday 22 December 2016

How to deploy asp.net web application

install iis
https://www.microsoft.com/en-ca/download/details.aspx?id=48264

Control Panel\Programs\Programs and Features -> turn windows features on or off


Control Panel\System and Security\Administrative Tools -> internet information service manager

Application Pools -> add application pools

right click newly created .net test application pool  -> advanced setting -> change identity to local system.


open SQL Server Management Studio -> database -> my database -> security -> right click user -> new user -> gerneral ->change user name, log in name




membership -> select datareader, datawritter


run visual as administrator -> create wcf service project


//iserverce1.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace service_1
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {

        [OperationContract]
        List<dto> GetData();

     
    }
}

------------------------------------------------------------
//service1.svc

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace service_1
{
    public class Service1 : IService1
    {
        public List<dto> GetData()
        {
            var db = new CTTIEntities();

            var data = db.Instructors.Select(x => new dto
            {
                FirstName = x.FirstName,
                LastName = x.LastName,
                Id = x.Id
            }).ToList();

            return data;
        }
    }
}

--------------------------------------------------------
//dto.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;

namespace service_1
{
    [DataContract]
    public class dto
    {
        [DataMember]
        public int Id { get; set; }
        [DataMember]
        public string FirstName { get; set; }
        [DataMember]
        public string LastName { get; set; }
    }
}

-------------------------------------------------------------

build application -> right click on project -> publish -> profile -> custom -> enter any name



connection -> web deploy

setting -> browse database -> publish

close visual studio -> open iis manager -> right click on newly created service_2 -> advanced setting

change application pool to newly created .net test

click browse on the right side

click service1.svc

click top link, should see the service method

run ipconfig in command window to get ip address for current computer/server -> 192.168.1.74

on second computer/cloud type 192.168.1.74/service_2/Service1.svc on internet exployer
should see the same service page

on second computer run visual studio as administrator -> create web project

right click on reference -> add service reference -> type in service address -> go -> iservice1

on default.aspx configer objectdatasouce 

select method

run application, should see table displayed

right click on project -> publish

on iis manager, should see the web deployment

run ipconfig -> second computer ip -> 192.168.1.70

on third computer/client type 192.168.1.70/instructor on internet explorer 


server -> cloud -> client


reference:
https://www.youtube.com/watch?v=88YtB6U9NrY
https://www.asp.net/mvc/overview/deployment/visual-studio-web-deployment/deploying-to-iis
https://www.youtube.com/watch?v=18-zatWd68s
http://stackoverflow.com/questions/4388066/the-page-you-are-requesting-cannot-be-served-because-of-the-extension-configura

Wednesday 14 December 2016

.asp final

Final Assignment – Inland Marina 

Background Information 

Inland Marina Ltd., a company operating a marina facility at Inland Lake, Arizona, has asked you to build an application that will handle their leasing services. Inland Lake is one of the largest lakes in the southern US and offers a year-round boating paradise. The company is the largest marina on Inland Lake and has the capacity to house 150 boats with plans to add another dock, bringing their total capacity to 200 boats. In addition, they are concluding negotiations to purchase a large marina facility in San Diego. With recent increases in tourism, the current practice of taking telephone bookings from customers is becoming too much to handle. Automating the process of leasing a slip, which is a parking spot for a boat, will enable office staff to concentrate on other duties. 

In discussions with management, it has been determined that the best solution would be to develop a web-enabled application that allows customers the ability to search for available slips on their docks at both Inland Lake and San Diego. Once customers are registered in the system, they will be allowed to register one or more boats, select a slip and lease the slip on a daily, weekly, monthly or yearly basis. Rates will be established for each of the lease types. 

The company decided to use a web service after determining that the existing desktop application used by administration staff could use the same database that the web application accessed. The web service should be able to handle all database activity for both the desktop and web applications and offer remote functionality through the service’s web methods. 

A corporate banner will be supplied as a .jpg file. It will measure 800 x 100 px. 

Your mission is to create an application that meets the customer’s needs as described above and the requirements as listed below. 
 Web Application Requirements 

1. A Home page: Welcomes the user to the site and displays a brief outline of the company. This is the start-up page for the web application and is available to the general public. Text for the page is provided at the end of this document. 2. A page that shows available slip by location and dock. This is a browsing page available to the general public. 3. A Contact Us page that contains company locations, addresses and phone numbers. This is available to the general public. 4. A registration page that is available to the general public and allows users to register online. 


SAIT Polytechnic – School of Information and Communication Technologies 2 
5. A login page that allows registered users to enter their security information for purposes of authentication. The type of authentication is Forms Authentication. 6. A lease slip page: Once authenticated, users are taken to the leasing page where current lease information is displayed and where new leases can be created. Users can lease one or more slips on any dock at any location. If users not already logged in, they are automatically redirected to the login page. 7. A register boat page where authenticated users can register one or more boats as well as update their boat information. 8. An update registration page where users can update their personal information and their authentication data (user name and password). 


Web Services Requirements: 

The last page of the assignment instructions contains a database diagram. It shows contains Location, Dock, Slip, and Lease Type data that has already been entered (and one test record in other four tables). The web application will use database functionality that is provided through a number of remote web methods. These methods will include the following database activity. We have provided check boxes so that you can use this to check your work. 

 AddCustomer: The first name, last name, phone number and city will be passed into this method and the record inserted. A string result is returned containing the newly created identity id or an error message.  UpdateCustomer: The same information along with id is passed in and the customer record updated by the id number. A string result is returned containing “Success” or an error message.  GetCustomerRecordById: A customer record is returned when the id value is passed in.  GetAllCustomers: A DataSet or Array containing all customers is returned.  AddBoat: The boat registration number, manufacturer name, model year, length and id of the owner will be passed in and the record inserted. A string result is returned containing “Success” or an error message.  UpdateBoat: An existing boat record is updated when all information including boat id is passed in. A string result is returned containing “Success” or an error message.  GetBoatsByCustomerId: A DataSet or Array containing all boats registered by a specific customer.  AddAuthorize: The auth user name, password and customer id are passed into the method and a new record is inserted. A string result is returned containing “Success” or an error message.  UpdateAuthorize: This method updates an existing authorize record. A string result is returned containing “Success” or an error message.  AddLease: Lease start date, end date, slip id, customer id and lease type id will be passed into the method. A record will be inserted and a string result is returned containing “Success” or an error message.  GetLocations:  a DataSet or Array of all locations is returned. 


SAIT Polytechnic – School of Information and Communication Technologies 3 
 GetDocks: A DataSet or Array of all locations is returned.  GetAvailableSlipsByDockId: A DataSet or Array of all available slips is returned when a dock id is passed in.  GetLeaseTypes: A DataSet or Array of all lease types is returned.  Authenticate: The user name and password are passed into the method; null is returned if there is no record or else the Authorize object containing the nested Customer object is returned. 

Please note that the id field in all tables is an identity field that automatically increments the id value for each insert. If you need the value, it should be returned in the string (probably just customer records). 
 Submission: The assignment is due the last day of the course unless otherwise noted. Both projects have to be supplied. Use your last name in the solution file you submit as a zipped file. Marks will be awarded for design of the web application, the code you write (follows good coding practices, naming standards, comments, white space, etc.), and how well the application runs. See the grading criteria. Please use master pages and content pages, user controls where appropriate, navigation menu, and site map controls. 


//site master.aspx

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="presentation.SiteMaster" %>

<!DOCTYPE html>

<html lang="en">
<head runat="server">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><%: Page.Title %> - My ASP.NET Application</title>

    <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
    </asp:PlaceHolder>
    <webopt:bundlereference runat="server" path="~/Content/css" />
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />

</head>
<body>
    <form runat="server">
        <asp:ScriptManager runat="server">
            <Scripts>
                <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
                <%--Framework Scripts--%>
                <asp:ScriptReference Name="MsAjaxBundle" />
                <asp:ScriptReference Name="jquery" />
                <asp:ScriptReference Name="bootstrap" />
                <asp:ScriptReference Name="respond" />
                <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
                <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
                <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
                <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
                <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
                <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
                <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
                <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
                <asp:ScriptReference Name="WebFormsBundle" />
                <%--Site Scripts--%>
            </Scripts>
        </asp:ScriptManager>

        <div class="navbar navbar-inverse navbar-fixed-top">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" runat="server" href="~/">
                        <img runat="server" src="~/image/icon.png" style="width: 200px" />
                    </a>
                </div>
                <div class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                        <li><a runat="server" href="~/">Home</a></li>
                        <li><a runat="server" href="~/available slip">Available Slip</a></li>
                        <li><a runat="server" href="~/authorized user/lease slip">Lease Slip</a></li>
                        <li><a runat="server" href="~/authorized user/register boat">Register Boat</a></li>
                        <li><a runat="server" href="~/Contact">Contact</a></li>
                    </ul>

                    <ul class="nav navbar-nav navbar-right">
                        <li class="dropdown">
                            <a runat="server" href="#" data-toggle="dropdown" class="dropdown-toggle">Register<b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu">
                                <li><a runat="server" href="~/new registration">New</a></li>
                                <li><a runat="server" href="~/update registration">Update</a></li>
                            </ul>
                        </li>
                        <li>
                            <asp:LinkButton ID="ux_log_in_out" runat="server" OnClick="ux_log_in_out_Click">Log in</asp:LinkButton></li>
                    </ul>
                  
                </div>
            </div>
        </div>
        <div class="container body-content">
            <asp:ContentPlaceHolder ID="MainContent" runat="server">
            </asp:ContentPlaceHolder>
            <hr />
            <footer>
                <p>&copy; <%: DateTime.Now.Year %> - My ASP.NET Application</p>
            </footer>
        </div>
    </form>
</body>
</html>

------------------------------------------------------------

//site master.cs

using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Security.Principal;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.AspNet.Identity;

namespace presentation
{
    public partial class SiteMaster : MasterPage
    {
        private const string AntiXsrfTokenKey = "__AntiXsrfToken";
        private const string AntiXsrfUserNameKey = "__AntiXsrfUserName";
        private string _antiXsrfTokenValue;

        protected void Page_Init(object sender, EventArgs e)
        {
            // The code below helps to protect against XSRF attacks
            var requestCookie = Request.Cookies[AntiXsrfTokenKey];
            Guid requestCookieGuidValue;
            if (requestCookie != null && Guid.TryParse(requestCookie.Value, out requestCookieGuidValue))
            {
                // Use the Anti-XSRF token from the cookie
                _antiXsrfTokenValue = requestCookie.Value;
                Page.ViewStateUserKey = _antiXsrfTokenValue;
            }
            else
            {
                // Generate a new Anti-XSRF token and save to the cookie
                _antiXsrfTokenValue = Guid.NewGuid().ToString("N");
                Page.ViewStateUserKey = _antiXsrfTokenValue;

                var responseCookie = new HttpCookie(AntiXsrfTokenKey)
                {
                    HttpOnly = true,
                    Value = _antiXsrfTokenValue
                };
                if (FormsAuthentication.RequireSSL && Request.IsSecureConnection)
                {
                    responseCookie.Secure = true;
                }
                Response.Cookies.Set(responseCookie);
            }

            Page.PreLoad += master_Page_PreLoad;
        }

        protected void master_Page_PreLoad(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Set Anti-XSRF token
                ViewState[AntiXsrfTokenKey] = Page.ViewStateUserKey;
                ViewState[AntiXsrfUserNameKey] = Context.User.Identity.Name ?? String.Empty;
            }
            else
            {
                // Validate the Anti-XSRF token
                if ((string)ViewState[AntiXsrfTokenKey] != _antiXsrfTokenValue
                    || (string)ViewState[AntiXsrfUserNameKey] != (Context.User.Identity.Name ?? String.Empty))
                {
                    throw new InvalidOperationException("Validation of Anti-XSRF token failed.");
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.User.Identity.IsAuthenticated)
            {
                ux_log_in_out.Text = "Log out " + Page.User.Identity.Name.Split(' ')[0]+" "+ Page.User.Identity.Name.Split(' ')[1];
            }
            else
            {
                ux_log_in_out.Text = "Log in";
                ux_log_in_out.PostBackUrl = "~/log in.aspx";
            }
        }

        protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e)
        {
            Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
        }

        protected void ux_log_in_out_Click(object sender, EventArgs e)
        {
            if (Page.User.Identity.IsAuthenticated)
            {
                FormsAuthentication.SignOut();
                Session.Clear();
                Session.Abandon();
                
                ux_log_in_out.Text = "Log in";
                Response.Redirect("~/Default.aspx");
            }
        }

        
    }

}

-----------------------------------------------------------------

//presentation/web.config

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-presentation-20161210082752.mdf;Initial Catalog=aspnet-presentation-20161210082752;Integrated Security=True"
      providerName="System.Data.SqlClient" />
    <add name="InlandMarinaEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost;initial catalog=InlandMarina;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <system.web>


    <authentication mode="Forms">
      <forms loginUrl="~/log in.aspx"/>
    </authentication>


    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Optimization" />
        <add namespace="Microsoft.AspNet.Identity" />
      </namespaces>
      <controls>
        <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
      </controls>
    </pages>
    <membership>
      <providers>
        <!--
     ASP.NET Membership is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
        -->
        <clear />
      </providers>
    </membership>
    <profile>
      <providers>
        <!--
     ASP.NET Membership Profile is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
        -->
        <clear />
      </providers>
    </profile>
    <roleManager>
      <!--
       ASP.NET Membership Role is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
        -->
      <providers>
        <clear />
      </providers>
    </roleManager>
    <!--
            If you are deploying to a cloud environment that has multiple web server instances,
            you should change session state mode from "InProc" to "Custom". In addition,
            change the connection string named "DefaultConnection" to connect to an instance
            of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
      -->
    <sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
      </providers>
    </sessionState>
  </system.web>
  <!--<system.webServer>
    <modules>
      <remove name="FormsAuthentication" />
    </modules>
  </system.webServer>-->
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" culture="neutral" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" culture="neutral" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_interface1" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:60401/method.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_interface1" contract="ServiceReference1.interface1"
        name="BasicHttpBinding_interface1" />
    </client>
  </system.serviceModel>
</configuration>

----------------------------------------------------------

log in.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="log in.aspx.cs" Inherits="presentation.log_in" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <table>
        <tr>
            <td>
                <asp:Label ID="Label1" runat="server" Text="user name"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_user_name" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label2" runat="server" Text="password"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_password" runat="server" TextMode="Password"></asp:TextBox></td>
        </tr> 
        <tr>
            <td>
                <br />
            </td>
        </tr>      
        <tr>
            <td colspan="2" style="text-align: center">
                <asp:Button ID="Button1" runat="server" Text="sign in" style="width:100%" OnClick="Button1_Click" /></td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="sign_in_error" runat="server" Text=""></asp:Label>
            </td>
        </tr>  
    </table>

</asp:Content>

----------------------------------------------------------

log in.cs

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace presentation
{
    public partial class log_in : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            sign_in_error.Text = "";
            string user_name = Request.QueryString["user_name"];

            if(user_name!=null)
            {
                ux_user_name.Text = user_name;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            var proxy = new ServiceReference1.interface1Client();

            var _authentication = proxy.Authenticate(ux_user_name.Text, ux_password.Text);

            if (_authentication != null)
            {
                var _customer = proxy.GetCustomerRecordById(_authentication.CustomerID);

                var full_name = _customer.FirstName + " " + _customer.LastName + " " + _authentication.ID + " " + _customer.ID;

                FormsAuthentication.RedirectFromLoginPage(full_name, false);
            }
            else
            {
                sign_in_error.Text = "invalid sign in";
                sign_in_error.ForeColor = Color.Red;
            }
        }
    }
}

-------------------------------------------

//presentation/authorized user/web.config

<?xml version="1.0"?>
<configuration>

  <system.web>
    <authorization>
      <deny users="?"/>
    </authorization>
  </system.web>

</configuration>

--------------------------------------------------------



<%@ Page Title="Available Slip" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="available slip.aspx.cs" Inherits="presentation.available_slip" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <h2 style="color: darkturquoise"><%: Title %>.</h2>

    <asp:UpdatePanel ID="UpdatePanel3" runat="server">
        <ContentTemplate>

            <div>
                <table>
                    <tr>
                        <td style="vertical-align: top">
                            <table>
                                <tr>
                                    <td style="width: 246px">
                                        <h3 style="color: darkturquoise">1. Select Location</h3>
                                        <asp:GridView ID="ux_location" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="ObjectDataSource1" ForeColor="#333333" GridLines="None" DataKeyNames="ID">
                                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                            <Columns>
                                                <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
                                                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                                <asp:ButtonField ButtonType="Button" CommandName="Select" Text="select" />
                                            </Columns>
                                            <EditRowStyle BackColor="#999999" />
                                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                            <SortedAscendingCellStyle BackColor="#E9E7E2" />
                                            <SortedAscendingHeaderStyle BackColor="#506C8C" />
                                            <SortedDescendingCellStyle BackColor="#FFFDF8" />
                                            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                                        </asp:GridView>
                                        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetLocations" TypeName="presentation.ServiceReference1.interface1Client"></asp:ObjectDataSource>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td style="vertical-align: top">
                            <table>
                                <tr>
                                    <td>
                                        <h3 style="color: darkturquoise">2. Select Dock</h3>
                                        <asp:GridView ID="ux_dock" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="ObjectDataSource2" ForeColor="#333333" GridLines="None" DataKeyNames="ID">
                                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                            <Columns>
                                                <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
                                                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                                <asp:CheckBoxField DataField="ElectricalService" HeaderText="ElectricalService" SortExpression="ElectricalService" />
                                                <asp:CheckBoxField DataField="WaterService" HeaderText="WaterService" SortExpression="WaterService" />
                                                <asp:ButtonField ButtonType="Button" CommandName="Select" Text="select" />
                                            </Columns>
                                            <EditRowStyle BackColor="#999999" />
                                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                            <SortedAscendingCellStyle BackColor="#E9E7E2" />
                                            <SortedAscendingHeaderStyle BackColor="#506C8C" />
                                            <SortedDescendingCellStyle BackColor="#FFFDF8" />
                                            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                                        </asp:GridView>
                                        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetDocks" TypeName="presentation.ServiceReference1.interface1Client">
                                            <SelectParameters>
                                                <asp:ControlParameter ControlID="ux_location" Name="_location_id" PropertyName="SelectedValue" Type="String" />
                                            </SelectParameters>
                                        </asp:ObjectDataSource>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
            <div>
                <table>
                    <tr>
                        <td>
                            <br />
                            <br />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h3 style="color: darkturquoise">3. Available Slip</h3>
                            <asp:GridView ID="available_slip_table" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="ObjectDataSource3" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="available_slip_table_SelectedIndexChanged1">
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                <Columns>
                                    <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
                                    <asp:BoundField DataField="DockID" HeaderText="DockID" SortExpression="DockID" />
                                    <asp:BoundField DataField="Length" HeaderText="Length" SortExpression="Length" />
                                    <asp:BoundField DataField="Width" HeaderText="Width" SortExpression="Width" />
                                    <asp:BoundField DataField="LeaseStart" DataFormatString="{0:d}" HeaderText="LeaseStartDate    " SortExpression="LeaseStart" />
                                    <asp:BoundField DataField="LeaseEnd" DataFormatString="{0:d}" HeaderText="LeaseEndDate    " SortExpression="LeaseEnd" />
                                    <asp:ButtonField ButtonType="Button" CommandName="Select" Text="Select" />
                                </Columns>
                                <EditRowStyle BackColor="#999999" />
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                <SortedAscendingCellStyle BackColor="#E9E7E2" />
                                <SortedAscendingHeaderStyle BackColor="#506C8C" />
                                <SortedDescendingCellStyle BackColor="#FFFDF8" />
                                <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                            </asp:GridView>
                            <asp:ObjectDataSource ID="ObjectDataSource3" runat="server" SelectMethod="GetAvailableSlipByDockId" TypeName="presentation.ServiceReference1.interface1Client">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="ux_dock" Name="_dock_id" PropertyName="SelectedValue" Type="Int32" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                        </td>
                    </tr>
                </table>
            </div>

        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>

-----------------------------------------------------

//log in.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace presentation
{
    public partial class available_slip : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void available_slip_table_SelectedIndexChanged1(object sender, EventArgs e)
        {
            string url = string.Format("~/authorized user/lease slip.aspx?Slip_id={0}&Start_date={1}&End_date={2}", 
                available_slip_table.SelectedRow.Cells[0].Text,
                available_slip_table.SelectedRow.Cells[4].Text,
                available_slip_table.SelectedRow.Cells[5].Text);

            Response.Redirect(url);
        }
    }
}




//new registration.aspx

<%@ Page Title="New Registration" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="new registration.aspx.cs" Inherits="presentation.new_registration" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <h2 style ="color:darkturquoise"><%: Title %>.</h2>

     <table>
          <tr>
            <td>
                <asp:Label ID="Label3" runat="server" Text="first name"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_first_name" runat="server"></asp:TextBox></td>
        </tr>
          <tr>
            <td>
                <asp:Label ID="Label4" runat="server" Text="last name"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_last_name" runat="server"></asp:TextBox></td>
        </tr>
          <tr>
            <td>
                <asp:Label ID="Label5" runat="server" Text="phone"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_phone" runat="server"></asp:TextBox></td>
        </tr>
          <tr>
            <td>
                <asp:Label ID="Label6" runat="server" Text="city"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_city" runat="server"></asp:TextBox></td>
        </tr>
         <tr>
            <td>
                <br />
                 <br />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label1" runat="server" Text="user name"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_user_name" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label2" runat="server" Text="password"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_password" runat="server" TextMode="Password"></asp:TextBox></td>
        </tr> 
        <tr>
            <td>
                <br />
            </td>
        </tr>      
        <tr>
            <td colspan="2" style="text-align: center">
                <asp:Button ID="Button1" runat="server" Text="register" style="width:100%" OnClick="Button1_Click" /></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center">
                <asp:Label ID="status" runat="server" Text=""></asp:Label>
            </td>
        </tr>  
         
    </table>

</asp:Content>

-----------------------------------------------------

//new registration.cs

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace presentation
{
    public partial class new_registration : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            status.ForeColor = Color.Red;

            if (ux_city.Text=="" || ux_first_name.Text =="" || ux_last_name.Text=="" || 
                ux_password.Text=="" || ux_phone.Text=="" ||ux_user_name.Text=="")
            {
                status.Text = "information incomplete";               
            }
            else
            {
                var proxy = new ServiceReference1.interface1Client();

                if (proxy.AddAuthorize(ux_user_name.Text, "", "") != "User name exist")
                {
                    status.Text = proxy.AddCustomer(ux_first_name.Text, ux_last_name.Text, ux_phone.Text, ux_city.Text);

                    if (status.Text != "customer exists")
                    {
                        var _id = status.Text;

                        status.Text = proxy.AddAuthorize(ux_user_name.Text, ux_password.Text, _id);
                    }
                }
                else
                {
                    status.Text = "User name exist";
                }
            }

            string url = Request.QueryString["ReturnUrl"];

            if (url != null)
            {
                Response.Redirect(url);
            }
        }
    }
}



<%@ Page Title="Update Registration" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="update registration.aspx.cs" Inherits="presentation.update_registration" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <h2 style ="color:darkturquoise"><%: Title %>.</h2>

    <div>
      <table id ="Table1" runat ="server">
           <tr>
               <td>
                   <table >
                       <tr>
                           <td style="width: 434px">
                               <h3 style ="color:darkturquoise">I have User Name</h3>
                           </td>
                       </tr>
                       <tr>
                           <td style="width: 434px">
                               <asp:Button ID="Button1" runat="server" class="btn btn-primary btn-lg" Text="Log In >>" OnClick="Button1_Click"  />
                           </td>
                       </tr>
                       <tr>
                           <td style="width: 434px">
                               <br/>
                           </td>
                       </tr>
                        <tr>
                           <td style="width: 434px">
                               <h3 style ="color:darkturquoise">I don't have User Name</h3>
                           </td>
                       </tr>
                       <tr>
                           <td style="width: 434px">
                               <asp:Button ID="Button2" runat="server" class="btn btn-primary btn-lg" Text="Register >>" OnClick="Button2_Click"   />
                           </td>
                       </tr>
                   </table>
               </td>
               <td style="vertical-align:top">
                   <table >
                       <tr>
                           <td >
                               <h3 style ="color:darkturquoise">Forgot User Name?</h3>
                           </td>
                       </tr>
                       <tr>
                           <td >
                               <asp:GridView ID="customer_list" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="ObjectDataSource1" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="customer_list_SelectedIndexChanged1">
                                   <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                   <Columns>
                                       <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
                                       <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
                                       <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
                                       <asp:ButtonField CommandName="Select" Text="select" />
                                   </Columns>
                                   <EditRowStyle BackColor="#999999" />
                                   <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                   <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                   <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                   <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                   <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                   <SortedAscendingCellStyle BackColor="#E9E7E2" />
                                   <SortedAscendingHeaderStyle BackColor="#506C8C" />
                                   <SortedDescendingCellStyle BackColor="#FFFDF8" />
                                   <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                               </asp:GridView>
                               <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetAllCustomers" TypeName="presentation.ServiceReference1.interface1Client"></asp:ObjectDataSource>
                           </td>
                       </tr>
                   </table>
               </td>
           </tr>         
    </table>
</div>

    <div>
        <table id ="Table2" runat ="server">
          <tr>
            <td>
                <asp:Label ID="Label3" runat="server" Text="first name"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_first_name" runat="server"></asp:TextBox></td>
        </tr>
          <tr>
            <td>
                <asp:Label ID="Label4" runat="server" Text="last name"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_last_name" runat="server"></asp:TextBox></td>
        </tr>
          <tr>
            <td>
                <asp:Label ID="Label5" runat="server" Text="phone"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_phone" runat="server"></asp:TextBox></td>
        </tr>
          <tr>
            <td>
                <asp:Label ID="Label6" runat="server" Text="city"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_city" runat="server"></asp:TextBox></td>
        </tr>
         <tr>
            <td>
                <br />
                 <br />
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label1" runat="server" Text="user name"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_user_name" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label2" runat="server" Text="password"></asp:Label></td>
            <td>
                <asp:TextBox ID="ux_password" runat="server" TextMode="Password"></asp:TextBox></td>
        </tr> 
        <tr>
            <td>
                <br />
            </td>
        </tr>      
        <tr>
            <td colspan="2" style="text-align: center">
                <asp:Button ID="Button3" runat="server" Text="update" style="width:100%" OnClick="Button3_Click"  /></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center">
                <asp:Label ID="status" runat="server" Text=""></asp:Label>
            </td>
        </tr>  
         
    </table>
    </div>


</asp:Content>

-----------------------------------------------

//update registration.cs

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace presentation
{
    public partial class update_registration : System.Web.UI.Page
    {
        private int authorize_id { get { return Convert.ToInt32(Page.User.Identity.Name.Split(' ')[2]); }  }
        private string customer_id { get { return Page.User.Identity.Name.Split(' ')[3]; } }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Page.User.Identity.IsAuthenticated)
                {
                    Table1.Visible = false;
                    Table2.Visible = true;

                    var proxy = new ServiceReference1.interface1Client();

                    ux_user_name.Text = proxy.UpdateAuthorize(0, "", "", customer_id);

                    var customer = proxy.GetCustomerRecordById(Convert.ToInt32(customer_id));

                    ux_first_name.Text = customer.FirstName;
                    ux_last_name.Text = customer.LastName;
                    ux_city.Text = customer.City;
                    ux_phone.Text = customer.Phone;
                }
                else
                {
                    Table1.Visible = true;
                    Table2.Visible = false;
                }
            }
        }       

        //log in with user name
        protected void customer_list_SelectedIndexChanged1(object sender, EventArgs e)
        {
            var proxy = new ServiceReference1.interface1Client();

            string _id = customer_list.SelectedRow.Cells[0].Text;
            string user_name = proxy.UpdateAuthorize(0, "", "", _id);

            string url = string.Format("~/log in.aspx?user_name={0}&ReturnUrl={1}", user_name,"~/update registration");

            Response.Redirect(url);
        }

        //log in
        protected void Button1_Click(object sender, EventArgs e)
        {
            string url = string.Format("~/log in.aspx?&ReturnUrl={0}", "~/update registration");

            Response.Redirect(url);
        }

        //register
        protected void Button2_Click(object sender, EventArgs e)
        {
            string url = string.Format("~/new registration.aspx?&ReturnUrl={0}", "~/update registration");

            Response.Redirect(url);
        }

        //update
        protected void Button3_Click(object sender, EventArgs e)
        {
            status.ForeColor = Color.Red;

            if (ux_city.Text == "" || ux_first_name.Text == "" || ux_last_name.Text == "" ||
                ux_password.Text == "" || ux_phone.Text == "" || ux_user_name.Text == "")
            {
                status.Text = "information incomplete";
            }
            else
            {
                var proxy = new ServiceReference1.interface1Client();

                string authorize_update = proxy.UpdateAuthorize(authorize_id, ux_user_name.Text, ux_password.Text, customer_id);

                string customer_update = proxy.UpdateCustomer(Convert.ToInt32( customer_id), ux_first_name.Text, ux_last_name.Text, ux_phone.Text, ux_city.Text);

                if(authorize_update=="success" && customer_update=="success")
                {
                    status.Text = "update success";
                }
            }
        }
    }
}




<%@ Page Title="Lease Slip" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="lease slip.aspx.cs" Inherits="presentation.authorized_user.lease_slip" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <h2 style="color: darkturquoise"><%: Title %>.</h2>

    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>

            <table>
                <tr>
                    <td style="vertical-align: top">
                        <table>
                            <tr>
                                <td style="width: 317px">
                                    <h3 style="color: darkturquoise">Select from available Slips</h3>
                                    <asp:Button ID="Button1" runat="server" class="btn btn-primary btn-lg" Text="Select a Slip >>" OnClick="Button1_Click" />
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 317px">
                                    <br />
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 317px">
                                    <h3 style="color: darkturquoise">Select lease date</h3>
                                    <asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged"></asp:Calendar>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 317px">
                                    <h3 style="color: darkturquoise">Select return date</h3>
                                    <asp:Calendar ID="Calendar2" runat="server" OnSelectionChanged="Calendar2_SelectionChanged"></asp:Calendar>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td style="vertical-align: top">
                        <table>
                            <tr>
                                <td colspan="2">
                                    <h3 style="color: darkturquoise">Select lease type</h3>
                                    <asp:GridView ID="ux_lease_type" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="ObjectDataSource1" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="ux_lease_type_SelectedIndexChanged">
                                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                        <Columns>
                                            <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
                                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                                            <asp:BoundField DataField="StandardRateAmount" HeaderText="Rate" SortExpression="StandardRateAmount" />
                                            <asp:ButtonField ButtonType="Button" CommandName="Select" Text="Select" />
                                        </Columns>
                                        <EditRowStyle BackColor="#999999" />
                                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                        <SortedAscendingCellStyle BackColor="#E9E7E2" />
                                        <SortedAscendingHeaderStyle BackColor="#506C8C" />
                                        <SortedDescendingCellStyle BackColor="#FFFDF8" />
                                        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                                    </asp:GridView>
                                    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetLeaseTypes" TypeName="presentation.ServiceReference1.interface1Client"></asp:ObjectDataSource>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <br />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="Label1" runat="server" Text="Request Start Date"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="ux_start_date" runat="server" Enabled="False"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="Label7" runat="server" Text="Lease Begin"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="lease_begin" runat="server" Enabled="False"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <br />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="Label2" runat="server" Text="Request End Date"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="ux_end_date" runat="server" Enabled="False"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="Label8" runat="server" Text="Lease End"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="lease_end" runat="server" Enabled="False"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <br />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="Label3" runat="server" Text="Slip Id"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="ux_slip_id" runat="server" Enabled="False"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="Label4" runat="server" Text="Customer Id"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="ux_customer_id" runat="server" Enabled="False"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="Label5" runat="server" Text="Lease Type"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="ux_lease_type_id" runat="server" Enabled="False"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <br />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="text-align: center">
                                    <asp:Button ID="Button3" runat="server" class="btn btn-primary btn-lg" Text="Price" Style="width: 100%" OnClick="Button3_Click" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="Label6" runat="server" Text="$$$"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="Price" runat="server" Enabled="False"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="text-align: center">
                                    <asp:Label ID="calculation_status" runat="server" Text="" ForeColor="#FF3300"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <br />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="text-align: center">
                                    <asp:Button ID="Button2" runat="server" class="btn btn-primary btn-lg" Text="Lease this Slip" Style="width: 100%" OnClick="Button2_Click" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="text-align: center">
                                    <asp:Label ID="status" runat="server" Text="" ForeColor="#FF3300"></asp:Label>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>

            </table>

        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>

------------------------------------------------------------

//lease.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace presentation.authorized_user
{
    public partial class lease_slip : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                ux_customer_id.Text = Page.User.Identity.Name.Split(' ')[3];

                string _slip_id  = Request.QueryString["Slip_id"];

                lease_begin.Text = Request.QueryString["Start_date"];
                lease_end.Text = Request.QueryString["End_date"];

                if (_slip_id==null)
                {
                    status.Text = "Slip is not selected";
                }
                else
                {
                    ux_slip_id.Text = _slip_id;
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/available slip");
        }

        protected void Calendar2_SelectionChanged(object sender, EventArgs e)
        {
            ux_end_date.Text = Calendar2.SelectedDate.ToString("yyyy-MM-dd");
        }

        protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {
            ux_start_date.Text = Calendar1.SelectedDate.ToString("yyyy-MM-dd");
        }

        protected void ux_lease_type_SelectedIndexChanged(object sender, EventArgs e)
        {
            ux_lease_type_id.Text = ux_lease_type.SelectedRow.Cells[0].Text;
        }

        //calculate total price
        protected void Button3_Click(object sender, EventArgs e)
        {         
            if (ux_start_date.Text==""||ux_end_date.Text==""||ux_lease_type_id.Text=="")
            {
                calculation_status.Text = "date or lease type not selected";
                return;
            }

            DateTime user_start_date = (Convert.ToDateTime(ux_start_date.Text));
            DateTime user_end_date = Convert.ToDateTime(ux_end_date.Text);            

            DateTime lease_start_date = Convert.ToDateTime( lease_begin.Text);
            DateTime lease_end_date = Convert.ToDateTime( lease_end.Text);

            if (DateTime.Compare(lease_start_date, user_start_date) < 0 && DateTime.Compare(lease_end_date, user_start_date) > 0)
            {
                calculation_status.Text = "slip is unavailable on lease start date";
                return;
            }

            if (DateTime.Compare(lease_start_date, user_end_date) < 0 && DateTime.Compare(lease_end_date, user_end_date) >0)
            {
                calculation_status.Text = "slip is unavailable on lease end date";
                return;
            }

            if (DateTime.Compare(DateTime.Now, user_start_date) > 0)
            {
                calculation_status.Text = "lease start date is before today";
                return;
            }

            if (DateTime.Compare(user_start_date, user_end_date) > 0)
            {
                calculation_status.Text = "Lease end date is before start date";
                return;
            }

            TimeSpan span = user_end_date.Subtract(user_start_date);

            double rate = Convert.ToDouble( ux_lease_type.SelectedRow.Cells[2].Text);
            string type = ux_lease_type.SelectedRow.Cells[1].Text;

            switch(type)
            {
                case "Daily":
                    Price.Text =  (rate * span.TotalDays).ToString();
                    break;
                case "Weekly":
                    Price.Text = (rate * Math.Ceiling(span.TotalDays/7)).ToString();
                    break;
                case "Monthly":
                    Price.Text = (rate * Math.Ceiling(span.TotalDays/30)).ToString();
                    break;
                case "Yearly":
                    Price.Text = (rate * Math.Ceiling(span.TotalDays/365)).ToString();
                    break;
                default:
                    break;
            }

            calculation_status.Text = "done";
        }

        //lease click
        protected void Button2_Click(object sender, EventArgs e)
        {
            Button3_Click(null, null);

            if(calculation_status.Text!="done")
            {
                status.Text = calculation_status.Text;
                return;
            }
           
            if(ux_slip_id.Text=="")
            {
                status.Text = "Slip not selected";
                return;
            }

            var proxy = new ServiceReference1.interface1Client();

            status.Text = proxy.AddLease
                (
                Convert.ToDateTime(ux_start_date.Text),
                Convert.ToDateTime(ux_end_date.Text),
                Convert.ToInt32(ux_slip_id.Text),
                Convert.ToInt32(Page.User.Identity.Name.Split(' ')[3]),
                Convert.ToInt32(ux_lease_type_id.Text)
                );
        }
    }
}



<%@ Page Title="Register Boat" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="register boat.aspx.cs" Inherits="presentation.authorized_user.register_boat" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <h2 style="color: darkturquoise"><%: Title %>.</h2>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>

            <table>
                <tr>
                    <td colspan="2">
                        <asp:GridView ID="boat_table" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="ObjectDataSource1" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="boat_table_SelectedIndexChanged">
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            <Columns>
                                <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" SortExpression="CustomerID" />
                                <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
                                <asp:BoundField DataField="Length" HeaderText="Length" SortExpression="Length" />
                                <asp:BoundField DataField="Manufacturer" HeaderText="Manufacturer" SortExpression="Manufacturer" />
                                <asp:BoundField DataField="ModelYear" HeaderText="ModelYear" SortExpression="ModelYear" />
                                <asp:BoundField DataField="RegistrationNumber" HeaderText="RegistrationNumber" SortExpression="RegistrationNumber" />
                                <asp:ButtonField ButtonType="Button" CommandName="Select" Text="Select" />
                            </Columns>
                            <EditRowStyle BackColor="#999999" />
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                            <SortedAscendingCellStyle BackColor="#E9E7E2" />
                            <SortedAscendingHeaderStyle BackColor="#506C8C" />
                            <SortedDescendingCellStyle BackColor="#FFFDF8" />
                            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                        </asp:GridView>
                        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetBoatsByCustomerId" TypeName="presentation.ServiceReference1.interface1Client">
                            <SelectParameters>
                                <asp:ControlParameter ControlID="customer_id" Name="_customer_id" PropertyName="Text" Type="Int32" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </td>
                </tr>
                <tr>
                    <td>
                        <br />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="label1" runat="server" Text="CustomerID"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="customer_id" runat="server" Enabled="False"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="label2" runat="server" Text="Length"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="ux_length" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="label3" runat="server" Text="ModelYear"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="ux_year" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="label4" runat="server" Text="Manufacture"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="ux_manufacture" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="label5" runat="server" Text="Registration"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="ux_registration" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Button ID="Button1" runat="server" class="btn btn-primary btn-lg" Text="Add" Style="width: 95%" OnClick="Button1_Click" />
                    </td>
                    <td>
                        <asp:Button ID="Button2" runat="server" class="btn btn-primary btn-lg" Text="Update" Style="width: 95%" OnClick="Button2_Click" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Label ID="status" runat="server" ForeColor="#FF3300"></asp:Label>
                    </td>
                </tr>
            </table>

        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>

---------------------------------------------------

register boat.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace presentation.authorized_user
{
    public partial class register_boat : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                customer_id.Text = Page.User.Identity.Name.Split(' ')[3];
            }
        }

        //add
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (ux_length.Text == "" || ux_manufacture.Text == "" || ux_registration.Text == "" || ux_year.Text == "")
            {
                status.Text = "information incomplete";
                return;
            }

            try
            {
                Convert.ToInt32(ux_year.Text);
                Convert.ToInt32(ux_length.Text);
            }
            catch(Exception e1)
            {
                status.Text = "year or length is not an integer";
                return;
            }

            var proxy = new ServiceReference1.interface1Client();

            status.Text = proxy.AddBoat(ux_registration.Text,
                ux_manufacture.Text,
                Convert.ToInt32(ux_year.Text),
                Convert.ToInt32(ux_length.Text),
                Convert.ToInt32(customer_id.Text));

            Page.DataBind();
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            if (ux_length.Text == "" || ux_manufacture.Text == "" || ux_registration.Text == "" || ux_year.Text == "")
            {
                status.Text = "information incomplete";
                return;
            }

            if (boat_table.SelectedRow.Cells[1].Text == null)
            {
                status.Text = "boat is not selected for update";
            }

            try
            {
                Convert.ToInt32(ux_year.Text);
                Convert.ToInt32(ux_length.Text);
            }
            catch (Exception e2)
            {
                status.Text = "year or length is not an integer";
                return;
            }

            var proxy = new ServiceReference1.interface1Client();

            status.Text=proxy.UpdateBoat(Convert.ToInt32(boat_table.SelectedRow.Cells[1].Text),
                ux_registration.Text,
                ux_manufacture.Text,
                Convert.ToInt32(ux_year.Text),
                Convert.ToInt32(ux_length.Text),
                Convert.ToInt32(customer_id.Text));

            Page.DataBind();
        }

        protected void boat_table_SelectedIndexChanged(object sender, EventArgs e)
        {
            ux_length.Text = boat_table.SelectedRow.Cells[2].Text;
            ux_manufacture.Text = boat_table.SelectedRow.Cells[3].Text;
            ux_year.Text = boat_table.SelectedRow.Cells[4].Text;
            ux_registration.Text = boat_table.SelectedRow.Cells[5].Text;
        }
    }
}



//service/interface.cs

using domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace service
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface interface1
    {
        [OperationContract]
        string AddCustomer(string _first_name, string _last_name, string _phone_number, string _city);

        [OperationContract]
        string UpdateCustomer(int _customer_id, string _first_name, string _last_name, string _phone_number, string _city);

        [OperationContract]
        customer_dto GetCustomerRecordById(int _id);

        [OperationContract]
        List<customer_dto> GetAllCustomers();

        [OperationContract]
        string AddBoat(string _registration_number, string _manufacture_name, int _model_year, int _length, int _customer_id);

        [OperationContract]
        string UpdateBoat(int _boat_id, string RegistrationNumber, string Manufacturer, int ModelYear, int Length, int _customer_id);

        [OperationContract]
        List<boat_dto> GetBoatsByCustomerId(int _customer_id);

        [OperationContract]
        string AddAuthorize(string _user_name, string _password, string _customer_id);

        [OperationContract]
        string UpdateAuthorize(int authorize_id, string _user_name, string _password, string _customer_id);

        [OperationContract]
        string AddLease(DateTime _start_date, DateTime _end_date, int _slip_id, int _customer_id, int lease_type);

        [OperationContract]
        List<location_dto> GetLocations();

        [OperationContract]
        List<slip_dto> GetAvailableSlipByDockId(int _dock_id);

        [OperationContract]
        List<lease_type_dto> GetLeaseTypes();

        [OperationContract]
        authorize_dto Authenticate(string _user_name, string password);

        [OperationContract]
        List<dock_dto> GetDocks(string _location_id);
    }


  
}

------------------------------------------------------

//service/method.svc

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using domain;
using business;

namespace service
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    public class method : interface1
    {
        public string AddAuthorize(string _user_name, string _password, string _customer_id)
        {
            return authorize_manager.AddAuthorize(_user_name, _password, _customer_id);
        }

        public string AddBoat(string _registration_number, string _manufacture_name, int _model_year, int _length, int _customer_id)
        {
            return boat_manager.AddBoat(_registration_number, _manufacture_name, _model_year, _length, _customer_id);
        }

        public string AddCustomer(string _first_name, string _last_name, string _phone_number, string _city)
        {
            return customer_manager.AddCustomer(_first_name, _last_name, _phone_number, _city);
        }

        public string AddLease(DateTime _start_date, DateTime _end_date, int _slip_id, int _customer_id, int lease_type)
        {
            return slip_manager.AddLease(_start_date, _end_date, _slip_id, _customer_id, lease_type);
        }

        public authorize_dto Authenticate(string _user_name, string password)
        {
            return authorize_manager.Authenticate(_user_name, password);
        }

        public List<customer_dto> GetAllCustomers()
        {
            return customer_manager.GetAllCustomers();
        }

        public List<slip_dto> GetAvailableSlipByDockId(int _dock_id)
        {
            return slip_manager.GetAvailableSlipByDockId(_dock_id);
        }

        public List<boat_dto> GetBoatsByCustomerId(int _customer_id)
        {
            return boat_manager.GetBoatsByCustomerId(_customer_id);
        }

        public customer_dto GetCustomerRecordById(int _id)
        {
            return customer_manager.GetCustomerRecordById(_id);
        }

        public List<dock_dto> GetDocks(string _location_id)
        {
            return slip_manager.GetDocks(_location_id);
        }

        public List<lease_type_dto> GetLeaseTypes()
        {
            return slip_manager.GetLeaseTypes();
        }

        public List<location_dto> GetLocations()
        {
            return slip_manager.GetLocations();
        }

        public string UpdateAuthorize(int authorize_id, string _user_name, string _password, string _customer_id)
        {
            return authorize_manager.UpdateAuthorize(authorize_id, _user_name, _password, _customer_id);
        }

        public string UpdateBoat(int _boat_id, string RegistrationNumber, string Manufacturer, int ModelYear, int Length, int _customer_id)
        {
            return boat_manager.UpdateBoat(_boat_id, RegistrationNumber, Manufacturer, ModelYear, Length, _customer_id);
        }

        public string UpdateCustomer(int _customer_id, string _first_name, string _last_name, string _phone_number, string _city)
        {
            return customer_manager.UpdateCustomer(_customer_id, _first_name, _last_name, _phone_number, _city);
        }
    }
}

---------------------------------------------------

//authorize_manager.cs

using data;
using domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace business
{
    public class authorize_manager
    {
        public static authorize_dto Authenticate(string _user_name, string password)
        {
            var db = new InlandMarinaEntities();

            var auth = db.Authorizes.SingleOrDefault(x => x.UserName == _user_name && x.Password == password);

            if (auth != null)
            {
                var _customer = new authorize_dto
                {
                    ID = auth.ID,
                    CustomerID = auth.CustomerID,
                    Password = auth.Password,
                    UserName = auth.UserName
                };

                return _customer;
            }

            return null;
        }

        public static string AddAuthorize(string _user_name, string _password, string _customer_id)
        {
            var db = new InlandMarinaEntities();
           
            if(db.Authorizes.SingleOrDefault(x => x.UserName == _user_name)!=null)
            {
                return "User name exist";
            }

            //for checking if user name is available, not intend to add a new authorization.
            if(_customer_id=="")
            {
                return "User name available";
            }

            var authorization = new Authorize
            {
                CustomerID = Convert.ToInt32(_customer_id),
                Password = _password,
                UserName = _user_name
            };

            db.Authorizes.Add(authorization);
            db.SaveChanges();

            return "new user added";
        }

        public static string UpdateAuthorize(int authorize_id, string _user_name, string _password, string _customer_id)
        {
            var db = new InlandMarinaEntities();

            var customer_id = Convert.ToInt32(_customer_id);

            //use to find user name given customer id, skip update
            if(authorize_id == 0)
            {
                var user_name = db.Authorizes.SingleOrDefault(x => x.CustomerID == customer_id).UserName;
                return user_name;
            }

            var authorization = db.Authorizes.SingleOrDefault(x => x.ID == authorize_id);

            authorization.CustomerID = Convert.ToInt32( _customer_id);
            authorization.UserName = _user_name;
            authorization.Password = _password;

            db.SaveChanges();

            return "success";
        }
    }
}

----------------------------------------------------------------

//boat_manager.cs

using data;
using domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace business
{
    public class boat_manager
    {
        public static List<boat_dto> GetBoatsByCustomerId(int _customer_id)
        {
            var db = new InlandMarinaEntities();

            var boats = db.Boats.Where(x => x.CustomerID == _customer_id).
                Select(x => new boat_dto
                {
                    CustomerID = x.CustomerID,
                    ID = x.ID,
                    Length = x.Length,
                    Manufacturer = x.Manufacturer,
                    ModelYear = x.ModelYear,
                    RegistrationNumber = x.RegistrationNumber
                }).ToList();

            return boats;
        }

        public static string AddBoat(string _registration_number, string _manufacture_name, int _model_year, int _length, int _customer_id)
        {
            var db = new InlandMarinaEntities();

            var new_boat = new Boat
            {
                CustomerID = _customer_id,
                Length = _length,
                Manufacturer = _manufacture_name,
                ModelYear = _model_year,
                RegistrationNumber = _registration_number
            };

            db.Boats.Add(new_boat);

            db.SaveChanges();

            return "success";
        }

        public static string UpdateBoat(int _boat_id, string _registration_number, string _manufacture_name, int _model_year, int _length, int _customer_id)
        {
            var db = new InlandMarinaEntities();

            var boat = db.Boats.SingleOrDefault(x => x.ID == _boat_id);

            boat.Length = _length;
            boat.Manufacturer = _manufacture_name;
            boat.ModelYear = _model_year;
            boat.RegistrationNumber = _registration_number;
            boat.CustomerID = _customer_id;

            db.SaveChanges();

            return "success";
        }
    }
}

------------------------------------------------

//customer_manager.cs

using data;
using domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace business
{
    public class customer_manager
    {
        public static customer_dto GetCustomerRecordById(int _id)
        {
            var db = new InlandMarinaEntities();

            var _customer = db.Customers.SingleOrDefault(x => x.ID == _id);

            var _customer_dto = new customer_dto
            {
                ID = _customer.ID,
                City = _customer.City,
                FirstName = _customer.FirstName,
                LastName = _customer.LastName,
                Phone = _customer.Phone
            };

            return _customer_dto;
        }

        public static string AddCustomer(string _first_name, string _last_name, string _phone_number, string _city)
        {
            var db = new InlandMarinaEntities();

            //check if customer is on database, skip add if customer exists
            if(db.Customers.SingleOrDefault(x => x.FirstName == _first_name && x.LastName == _last_name)!=null)
            {
                return "customer exists";
            }                                      

            var customer = new Customer
            {
                FirstName = _first_name,
                LastName = _last_name,
                Phone = _phone_number,
                City = _city
            };
            
            db.Customers.Add(customer);
            db.SaveChanges();

            var _id = db.Customers.SingleOrDefault(x => x.FirstName == _first_name && x.LastName == _last_name).ID;

            return _id.ToString();
        }

        public static List<customer_dto> GetAllCustomers()
        {
            var db = new InlandMarinaEntities();

            var customers = db.Customers.Select(x => new customer_dto
            {
                City = x.City,
                FirstName = x.FirstName,
                LastName = x.LastName,
                ID = x.ID,
                Phone = x.Phone
            }).ToList();

            return customers;
        }

        public static string UpdateCustomer(int _customer_id, string _first_name, string _last_name, string _phone_number, string _city)
        {
            var db = new InlandMarinaEntities();

            var customer = db.Customers.SingleOrDefault(x => x.ID == _customer_id);

            customer.FirstName = _first_name;
            customer.LastName = _last_name;
            customer.Phone = _phone_number;
            customer.City = _city;

            db.SaveChanges();

            return "success";
        }
    }
}

---------------------------------------------------

// slip_manager.cs

using data;
using domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace business
{
    public class slip_manager
    {
        public static List<location_dto> GetLocations()
        {
            var db = new InlandMarinaEntities();

            var locations = db.Locations.Select(x => new location_dto
            {
                ID = x.ID,
                Name = x.Name
            }).ToList();

            return locations;
        }

        public static List<dock_dto> GetDocks(string _location_id)
        {
            var db = new InlandMarinaEntities();

            int location_id = Convert.ToInt32(_location_id);

            var docks = db.Docks.Where(x => x.LocationId == location_id).
                Select(x => new dock_dto
                {
                    ID = x.ID,
                    LocationId = x.LocationId,
                    Name = x.Name,
                    ElectricalService = x.ElectricalService,
                    WaterService = x.WaterService
                }).ToList();

            return docks;
        }

        public static List<slip_dto> GetAvailableSlipByDockId(int _dock_id)
        {
            var db = new InlandMarinaEntities();          

            var available_slip = db.Slips.Where(x => x.DockID == _dock_id).
                Select(x => new slip_dto
                {
                    ID = x.ID,
                    DockID = x.DockID,
                    Length = x.Length,
                    Width = x.Width,
                    LeaseStart = new DateTime(2000, 1, 1),
                    LeaseEnd = new DateTime(2000, 1, 2)
        }).ToList();

            if (available_slip.Count == 0) { return available_slip; } 

            //find lease start and end date for slips
            foreach (var lease_item in db.Leases)
            {
                var _slip = available_slip.SingleOrDefault(x => x.ID == lease_item.SlipID);

                if (_slip != null)
                {
                    _slip.LeaseStart = lease_item.StartDate;

                    _slip.LeaseEnd = lease_item.EndDate;
                }
            }

            return available_slip;
        }

        public static List<lease_type_dto> GetLeaseTypes()
        {
            var db = new InlandMarinaEntities();

            var lease_type = db.LeaseTypes.Select(x => new lease_type_dto
            {
                ID = x.ID,
                Name = x.Name,
                StandardRateAmount=x.StandardRateAmount
            }).ToList();

            return lease_type;
        }

        public static string AddLease(DateTime _start_date, DateTime _end_date, int _slip_id, int _customer_id, int lease_type)
        {
            var db = new InlandMarinaEntities();

            var new_lease = new Lease
            {
                CustomerID = _customer_id,
                EndDate = _end_date,
                LeaseTypeID = lease_type,
                SlipID = _slip_id,
                StartDate = _start_date
            };

            db.Leases.Add(new_lease);

            db.SaveChanges();

            return "success";
        }

    }

}

---------------------------------------

//lease_dto.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace domain
{
    [DataContract]
    public class lease_dto
    {
        [DataMember]
        public int ID { get; set; }
        [DataMember]
        public System.DateTime StartDate { get; set; }
        [DataMember]
        public System.DateTime EndDate { get; set; }
        [DataMember]
        public int SlipID { get; set; }
        [DataMember]
        public int CustomerID { get; set; }
        [DataMember]
        public int LeaseTypeID { get; set; }
    }
}