Index: backend/Controllers/ReservationsController.cs
===================================================================
--- backend/Controllers/ReservationsController.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/Controllers/ReservationsController.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,36 @@
+﻿namespace backend.Controllers;
+
+using backend.DTOs;
+using backend.Entities;
+using backend.Helpers;
+using backend.Models;
+using backend.Services;
+using Microsoft.AspNetCore.Mvc;
+using System.Security.Claims;
+
+[ApiController]
+[Route("[controller]")]
+public class ReservationsController : ControllerBase
+{
+    private readonly IReservationService _reservationService = null;
+
+    public ReservationsController(IReservationService reservationService)
+    {
+        _reservationService = reservationService;
+    }
+
+    [HttpPost()]
+    public async Task<IActionResult> CreateReservation([FromBody] CreateReservationRequest req)
+    {
+        await _reservationService.CreateReservation(req);
+        return Ok();
+    }
+
+    [Authorize]
+    [HttpPut("{rid}")]
+    public async Task<IActionResult> ChangeStatus(int rid, [FromQuery] ReservationStatus status)
+    {
+        await _reservationService.ChangeReservationStatus(rid, status);
+        return Ok();
+    }
+}
Index: backend/Controllers/RestaurantsController.cs
===================================================================
--- backend/Controllers/RestaurantsController.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/Controllers/RestaurantsController.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,39 @@
+﻿namespace backend.Controllers;
+
+using backend.DTOs;
+using backend.Entities;
+using backend.Helpers;
+using backend.Models;
+using backend.Services;
+using Microsoft.AspNetCore.Mvc;
+using System.Security.Claims;
+
+[ApiController]
+[Route("[controller]")]
+public class RestaurantsController : ControllerBase
+{
+    private readonly IRestaurantService _restaurantService = null;
+
+    public RestaurantsController(IRestaurantService restaurantService)
+    {
+        _restaurantService = restaurantService;
+    }
+
+    [Authorize]
+    [HttpPost()]
+    public async Task<IActionResult> CreateRestaurant([FromQuery] string title)
+    {
+        var userId = (int) this.HttpContext.Items["User"];
+        await _restaurantService.CreateRestaurant(title, userId);
+
+
+        return Ok();
+    }
+
+    [HttpGet()]
+    public async Task<RestaurantResponse> GetRestaurant()
+    {
+        var response = await _restaurantService.GetRestaurant();
+        return response;
+    }
+}
Index: backend/Controllers/UsersController.cs
===================================================================
--- backend/Controllers/UsersController.cs	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/Controllers/UsersController.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -1,4 +1,5 @@
 ﻿namespace backend.Controllers;
 
+using backend.DTOs;
 using backend.Helpers;
 using backend.Models;
@@ -10,5 +11,5 @@
 public class UsersController : ControllerBase
 {
-    private IUserService _userService;
+    private readonly IUserService _userService = null;
 
     public UsersController(IUserService userService)
@@ -17,21 +18,20 @@
     }
 
-    [HttpPost("authenticate")]
-    public IActionResult Authenticate(AuthenticateRequest model)
+    [HttpPost("login")]
+    public async Task<AuthenticateResponse> Authenticate(AuthenticateRequest model)
     {
-        var response = _userService.Authenticate(model);
+        var response = await _userService.Authenticate(model);
 
         if (response == null)
-            return BadRequest(new { message = "Username or password is incorrect" });
+            throw new Exception("Email or password is incorrect");
 
-        return Ok(response);
+        return response;
     }
 
-    [Authorize]
-    [HttpGet]
-    public IActionResult GetUserById(int id)
+    [HttpPost("register")]
+    public async Task<AuthenticateResponse> Register(CreateUserRequest req)
     {
-        var users = _userService.GetById(id);
-        return Ok(users);
+        var response = await _userService.Register(req);
+        return response;
     }
 }
Index: backend/DTOs/AuthenticateRequest.cs
===================================================================
--- backend/DTOs/AuthenticateRequest.cs	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/DTOs/AuthenticateRequest.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -6,5 +6,5 @@
 {
     [Required]
-    public string Username { get; set; }
+    public string Email { get; set; }
 
     [Required]
Index: backend/DTOs/AuthenticateResponse.cs
===================================================================
--- backend/DTOs/AuthenticateResponse.cs	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/DTOs/AuthenticateResponse.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -1,3 +1,4 @@
 using backend.Entities;
+using Newtonsoft.Json;
 
 namespace backend.Models;
@@ -6,14 +7,9 @@
 public class AuthenticateResponse
 {
+    [JsonProperty]
     public int Id { get; set; }
-    public string Username { get; set; }
+    [JsonProperty]
+    public string Email { get; set; }
+    [JsonProperty]
     public string Token { get; set; }
-
-
-    public AuthenticateResponse(User user, string token)
-    {
-        Id = user.Id;
-        Username = user.Username;
-        Token = token;
-    }
 }
Index: backend/DTOs/CreateReservationRequest.cs
===================================================================
--- backend/DTOs/CreateReservationRequest.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/DTOs/CreateReservationRequest.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,27 @@
+﻿using backend.Entities;
+using Newtonsoft.Json;
+
+namespace backend.DTOs
+{
+    public class CreateReservationRequest
+    {
+        [JsonRequired]
+        [JsonProperty]
+        public DateTime StartDate { get; set; }
+        [JsonRequired]
+        [JsonProperty]
+        public ReservationPlace ReservationPlace { get; set; }
+        [JsonRequired]
+        [JsonProperty]
+        public ReservationType ReservationType { get; set; }
+        [JsonRequired]
+        [JsonProperty]
+        public int Persons { get; set; }
+        [JsonRequired]
+        [JsonProperty]
+        public string ContactName { get; set; }
+        [JsonRequired]
+        [JsonProperty]
+        public string ContactNumber { get; set; }
+    }
+}
Index: backend/DTOs/CreateUserRequest.cs
===================================================================
--- backend/DTOs/CreateUserRequest.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/DTOs/CreateUserRequest.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,13 @@
+﻿using Newtonsoft.Json;
+
+namespace backend.DTOs
+{
+    public class CreateUserRequest
+    {
+        [JsonProperty]
+        public string Email { get; set; }
+
+        [JsonProperty]
+        public string Password { get; set; }
+    }
+}
Index: backend/DTOs/ReservationResponse.cs
===================================================================
--- backend/DTOs/ReservationResponse.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/DTOs/ReservationResponse.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,25 @@
+﻿using backend.Entities;
+using Newtonsoft.Json;
+
+namespace backend.DTOs
+{
+    public class ReservationResponse
+    {
+        [JsonProperty]
+        public int Id { get; set; }
+        [JsonProperty]
+        public DateTime StartDate { get; set; }
+        [JsonProperty]
+        public ReservationPlace ReservationPlace { get; set; }
+        [JsonProperty]
+        public ReservationStatus ReservationStatus { get; set; }
+        [JsonProperty]
+        public ReservationType ReservationType { get; set; }
+        [JsonProperty]
+        public int Persons { get; set; }
+        [JsonProperty]
+        public string ContactName { get; set; }
+        [JsonProperty]
+        public string ContactNumber { get; set; }
+    }
+}
Index: backend/DTOs/RestaurantResponse.cs
===================================================================
--- backend/DTOs/RestaurantResponse.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/DTOs/RestaurantResponse.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,16 @@
+﻿using Newtonsoft.Json;
+
+namespace backend.DTOs
+{
+    public class RestaurantResponse
+    {
+        [JsonProperty]
+        public int Id { get; set; }
+        [JsonProperty]
+        public int? OwnerId { get; set; }
+        [JsonProperty]
+        public List<ReservationResponse> Reservations { get; set; }
+        [JsonProperty]
+        public string Name { get; set; }
+    }
+}
Index: backend/Entities/Reservation.cs
===================================================================
--- backend/Entities/Reservation.cs	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/Entities/Reservation.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -1,3 +1,5 @@
-﻿namespace backend.Entities
+﻿using Newtonsoft.Json;
+
+namespace backend.Entities
 {
     public class Reservation
@@ -5,4 +7,5 @@
         public int Id { get; set; }
         public DateTime StartDate { get; set; }
+        public int Persons { get; set; }
         public virtual Restaurant Restaurant { get; set; }
         public ReservationPlace ReservationPlace { get; set; }
Index: backend/Entities/Restaurant.cs
===================================================================
--- backend/Entities/Restaurant.cs	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/Entities/Restaurant.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -1,3 +1,5 @@
-﻿namespace backend.Entities
+﻿using Newtonsoft.Json;
+
+namespace backend.Entities
 {
     public class Restaurant
Index: backend/Entities/User.cs
===================================================================
--- backend/Entities/User.cs	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/Entities/User.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -1,2 +1,4 @@
+using Newtonsoft.Json;
+
 namespace backend.Entities;
 
@@ -4,6 +6,7 @@
 {
     public int Id { get; set; }
-    public string Username { get; set; }
+    public string Email { get; set; }
     public string Password { get; set; }
+    [JsonIgnore]
     public virtual Restaurant Restaurant { get; set; }
 }
Index: backend/Helpers/AuthorizeAttribute.cs
===================================================================
--- backend/Helpers/AuthorizeAttribute.cs	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/Helpers/AuthorizeAttribute.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -10,5 +10,5 @@
     public void OnAuthorization(AuthorizationFilterContext context)
     {
-        var user = (User)context.HttpContext.Items["User"];
+        var user = context.HttpContext.Items["User"];
         if (user == null)
         {
Index: backend/Helpers/JwtMiddleware.cs
===================================================================
--- backend/Helpers/JwtMiddleware.cs	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/Helpers/JwtMiddleware.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -4,5 +4,4 @@
 using Microsoft.IdentityModel.Tokens;
 using System.IdentityModel.Tokens.Jwt;
-using System.Text;
 using backend.Services;
 using backend.Helpers;
@@ -34,5 +33,5 @@
         {
             var tokenHandler = new JwtSecurityTokenHandler();
-            var key = Encoding.ASCII.GetBytes(_appSettings.Secret);
+            var key = System.Text.Encoding.ASCII.GetBytes(_appSettings.Secret);
             tokenHandler.ValidateToken(token, new TokenValidationParameters
             {
@@ -47,5 +46,5 @@
             var userId = int.Parse(jwtToken.Claims.First(x => x.Type == "id").Value);
 
-            context.Items["User"] = userService.GetById(userId);
+            context.Items["User"] = userId;
         }
         catch
Index: backend/Migrations/20220411110455_Change-Propname.Designer.cs
===================================================================
--- backend/Migrations/20220411110455_Change-Propname.Designer.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/Migrations/20220411110455_Change-Propname.Designer.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,142 @@
+﻿// <auto-generated />
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+using backend.Data;
+
+#nullable disable
+
+namespace backend.Migrations
+{
+    [DbContext(typeof(DataContext))]
+    [Migration("20220411110455_Change-Propname")]
+    partial class ChangePropname
+    {
+        protected override void BuildTargetModel(ModelBuilder modelBuilder)
+        {
+#pragma warning disable 612, 618
+            modelBuilder
+                .HasAnnotation("ProductVersion", "6.0.3")
+                .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+            modelBuilder.Entity("backend.Entities.Reservation", b =>
+                {
+                    b.Property<int>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("integer");
+
+                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+                    b.Property<string>("ContactName")
+                        .IsRequired()
+                        .HasColumnType("text");
+
+                    b.Property<string>("ContactNumber")
+                        .IsRequired()
+                        .HasColumnType("text");
+
+                    b.Property<int>("ReservationPlace")
+                        .HasColumnType("integer");
+
+                    b.Property<int>("ReservationStatus")
+                        .HasColumnType("integer");
+
+                    b.Property<int>("ReservationType")
+                        .HasColumnType("integer");
+
+                    b.Property<int>("RestaurantId")
+                        .HasColumnType("integer");
+
+                    b.Property<DateTime>("StartDate")
+                        .HasColumnType("timestamp with time zone");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("RestaurantId");
+
+                    b.ToTable("Reservations");
+                });
+
+            modelBuilder.Entity("backend.Entities.Restaurant", b =>
+                {
+                    b.Property<int>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("integer");
+
+                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+                    b.Property<string>("Name")
+                        .IsRequired()
+                        .HasColumnType("text");
+
+                    b.Property<int?>("OwnerFk")
+                        .HasColumnType("integer");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("OwnerFk")
+                        .IsUnique();
+
+                    b.ToTable("Restoraunts");
+                });
+
+            modelBuilder.Entity("backend.Entities.User", b =>
+                {
+                    b.Property<int>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("integer");
+
+                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+                    b.Property<string>("Email")
+                        .IsRequired()
+                        .HasColumnType("text");
+
+                    b.Property<string>("Password")
+                        .IsRequired()
+                        .HasColumnType("text");
+
+                    b.HasKey("Id");
+
+                    b.ToTable("Users");
+                });
+
+            modelBuilder.Entity("backend.Entities.Reservation", b =>
+                {
+                    b.HasOne("backend.Entities.Restaurant", "Restaurant")
+                        .WithMany("Reservations")
+                        .HasForeignKey("RestaurantId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Restaurant");
+                });
+
+            modelBuilder.Entity("backend.Entities.Restaurant", b =>
+                {
+                    b.HasOne("backend.Entities.User", "Owner")
+                        .WithOne("Restaurant")
+                        .HasForeignKey("backend.Entities.Restaurant", "OwnerFk");
+
+                    b.Navigation("Owner");
+                });
+
+            modelBuilder.Entity("backend.Entities.Restaurant", b =>
+                {
+                    b.Navigation("Reservations");
+                });
+
+            modelBuilder.Entity("backend.Entities.User", b =>
+                {
+                    b.Navigation("Restaurant")
+                        .IsRequired();
+                });
+#pragma warning restore 612, 618
+        }
+    }
+}
Index: backend/Migrations/20220411110455_Change-Propname.cs
===================================================================
--- backend/Migrations/20220411110455_Change-Propname.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/Migrations/20220411110455_Change-Propname.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,25 @@
+﻿using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace backend.Migrations
+{
+    public partial class ChangePropname : Migration
+    {
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.RenameColumn(
+                name: "Username",
+                table: "Users",
+                newName: "Email");
+        }
+
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.RenameColumn(
+                name: "Email",
+                table: "Users",
+                newName: "Username");
+        }
+    }
+}
Index: backend/Migrations/20220411130410_Add-Persons.Designer.cs
===================================================================
--- backend/Migrations/20220411130410_Add-Persons.Designer.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/Migrations/20220411130410_Add-Persons.Designer.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,145 @@
+﻿// <auto-generated />
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+using backend.Data;
+
+#nullable disable
+
+namespace backend.Migrations
+{
+    [DbContext(typeof(DataContext))]
+    [Migration("20220411130410_Add-Persons")]
+    partial class AddPersons
+    {
+        protected override void BuildTargetModel(ModelBuilder modelBuilder)
+        {
+#pragma warning disable 612, 618
+            modelBuilder
+                .HasAnnotation("ProductVersion", "6.0.3")
+                .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+            modelBuilder.Entity("backend.Entities.Reservation", b =>
+                {
+                    b.Property<int>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("integer");
+
+                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+                    b.Property<string>("ContactName")
+                        .IsRequired()
+                        .HasColumnType("text");
+
+                    b.Property<string>("ContactNumber")
+                        .IsRequired()
+                        .HasColumnType("text");
+
+                    b.Property<int>("Persons")
+                        .HasColumnType("integer");
+
+                    b.Property<int>("ReservationPlace")
+                        .HasColumnType("integer");
+
+                    b.Property<int>("ReservationStatus")
+                        .HasColumnType("integer");
+
+                    b.Property<int>("ReservationType")
+                        .HasColumnType("integer");
+
+                    b.Property<int>("RestaurantId")
+                        .HasColumnType("integer");
+
+                    b.Property<DateTime>("StartDate")
+                        .HasColumnType("timestamp with time zone");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("RestaurantId");
+
+                    b.ToTable("Reservations");
+                });
+
+            modelBuilder.Entity("backend.Entities.Restaurant", b =>
+                {
+                    b.Property<int>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("integer");
+
+                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+                    b.Property<string>("Name")
+                        .IsRequired()
+                        .HasColumnType("text");
+
+                    b.Property<int?>("OwnerFk")
+                        .HasColumnType("integer");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("OwnerFk")
+                        .IsUnique();
+
+                    b.ToTable("Restoraunts");
+                });
+
+            modelBuilder.Entity("backend.Entities.User", b =>
+                {
+                    b.Property<int>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("integer");
+
+                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+                    b.Property<string>("Email")
+                        .IsRequired()
+                        .HasColumnType("text");
+
+                    b.Property<string>("Password")
+                        .IsRequired()
+                        .HasColumnType("text");
+
+                    b.HasKey("Id");
+
+                    b.ToTable("Users");
+                });
+
+            modelBuilder.Entity("backend.Entities.Reservation", b =>
+                {
+                    b.HasOne("backend.Entities.Restaurant", "Restaurant")
+                        .WithMany("Reservations")
+                        .HasForeignKey("RestaurantId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Restaurant");
+                });
+
+            modelBuilder.Entity("backend.Entities.Restaurant", b =>
+                {
+                    b.HasOne("backend.Entities.User", "Owner")
+                        .WithOne("Restaurant")
+                        .HasForeignKey("backend.Entities.Restaurant", "OwnerFk");
+
+                    b.Navigation("Owner");
+                });
+
+            modelBuilder.Entity("backend.Entities.Restaurant", b =>
+                {
+                    b.Navigation("Reservations");
+                });
+
+            modelBuilder.Entity("backend.Entities.User", b =>
+                {
+                    b.Navigation("Restaurant")
+                        .IsRequired();
+                });
+#pragma warning restore 612, 618
+        }
+    }
+}
Index: backend/Migrations/20220411130410_Add-Persons.cs
===================================================================
--- backend/Migrations/20220411130410_Add-Persons.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/Migrations/20220411130410_Add-Persons.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,26 @@
+﻿using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace backend.Migrations
+{
+    public partial class AddPersons : Migration
+    {
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<int>(
+                name: "Persons",
+                table: "Reservations",
+                type: "integer",
+                nullable: false,
+                defaultValue: 0);
+        }
+
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropColumn(
+                name: "Persons",
+                table: "Reservations");
+        }
+    }
+}
Index: backend/Migrations/DataContextModelSnapshot.cs
===================================================================
--- backend/Migrations/DataContextModelSnapshot.cs	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/Migrations/DataContextModelSnapshot.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -38,4 +38,7 @@
                         .IsRequired()
                         .HasColumnType("text");
+
+                    b.Property<int>("Persons")
+                        .HasColumnType("integer");
 
                     b.Property<int>("ReservationPlace")
@@ -92,9 +95,9 @@
                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
 
-                    b.Property<string>("Password")
+                    b.Property<string>("Email")
                         .IsRequired()
                         .HasColumnType("text");
 
-                    b.Property<string>("Username")
+                    b.Property<string>("Password")
                         .IsRequired()
                         .HasColumnType("text");
Index: backend/Program.cs
===================================================================
--- backend/Program.cs	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/Program.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -4,5 +4,4 @@
 using Microsoft.EntityFrameworkCore;
 using Microsoft.OpenApi.Models;
-using Swashbuckle.AspNetCore.Swagger;
 using WebApi.Helpers;
 
@@ -11,5 +10,5 @@
 // Add services to the container.
 builder.Services.Configure<AppSettings>(builder.Configuration.GetSection("AppSettings"));
-builder.Services.AddControllers();
+builder.Services.AddControllers().AddNewtonsoftJson();
 // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
 builder.Services.AddEndpointsApiExplorer();
@@ -45,4 +44,7 @@
 });
 builder.Services.AddScoped<IUserService, UserService>();
+builder.Services.AddScoped<IRestaurantService, RestaurantService>();
+builder.Services.AddScoped<IReservationService, ReservationService>();
+builder.Services.AddScoped<ISmsService, SmsService>();
 
 builder.Services.AddDbContext<DataContext>(p => p.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
Index: backend/Services/ReservationService.cs
===================================================================
--- backend/Services/ReservationService.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/Services/ReservationService.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,51 @@
+﻿using backend.Data;
+using backend.DTOs;
+using backend.Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace backend.Services
+{
+    public interface IReservationService
+    {
+        public Task CreateReservation(CreateReservationRequest req);
+        public Task ChangeReservationStatus(int resId, ReservationStatus status);
+    }
+    public class ReservationService : IReservationService
+    {
+        private readonly DataContext _context = null;
+        private readonly ISmsService _smsService = null;
+
+        public ReservationService(DataContext context, ISmsService smsService)
+        {
+            _context = context;
+            _smsService = smsService;
+        }
+
+        public async Task ChangeReservationStatus(int resId, ReservationStatus status)
+        {
+            var reservation = await _context.Reservations.FindAsync(resId);
+            reservation.ReservationStatus = status;
+            _context.Update(reservation);
+            await _context.SaveChangesAsync();
+            _smsService.ReservationStatusUpdate(reservation.ContactName, reservation.ContactNumber, reservation.ReservationStatus);
+        }
+
+        public async Task CreateReservation(CreateReservationRequest req)
+        {
+            Restaurant res = await _context.Restoraunts.Include(x => x.Reservations).FirstOrDefaultAsync();
+            Reservation reservation = new Reservation()
+            {
+                ContactName = req.ContactName,
+                ContactNumber = req.ContactNumber,
+                ReservationPlace = req.ReservationPlace,
+                ReservationType = req.ReservationType,
+                StartDate = req.StartDate,
+                Persons = req.Persons,
+                ReservationStatus = ReservationStatus.New
+            };
+            res.Reservations.Add(reservation);
+            _context.Restoraunts.Update(res);
+            await _context.SaveChangesAsync();
+        }
+    }
+}
Index: backend/Services/RestaurantService.cs
===================================================================
--- backend/Services/RestaurantService.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/Services/RestaurantService.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,54 @@
+﻿using backend.Data;
+using backend.DTOs;
+using backend.Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace backend.Services
+{
+    public interface IRestaurantService
+    {
+        public Task CreateRestaurant(string name, int userId);
+        public Task<RestaurantResponse> GetRestaurant();
+    }
+    public class RestaurantService : IRestaurantService
+    {
+        private readonly DataContext _context = null;
+
+        public RestaurantService(DataContext context)
+        {
+            _context = context;
+        }
+        public async Task CreateRestaurant(string name, int userId)
+        {
+            User user = await _context.Users.FindAsync(userId);
+            Restaurant restaurant = new Restaurant() { Name = name, Owner = user};
+            await _context.Restoraunts.AddAsync(restaurant);
+            await _context.SaveChangesAsync();
+        }
+
+        public async Task<RestaurantResponse> GetRestaurant()
+        {
+            RestaurantResponse res = await _context.Restoraunts
+                .Include(x => x.Reservations)
+                .Select(x => new RestaurantResponse()
+                {
+                    Id = x.Id,
+                    Name = x.Name,
+                    OwnerId = x.OwnerFk,
+                    Reservations = x.Reservations.Select(t => new ReservationResponse()
+                    {
+                        ContactName = t.ContactName,
+                        ContactNumber = t.ContactNumber,
+                        Persons = t.Persons,
+                        StartDate = t.StartDate,
+                        ReservationStatus = t.ReservationStatus,
+                        Id = t.Id,
+                        ReservationPlace = t.ReservationPlace,
+                        ReservationType = t.ReservationType
+                    }).ToList()
+                })
+                .FirstOrDefaultAsync();
+            return res;
+        }
+    }
+}
Index: backend/Services/SmsService.cs
===================================================================
--- backend/Services/SmsService.cs	(revision 057037b3df07d92e2be689285380664471687a07)
+++ backend/Services/SmsService.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -0,0 +1,20 @@
+﻿using backend.Entities;
+
+namespace backend.Services
+{
+    public interface ISmsService
+    {
+        public Task ReservationStatusUpdate(string name, string number, ReservationStatus newStatus);
+    }
+    public class SmsService : ISmsService
+    {
+        public async Task ReservationStatusUpdate(string name, string number, ReservationStatus newStatus)
+        {
+            string message = $"Hello {name}, the status of your reservation was changed to: { Enum.GetName(typeof(ReservationStatus), newStatus)}";
+
+            // simulate sending sms
+            await Task.Delay(100);
+            Console.WriteLine(message);
+        }
+    }
+}
Index: backend/Services/UserService.cs
===================================================================
--- backend/Services/UserService.cs	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/Services/UserService.cs	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -1,37 +1,36 @@
 namespace backend.Services;
 
+using backend.Data;
+using backend.DTOs;
 using backend.Entities;
 using backend.Helpers;
 using backend.Models;
+using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Options;
 using Microsoft.IdentityModel.Tokens;
 using System.IdentityModel.Tokens.Jwt;
 using System.Security.Claims;
-using System.Text;
 
 public interface IUserService
 {
-    AuthenticateResponse Authenticate(AuthenticateRequest model);
-    User GetById(int id);
+    Task<AuthenticateResponse> Authenticate(AuthenticateRequest model);
+    Task<AuthenticateResponse> Register(CreateUserRequest req);
+    Task<User> GetById(int id);
 }
 
 public class UserService : IUserService
 {
-    // users hardcoded for simplicity, store in a db with hashed passwords in production applications
-    private List<User> _users = new List<User>
-    {
-        new User { Id = 1, Username = "test", Password = "test" }
-    };
+    private readonly AppSettings _appSettings;
+    private readonly DataContext _context = null;
 
-    private readonly AppSettings _appSettings;
-
-    public UserService(IOptions<AppSettings> appSettings)
+    public UserService(IOptions<AppSettings> appSettings, DataContext context)
     {
         _appSettings = appSettings.Value;
+        _context = context;
     }
 
-    public AuthenticateResponse Authenticate(AuthenticateRequest model)
+    public async Task<AuthenticateResponse> Authenticate(AuthenticateRequest model)
     {
-        var user = _users.SingleOrDefault(x => x.Username == model.Username && x.Password == model.Password);
+        User user = await _context.Users.FirstOrDefaultAsync(x => x.Email == model.Email && x.Password == model.Password);
 
         // return null if user not found
@@ -41,10 +40,19 @@
         var token = generateJwtToken(user);
 
-        return new AuthenticateResponse(user, token);
+        return new AuthenticateResponse { Email = user.Email, Id = user.Id, Token = token};
     }
 
-    public User GetById(int id)
+    public async Task<User> GetById(int id)
     {
-        return _users.FirstOrDefault(x => x.Id == id);
+        return await _context.Users.FindAsync(id);
+    }
+
+    public async Task<AuthenticateResponse> Register(CreateUserRequest req)
+    {
+        User user = new User() { Email = req.Email, Password = req.Password };
+        await _context.Users.AddAsync(user);
+        await _context.SaveChangesAsync();
+        var token = generateJwtToken(user);
+        return new AuthenticateResponse { Email = user.Email, Id = user.Id, Token = token };
     }
 
@@ -53,5 +61,5 @@
         // generate token that is valid for 7 days
         var tokenHandler = new JwtSecurityTokenHandler();
-        var key = Encoding.ASCII.GetBytes(_appSettings.Secret);
+        var key = System.Text.Encoding.ASCII.GetBytes(_appSettings.Secret);
         var tokenDescriptor = new SecurityTokenDescriptor
         {
Index: backend/backend.csproj
===================================================================
--- backend/backend.csproj	(revision b66b3acb77c10d451916af5571fc0b31168ad254)
+++ backend/backend.csproj	(revision 057037b3df07d92e2be689285380664471687a07)
@@ -8,5 +8,10 @@
 
   <ItemGroup>
+    <None Include="..\.editorconfig" Link=".editorconfig" />
+  </ItemGroup>
+
+  <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.3" />
+    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.3" />
     <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.3" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.3">
