Development of small program for developing personal book Collection (vii) DB design

Source: Internet
Author: User

Front of the study initialization of the front-end information is complete, so now start implementing the script part of DB.

New Action:Shelf_Init.sql

Svc.sql

1 CREATE SCHEMA [svc] 2     AUTHORIZATION [dbo];

Shelf_init.sql

1 CREATE PROCEDURE [Svc].[Shelf$init](@json nvarchar(Max))2  withEncryption3  as4 BEGIN5     SETNOCOUNT on;6     SETXact_abort on;7     BEGINTRY8         BEGIN    TRAN;9 Ten         Declare    @nickName nvarchar( -),@shelfName nvarchar( -); One         Select    @nickName=Nickname,@shelfName=Shelfname A          fromOpenjson (@json,'$') -          with ( -Nicknamenvarchar( -), theShelfnamenvarchar( -) -         ); -  -         InsertCore._party (Type, Alias)SelectK._User,@nickName +          fromCore. Party#type () K; -         Declare    @userID int=@ @identity; +  A          at         InsertCore._party (PID, Type, Alias)Select @userID, K._shelf,@shelfName -          fromCore. Party#type () K; -  -         COMMIT    TRAN; -     ENDTRY -     BEGINCATCH in         if(Xact_state ()= -1)ROLLBACK TRAN; throw; -     ENDCATCH to END

Okay, I'm going to try the front end can initialize information into DB

....

Before testing, we need to implement the Init Razor pages code:

Init.cshtml.cs

1     usingM =Shelf;2      Public classInitmodel:pagemodel3     {4         Private ReadOnlyIshelfrepo _shelfrepo;5          PublicInitmodel (Ishelfrepo Shelfrepo)6         {7_shelfrepo =Shelfrepo;8         }9 [BindProperty]Ten          PublicInitinputmodel Input {Get;Set; } One  A          Public voidOnget () -         { -  the         } -  -          Public AsyncTask<iactionresult>Onpostasync () -         { +             if(modelstate.isvalid) -             { +                 await_shelfrepo.initasync (NewM.initspec A                 { atNickname =Input.NickName.Trim (), -Shelfname =Input.ShelfName.Trim () -                 }); -                 returnRedirecttopage ("New"); -             } -             returnPage (); in         } -}

Page content also needs to modify the form section

Init.cshtml

1<form method="Post">2<divclass="Form-group FORM-GROUP-LG">3<label asp- for="Input.nickname"></label>4<inputclass="Form-control FORM-CONTROL-LG"asp- for="Input.nickname"Autocomplete="off">5<span asp-validation- for="Input.nickname" class="Text-danger"></span>6</div>7<divclass="Form-group FORM-GROUP-LG">8<label asp- for="Input.shelfname"></label>9<inputclass="Form-control FORM-CONTROL-LG"asp- for="Input.shelfname"Autocomplete="if">Ten<span asp-validation- for="Input.shelfname" class="Text-danger"></span> One</div> A<divclass="Form-group text-right"> -<buttonclass="btn btn-warning Btn-lg"Type="Submit">Save</button> -</div> the</form>

Fill in the information of the study:

Click the Save button to submit, OK, the normal submission and jump.

See if the following DB has data:

Haha, everything looks normal.

Development of small program for developing personal book Collection (vii) DB design

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.