Pārlūkot izejas kodu

Merge commit

master
George Williams 4 gadus atpakaļ
vecāks
revīzija
b7bec88aa9

+ 1
- 0
UnivateProperties_API/Context/DataContext.cs Parādīt failu

@@ -89,6 +89,7 @@ namespace UnivateProperties_API.Context
89 89
 
90 90
         #region Payments
91 91
         public DbSet<Payment> Payments { get; set; }
92
+        public DbSet<ListingFee> ListingFees { get; set; }
92 93
         #endregion
93 94
 
94 95
         #region Campaign

+ 57
- 0
UnivateProperties_API/Controllers/Financial/FeesController.cs Parādīt failu

@@ -0,0 +1,57 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using UnivateProperties_API.Model.Financial;
8
+using UnivateProperties_API.Repository.Financial;
9
+
10
+namespace UnivateProperties_API.Controllers.Financial
11
+{
12
+    [Route("api/[controller]")]
13
+    [ApiController]
14
+    public class FeesController : ControllerBase
15
+    {
16
+        private readonly IListingRepository _repo;
17
+
18
+        public FeesController(IListingRepository rp)
19
+        {
20
+            _repo = rp;
21
+        }
22
+
23
+        // GET: api/Fees/listingFee
24
+        [HttpGet("listingFee")]
25
+        public IActionResult Get()
26
+        {
27
+            return new OkObjectResult(_repo.GetListingFee());
28
+        }
29
+
30
+        // POST: api/Fees
31
+        [HttpPost("listingFee")]
32
+        public IActionResult Post([FromBody] ListingFee fee)
33
+        {
34
+            var feeObj = _repo.insertListingFee(fee);
35
+            if (feeObj != null)
36
+            {
37
+                return new OkObjectResult(fee);
38
+            }
39
+            else
40
+            {
41
+                return new NoContentResult();
42
+            }
43
+        }
44
+
45
+        // PUT: api/Fees/5
46
+        [HttpPut("{id}")]
47
+        public void Put(int id, [FromBody] string value)
48
+        {
49
+        }
50
+
51
+        // DELETE: api/ApiWithActions/5
52
+        [HttpDelete("{id}")]
53
+        public void Delete(int id)
54
+        {
55
+        }
56
+    }
57
+}

+ 1590
- 0
UnivateProperties_API/Migrations/20200910134303_ListingFees.Designer.cs
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 31
- 0
UnivateProperties_API/Migrations/20200910134303_ListingFees.cs Parādīt failu

@@ -0,0 +1,31 @@
1
+using Microsoft.EntityFrameworkCore.Metadata;
2
+using Microsoft.EntityFrameworkCore.Migrations;
3
+
4
+namespace UnivateProperties_API.Migrations
5
+{
6
+    public partial class ListingFees : Migration
7
+    {
8
+        protected override void Up(MigrationBuilder migrationBuilder)
9
+        {
10
+            migrationBuilder.CreateTable(
11
+                name: "ListingFees",
12
+                columns: table => new
13
+                {
14
+                    Id = table.Column<int>(nullable: false)
15
+                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
16
+                    Amount = table.Column<double>(nullable: false),
17
+                    Name = table.Column<string>(nullable: true)
18
+                },
19
+                constraints: table =>
20
+                {
21
+                    table.PrimaryKey("PK_ListingFees", x => x.Id);
22
+                });
23
+        }
24
+
25
+        protected override void Down(MigrationBuilder migrationBuilder)
26
+        {
27
+            migrationBuilder.DropTable(
28
+                name: "ListingFees");
29
+        }
30
+    }
31
+}

+ 1592
- 0
UnivateProperties_API/Migrations/20200910135810_ListingFees1.Designer.cs
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 23
- 0
UnivateProperties_API/Migrations/20200910135810_ListingFees1.cs Parādīt failu

@@ -0,0 +1,23 @@
1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class ListingFees1 : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.AddColumn<bool>(
10
+                name: "IsDeleted",
11
+                table: "ListingFees",
12
+                nullable: false,
13
+                defaultValue: false);
14
+        }
15
+
16
+        protected override void Down(MigrationBuilder migrationBuilder)
17
+        {
18
+            migrationBuilder.DropColumn(
19
+                name: "IsDeleted",
20
+                table: "ListingFees");
21
+        }
22
+    }
23
+}

+ 1592
- 0
UnivateProperties_API/Migrations/20200910140429_ListingFees2.Designer.cs
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 17
- 0
UnivateProperties_API/Migrations/20200910140429_ListingFees2.cs Parādīt failu

@@ -0,0 +1,17 @@
1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class ListingFees2 : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+
10
+        }
11
+
12
+        protected override void Down(MigrationBuilder migrationBuilder)
13
+        {
14
+
15
+        }
16
+    }
17
+}

+ 1598
- 0
UnivateProperties_API/Migrations/20200910140623_ListingFees3.Designer.cs
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 43
- 0
UnivateProperties_API/Migrations/20200910140623_ListingFees3.cs Parādīt failu

@@ -0,0 +1,43 @@
1
+using System;
2
+using Microsoft.EntityFrameworkCore.Migrations;
3
+
4
+namespace UnivateProperties_API.Migrations
5
+{
6
+    public partial class ListingFees3 : Migration
7
+    {
8
+        protected override void Up(MigrationBuilder migrationBuilder)
9
+        {
10
+            migrationBuilder.AddColumn<DateTime>(
11
+                name: "Created",
12
+                table: "ListingFees",
13
+                nullable: false,
14
+                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
15
+
16
+            migrationBuilder.AddColumn<DateTime>(
17
+                name: "Modified",
18
+                table: "ListingFees",
19
+                nullable: false,
20
+                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
21
+
22
+            migrationBuilder.AddColumn<string>(
23
+                name: "ModifiedBy",
24
+                table: "ListingFees",
25
+                nullable: true);
26
+        }
27
+
28
+        protected override void Down(MigrationBuilder migrationBuilder)
29
+        {
30
+            migrationBuilder.DropColumn(
31
+                name: "Created",
32
+                table: "ListingFees");
33
+
34
+            migrationBuilder.DropColumn(
35
+                name: "Modified",
36
+                table: "ListingFees");
37
+
38
+            migrationBuilder.DropColumn(
39
+                name: "ModifiedBy",
40
+                table: "ListingFees");
41
+        }
42
+    }
43
+}

+ 23
- 0
UnivateProperties_API/Migrations/DataContextModelSnapshot.cs Parādīt failu

@@ -352,6 +352,29 @@ namespace UnivateProperties_API.Migrations
352 352
                     b.ToTable("Templates");
353 353
                 });
354 354
 
355
+            modelBuilder.Entity("UnivateProperties_API.Model.Financial.ListingFee", b =>
356
+                {
357
+                    b.Property<int>("Id")
358
+                        .ValueGeneratedOnAdd()
359
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
360
+
361
+                    b.Property<double>("Amount");
362
+
363
+                    b.Property<DateTime>("Created");
364
+
365
+                    b.Property<bool>("IsDeleted");
366
+
367
+                    b.Property<DateTime>("Modified");
368
+
369
+                    b.Property<string>("ModifiedBy");
370
+
371
+                    b.Property<string>("Name");
372
+
373
+                    b.HasKey("Id");
374
+
375
+                    b.ToTable("ListingFees");
376
+                });
377
+
355 378
             modelBuilder.Entity("UnivateProperties_API.Model.Financial.Payment", b =>
356 379
                 {
357 380
                     b.Property<int>("Id")

+ 11
- 0
UnivateProperties_API/Model/Financial/ListingFee.cs Parādīt failu

@@ -0,0 +1,11 @@
1
+using System.ComponentModel.DataAnnotations;
2
+using System.ComponentModel.DataAnnotations.Schema;
3
+
4
+namespace UnivateProperties_API.Model.Financial
5
+{
6
+    public class ListingFee : BaseEntity
7
+    {
8
+        public double Amount {get; set;}
9
+        public string Name { get; set; }
10
+    }
11
+}

+ 57
- 0
UnivateProperties_API/Repository/Financial/ListingRepository.cs Parādīt failu

@@ -0,0 +1,57 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using UnivateProperties_API.Context;
6
+using UnivateProperties_API.Model.Financial;
7
+
8
+namespace UnivateProperties_API.Repository.Financial
9
+{
10
+    public interface IListingRepository
11
+    {
12
+        ListingFee insertListingFee(ListingFee fee);
13
+        ListingFee GetListingFee();
14
+    }
15
+
16
+    public class ListingRepository : IListingRepository
17
+    {
18
+        private readonly DataContext _dbContext;
19
+
20
+        public ListingRepository(DataContext db)
21
+        {
22
+            _dbContext = db;
23
+        }
24
+
25
+        public ListingFee insertListingFee(ListingFee fee)
26
+        {
27
+            var hasFee = _dbContext.ListingFees.FirstOrDefault();
28
+            if (fee != null)
29
+            {
30
+                if (hasFee == null)
31
+                {
32
+                    _dbContext.ListingFees.Add(fee);
33
+                    _dbContext.SaveChanges();
34
+                    return fee;
35
+                }
36
+                else
37
+                {
38
+                    fee.Id = 1;
39
+                    _dbContext.ListingFees.Update(fee);
40
+                    _dbContext.SaveChanges();
41
+                    return fee;
42
+                }
43
+                
44
+            }
45
+            else
46
+            {
47
+                return null;
48
+            }
49
+            
50
+        }
51
+
52
+        public ListingFee GetListingFee()
53
+        {
54
+            return _dbContext.ListingFees.FirstOrDefault();
55
+        }
56
+    }
57
+}

+ 1
- 0
UnivateProperties_API/Startup.cs Parādīt failu

@@ -158,6 +158,7 @@ namespace UnivateProperties_API
158 158
             #endregion
159 159
             #region Financial 
160 160
             services.AddTransient<IPaygateRepository, PaygateRepository>();
161
+            services.AddTransient<IListingRepository, ListingRepository>(); 
161 162
             #endregion
162 163
             #region Misc
163 164
             services.AddTransient<ICarouselRepository, CarouselRepository>();

Notiek ielāde…
Atcelt
Saglabāt