SharpRestoVRII: Difference between revisions

From ICO wiki
Jump to navigationJump to search
No edit summary
Line 142: Line 142:
     {bill2 object}]
     {bill2 object}]
}
}
</source>
== XML ==
XML fail
<source>
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="test.xslt"?>
<bills>
  <bill id="1" quantity="2" totalCost="5" notPaid="true">
    <menuArticle id="1">
<name><![CDATA[Hamburger]]></name>
<itemType id="2">
<itemTypeName><![CDATA[Mains]]></itemTypeName>
</itemType>
<price id = "3">
<startTime>2018-01-01-00:00</startTime>
<endTime>2019-01-01-00:00</endTime>
<priceInEur currency="€">3</priceInEur>
</price>
<ingredients>
<ingredient id= "4">
<ingredientName><![CDATA[Sai]]></ingredientName>
</ingredient>
<ingredient id= "5">
<ingredientName><![CDATA[Hakkliha]]></ingredientName>
</ingredient>
<ingredient id= "6">
<ingredientName><![CDATA[Salat]]></ingredientName>
</ingredient>
<ingredient id= "7">
<ingredientName><![CDATA[Kaste]]></ingredientName>
</ingredient>
</ingredients>
    </menuArticle>
        <menuArticle id="9">
<name><![CDATA[Fanta 0,5l]]></name>
<itemType id="2">
<itemTypeName><![CDATA[Drinks]]></itemTypeName>
</itemType>
<price id = "8">
<startTime>2018-01-01-00:00</startTime>
<endTime>2019-01-01-00:00</endTime>
<priceInEur currency="€">2</priceInEur>
</price>
    </menuArticle>
  </bill>
  <bill id="2" quantity="1" totalCost="5" notPaid="false">
    <menuArticle id="1">
<name><![CDATA[Lõbusa Lauri burks]]></name>
<itemType id="2">
<itemTypeName><![CDATA[Mains]]></itemTypeName>
</itemType>
<price id = "5">
<startTime>2018-01-01-00:00</startTime>
<endTime>2019-01-01-00:00</endTime>
<priceInEur currency="€">5</priceInEur>
</price>
<ingredients>
<ingredient id= "4">
<ingredientName><![CDATA[Sai]]></ingredientName>
</ingredient>
<ingredient id= "5">
<ingredientName><![CDATA[Hakkiliha]]></ingredientName>
</ingredient>
<ingredient id= "6">
<ingredientName><![CDATA[Salat]]></ingredientName>
</ingredient>
<ingredient id= "7">
<ingredientName><![CDATA[Salajane Kaste]]></ingredientName>
</ingredient>
</ingredients>
    </menuArticle>
  </bill>
    <bill id="3" quantity="1" totalCost="6" notPaid="true">
    <menuArticle id="1">
<name><![CDATA[Kanapraad]]></name>
<itemType id="2">
<itemTypeName><![CDATA[Mains]]></itemTypeName>
</itemType>
<price id = "7">
<startTime>2018-01-01-00:00</startTime>
<endTime>2019-01-01-00:00</endTime>
<priceInEur currency="€">6</priceInEur>
</price>
<ingredients>
<ingredient id= "4">
<ingredientName><![CDATA[Friikartulid]]></ingredientName>
</ingredient>
<ingredient id= "5">
<ingredientName><![CDATA[Krõbekana]]></ingredientName>
</ingredient>
<ingredient id= "6">
<ingredientName><![CDATA[Salat]]></ingredientName>
</ingredient>
<ingredient id= "7">
<ingredientName><![CDATA[Salajane Kaste]]></ingredientName>
</ingredient>
</ingredients>
    </menuArticle>
  </bill>
 
</bills>
</source>
XSD
<source>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="bills" type="billsType"/>
  <xs:complexType name="ingredientType">
    <xs:sequence>
      <xs:element name="ingredientName">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="Sai"/>
            <xs:enumeration value="Hakkliha"/>
            <xs:enumeration value="Salat"/>
            <xs:enumeration value="Kaste"/>
            <xs:enumeration value="Salajane Kaste"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
    <xs:attribute type="xs:string" name="id" use="optional"/>
  </xs:complexType>
  <xs:complexType name="billsType">
    <xs:sequence>
      <xs:element type="billType" name="bill" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ingredientsType">
    <xs:sequence>
      <xs:element type="ingredientType" name="ingredient" maxOccurs="32" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="itemTypeType">
    <xs:sequence>
      <xs:element type="xs:string" name="itemTypeName"/>
    </xs:sequence>
    <xs:attribute type="xs:string" name="id" use="optional"/>
  </xs:complexType>
  <xs:complexType name="billType">
    <xs:sequence>
      <xs:element type="menuArticleType" name="menuArticle" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute type="xs:string" name="id" use="optional"/>
    <xs:attribute type="xs:string" name="quantity" use="optional"/>
    <xs:attribute type="xs:string" name="totalCost" use="optional"/>
    <xs:attribute type="xs:string" name="notPaid" use="optional"/>
  </xs:complexType>
  <xs:complexType name="priceType">
    <xs:sequence>
      <xs:element type="xs:string" name="startTime"/>
      <xs:element type="xs:string" name="endTime"/>
      <xs:element type="priceInEurType" name="priceInEur"/>
    </xs:sequence>
    <xs:attribute type="xs:string" name="id" use="optional"/>
  </xs:complexType>
  <xs:complexType name="menuArticleType">
    <xs:sequence>
      <xs:element name="name">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="Hamburger"/>
            <xs:enumeration value="Fanta 0,5l"/>
            <xs:enumeration value="Lõbusa Lauri burks"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element type="itemTypeType" name="itemType"/>
      <xs:element type="priceType" name="price"/>
      <xs:element type="ingredientsType" name="ingredients" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute type="xs:string" name="id" use="optional"/>
  </xs:complexType>
  <xs:complexType name="priceInEurType">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute type="xs:string" name="currency" use="optional"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:schema>
</source>
XLST 1 - Kõik arved ja nende koostised
<source>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <html>
      <head>
        <h1>Arved</h1>
      </head>
      <body>
  <ol>
<xsl:variable name="notPaid">true</xsl:variable>
<xsl:for-each select="bills/bill">
<li>Arve: <xsl:choose>
<xsl:when test="@notPaid = $notPaid">
<b style="color:red;">MAKSMATA SUMMAS: <xsl:value-of select="@totalCost"/> €</b>
</xsl:when>
<xsl:otherwise>
<b style="color:green;">makstud summas: <xsl:value-of select="@totalCost"/> €</b>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="menuArticle">
<xsl:sort select="@id"/>
<ul>Menüü artikkel: <xsl:value-of select="name"/>
<br/>Menüü kategooria: <xsl:value-of select="itemType/itemTypeName"/>
<br/>Hind: <xsl:value-of select="price/priceInEur"/> €
</ul>
<br/>
<xsl:if test="ingredients">Koostisosad:<br/>
<ul style="list-style-type:disc">
<xsl:for-each select="ingredients/ingredient">
<li>
<xsl:value-of select="ingredientName"/>
</li>
</xsl:for-each>
</ul>
<br/>
</xsl:if>
</xsl:for-each>
</li>
<br/>
</xsl:for-each>
</ol>
</body>
    </html>
  </xsl:template>
</xsl:stylesheet>
</source>
XLST 2 - Maksmata arved
<source>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <html>
      <head>
        <h1>Maksmata arved</h1>
      </head>
      <body>
  <ol>
<xsl:variable name="notPaid">true</xsl:variable>
<xsl:for-each select="bills/bill[@notPaid=$notPaid]">
<li>Arve: <xsl:choose>
<xsl:when test="@notPaid = $notPaid">
<b style="color:red;">MAKSMATA SUMMAS: <xsl:value-of select="@totalCost"/> €</b>
</xsl:when>
<xsl:otherwise>
<b style="color:green;">makstud summas: <xsl:value-of select="@totalCost"/> €</b>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="menuArticle">
<xsl:sort select="@id"/>
<ul>Menüü artikkel: <xsl:value-of select="name"/>
<br/>Menüü kategooria: <xsl:value-of select="itemType/itemTypeName"/>
<br/>Hind: <xsl:value-of select="price/priceInEur"/> €
</ul>
<br/>
</xsl:for-each>
</li>
<br/>
</xsl:for-each>
</ol>
</body>
    </html>
  </xsl:template>
</xsl:stylesheet>
</source>
</source>



Revision as of 13:37, 2 June 2018

Meeskond

  • Andres Aava (lahkunud liige)
  • Henri Annilo
  • Jaan Koolmeister
  • Lauri Üksti

Esitused

Lähtekood: CSharpResto

Retsensioonid:

Tehnoloogia

Server: ASP.NET Core 2.0
Klient: WPF
DB: SQL Server (Azure)

Ülevaade

Tegemist on SharpResto jätkuprojektiga.

Eesmärk on luua restoranihalduse teenus

  • kasutaja saab pärida, lisada ja muuta menüü komponente
  • kasutaja saab pärida, lisada ja muuta esitatud tellimusi
  • kasutaja saab pärida statistikat tellimuste kohta
  • eri teenuste ligipääs on piiratav kasutaja- ning grupipõhiselt
  • staatiline informatsioon hoitakse serveri vahemälus

API

Täpsema implementatsiooni lõplikest teenustest leiab siit Lisatud on paar tehnilist teenust (health'i ja security tokeni tarbeks) ja mõned teenused tulevikuks (nt kuupäeva vahemikuga arvete tagastamine).

Esialgne analüüs:

Menüü teenus
GET api/menu
Tagastab kõik menüü artiklid menüü vaate jaoks
Parameetrid:

id (valikuline)

Väljund:

{
"MenuItem":
[{ //menuitem objekt},
{ //menuitem 2 },
{ //menuitem 3 }
]}

POST api/menu/
Loob uue menuItem’i
Body:

{ 
//new MenuItem object
}

Tagastab 201 või 400

PUT api/menu/{id}
Muudab olemasolevat menuItem’it
Body:

{ 
// changed MenuItem object
}

Tagastab 200, 400 või 404

Tellimuste teenus
GET api/orders
Tagastab kõik tellimused
Parameetrid:

id (valikuline)

Väljund:

{
    [{order1 object}, {order2 object}]
}

POST api/orders
Loob uue tellimuse
Body:

{
    <uus order objekt>  
}

Tagastab 201 või 400

PUT api/orders/{id}
Muudab tellimust (üldine)
Body:

{
    <muudetud order objekt>  
}

Tagastab 200, 400, või 404 </source>

PUT api/orders/setStatus/{id}
Muudab vaid tellimuse staatust
Body:

{status: <status>}

Tagastab 200, 400 või 404

Arvete teenus
Lõpetatud/serveeritud tellimuste salvestamine arveteks.
Hilisem arvete küsimine.

POST api/bills Arvete sisestamine.

Body:

{ 
   <Bill objekt>
}

Tagastab 200, 400 </source>

GET api/bills
Parameetrid:

id (valikuline)

Väljund:

{
   [{bill1 object}, 
    {bill2 object}]
}

XML

XML fail

<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="test.xslt"?>
<bills>
  <bill id="1" quantity="2" totalCost="5" notPaid="true">
    <menuArticle id="1">
		<name><![CDATA[Hamburger]]></name>
		<itemType id="2">
			<itemTypeName><![CDATA[Mains]]></itemTypeName>
		</itemType>
		<price id = "3">
			<startTime>2018-01-01-00:00</startTime>
			<endTime>2019-01-01-00:00</endTime>
			<priceInEur currency="€">3</priceInEur>
		</price>
		<ingredients>
			<ingredient id= "4">
				<ingredientName><![CDATA[Sai]]></ingredientName>
			</ingredient>
			<ingredient id= "5">
				<ingredientName><![CDATA[Hakkliha]]></ingredientName>
			</ingredient>
			<ingredient id= "6">
				<ingredientName><![CDATA[Salat]]></ingredientName>
			</ingredient>
			<ingredient id= "7">
				<ingredientName><![CDATA[Kaste]]></ingredientName>
			</ingredient>
		</ingredients>
    </menuArticle>
        <menuArticle id="9">
		<name><![CDATA[Fanta 0,5l]]></name>
		<itemType id="2">
			<itemTypeName><![CDATA[Drinks]]></itemTypeName>
		</itemType>
		<price id = "8">
			<startTime>2018-01-01-00:00</startTime>
			<endTime>2019-01-01-00:00</endTime>
			<priceInEur currency="€">2</priceInEur>
		</price>
    </menuArticle>
  </bill>
  <bill id="2" quantity="1" totalCost="5" notPaid="false">
    <menuArticle id="1">
		<name><![CDATA[Lõbusa Lauri burks]]></name>
		<itemType id="2">
			<itemTypeName><![CDATA[Mains]]></itemTypeName>
		</itemType>
		<price id = "5">
			<startTime>2018-01-01-00:00</startTime>
			<endTime>2019-01-01-00:00</endTime>
			<priceInEur currency="€">5</priceInEur>
		</price>
		<ingredients>
			<ingredient id= "4">
				<ingredientName><![CDATA[Sai]]></ingredientName>
			</ingredient>
			<ingredient id= "5">
				<ingredientName><![CDATA[Hakkiliha]]></ingredientName>
			</ingredient>
			<ingredient id= "6">
				<ingredientName><![CDATA[Salat]]></ingredientName>
			</ingredient>
			<ingredient id= "7">
				<ingredientName><![CDATA[Salajane Kaste]]></ingredientName>
			</ingredient>
		</ingredients>
    </menuArticle>
  </bill>
    <bill id="3" quantity="1" totalCost="6" notPaid="true">
    <menuArticle id="1">
		<name><![CDATA[Kanapraad]]></name>
		<itemType id="2">
			<itemTypeName><![CDATA[Mains]]></itemTypeName>
		</itemType>
		<price id = "7">
			<startTime>2018-01-01-00:00</startTime>
			<endTime>2019-01-01-00:00</endTime>
			<priceInEur currency="€">6</priceInEur>
		</price>
		<ingredients>
			<ingredient id= "4">
				<ingredientName><![CDATA[Friikartulid]]></ingredientName>
			</ingredient>
			<ingredient id= "5">
				<ingredientName><![CDATA[Krõbekana]]></ingredientName>
			</ingredient>
			<ingredient id= "6">
				<ingredientName><![CDATA[Salat]]></ingredientName>
			</ingredient>
			<ingredient id= "7">
				<ingredientName><![CDATA[Salajane Kaste]]></ingredientName>
			</ingredient>
		</ingredients>
    </menuArticle>
  </bill>
  
</bills>

XSD

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="bills" type="billsType"/>
  <xs:complexType name="ingredientType">
    <xs:sequence>
      <xs:element name="ingredientName">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="Sai"/>
            <xs:enumeration value="Hakkliha"/>
            <xs:enumeration value="Salat"/>
            <xs:enumeration value="Kaste"/>
            <xs:enumeration value="Salajane Kaste"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
    <xs:attribute type="xs:string" name="id" use="optional"/>
  </xs:complexType>
  <xs:complexType name="billsType">
    <xs:sequence>
      <xs:element type="billType" name="bill" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ingredientsType">
    <xs:sequence>
      <xs:element type="ingredientType" name="ingredient" maxOccurs="32" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="itemTypeType">
    <xs:sequence>
      <xs:element type="xs:string" name="itemTypeName"/>
    </xs:sequence>
    <xs:attribute type="xs:string" name="id" use="optional"/>
  </xs:complexType>
  <xs:complexType name="billType">
    <xs:sequence>
      <xs:element type="menuArticleType" name="menuArticle" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute type="xs:string" name="id" use="optional"/>
    <xs:attribute type="xs:string" name="quantity" use="optional"/>
    <xs:attribute type="xs:string" name="totalCost" use="optional"/>
    <xs:attribute type="xs:string" name="notPaid" use="optional"/>
  </xs:complexType>
  <xs:complexType name="priceType">
    <xs:sequence>
      <xs:element type="xs:string" name="startTime"/>
      <xs:element type="xs:string" name="endTime"/>
      <xs:element type="priceInEurType" name="priceInEur"/>
    </xs:sequence>
    <xs:attribute type="xs:string" name="id" use="optional"/>
  </xs:complexType>
  <xs:complexType name="menuArticleType">
    <xs:sequence>
      <xs:element name="name">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="Hamburger"/>
            <xs:enumeration value="Fanta 0,5l"/>
            <xs:enumeration value="Lõbusa Lauri burks"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element type="itemTypeType" name="itemType"/>
      <xs:element type="priceType" name="price"/>
      <xs:element type="ingredientsType" name="ingredients" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute type="xs:string" name="id" use="optional"/>
  </xs:complexType>
  <xs:complexType name="priceInEurType">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute type="xs:string" name="currency" use="optional"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:schema>

XLST 1 - Kõik arved ja nende koostised

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <html>
      <head>
        <h1>Arved</h1>
      </head>
      <body>
	  <ol>
					<xsl:variable name="notPaid">true</xsl:variable>
					<xsl:for-each select="bills/bill">
						<li>Arve: <xsl:choose>
								<xsl:when test="@notPaid = $notPaid">
									<b style="color:red;">MAKSMATA SUMMAS: <xsl:value-of select="@totalCost"/> €</b>
								</xsl:when>
								<xsl:otherwise>
									<b style="color:green;">makstud summas: <xsl:value-of select="@totalCost"/> €</b>
								</xsl:otherwise>
							</xsl:choose>
							<xsl:for-each select="menuArticle">
								<xsl:sort select="@id"/>
								<ul>Menüü artikkel: <xsl:value-of select="name"/>
									<br/>Menüü kategooria: <xsl:value-of select="itemType/itemTypeName"/>
									<br/>Hind: <xsl:value-of select="price/priceInEur"/> €
								</ul>
								<br/>
								<xsl:if test="ingredients">Koostisosad:<br/>
									<ul style="list-style-type:disc">
										<xsl:for-each select="ingredients/ingredient">
											<li>
												<xsl:value-of select="ingredientName"/>
											</li>
										</xsl:for-each>
									</ul>
									<br/>
								</xsl:if>
							</xsl:for-each>
						</li>
						<br/>
					</xsl:for-each>
				</ol>
			</body>
    </html>
  </xsl:template>
</xsl:stylesheet>

XLST 2 - Maksmata arved

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <html>
      <head>
        <h1>Maksmata arved</h1>
      </head>
      <body>
	  <ol>
					<xsl:variable name="notPaid">true</xsl:variable>
					<xsl:for-each select="bills/bill[@notPaid=$notPaid]">
						<li>Arve: <xsl:choose>
								<xsl:when test="@notPaid = $notPaid">
									<b style="color:red;">MAKSMATA SUMMAS: <xsl:value-of select="@totalCost"/> €</b>
								</xsl:when>
								<xsl:otherwise>
									<b style="color:green;">makstud summas: <xsl:value-of select="@totalCost"/> €</b>
								</xsl:otherwise>
							</xsl:choose>
							<xsl:for-each select="menuArticle">
								<xsl:sort select="@id"/>
								<ul>Menüü artikkel: <xsl:value-of select="name"/>
									<br/>Menüü kategooria: <xsl:value-of select="itemType/itemTypeName"/>
									<br/>Hind: <xsl:value-of select="price/priceInEur"/> €
								</ul>
								<br/>
							</xsl:for-each>
						</li>
						<br/>
					</xsl:for-each>
				</ol>
			</body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Ajalogi

Analüüsi tegemine 25.03-01.04
Programmeerimine 04.02-27.05