添加项目文件。

This commit is contained in:
luoyunchong
2020-08-09 14:50:47 +08:00
parent 5d21b53ae2
commit 483c410943
51 changed files with 2367 additions and 0 deletions

View File

@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Mvc;
namespace Basic.Controllers
{
[Produces("application/json")]
public class JsonAnnotationsController
{
[HttpGet("/promotions")]
public IEnumerable<Promotion> GetPromotions()
{
return new[]
{
new Promotion { Code = "A", DiscountType = DiscountType.Amount, Discount = 30 },
new Promotion { Code = "B", DiscountType = DiscountType.Percentage, Discount = 10 }
};
}
}
public class Promotion
{
[JsonPropertyName("promo-code")]
public string Code { get; set; }
public DiscountType DiscountType { get; set; }
[JsonIgnore]
public int Discount { get; set; }
}
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum DiscountType
{
Percentage,
Amount
}
}