First Initial
This commit is contained in:
52
Common/CommonMethod.cs
Normal file
52
Common/CommonMethod.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
using TodoAPI2.Models;
|
||||
using TTSW.EF;
|
||||
|
||||
namespace TestAPI01.Common
|
||||
{
|
||||
public class CommonMethod
|
||||
{
|
||||
public string Month_th(int i)
|
||||
{
|
||||
string[] month = new string[] { "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม" };
|
||||
|
||||
return month[i - 1];
|
||||
}
|
||||
|
||||
public string shortMonth_th(int i)
|
||||
{
|
||||
string[] month = new string[] { "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค." };
|
||||
|
||||
return month[i - 1];
|
||||
}
|
||||
|
||||
public string Month_en(int i)
|
||||
{
|
||||
string[] month = new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
|
||||
|
||||
return month[i - 1];
|
||||
}
|
||||
|
||||
public string shortMonth_en(int i)
|
||||
{
|
||||
string[] month = new string[] { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };
|
||||
|
||||
return month[i - 1];
|
||||
}
|
||||
|
||||
public string Year_th(int i)
|
||||
{
|
||||
var year = i + 543;
|
||||
|
||||
return year.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Common/LoginProfile.cs
Normal file
22
Common/LoginProfile.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TodoAPI2.Models
|
||||
{
|
||||
public class LoginProfile
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public Guid? CustomerGUID { get; set; }
|
||||
public Guid UserGUID { get; set; }
|
||||
public string permission_level { get; set; }
|
||||
public string base_system { get; set; }
|
||||
public string fullnameEng { get; set; }
|
||||
public string positionEng { get; set; }
|
||||
}
|
||||
}
|
||||
30
Common/NotificationException.cs
Normal file
30
Common/NotificationException.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TTSW.Common
|
||||
{
|
||||
[Serializable]
|
||||
public class NotificationException : Exception
|
||||
{
|
||||
public NotificationException()
|
||||
: base() { }
|
||||
|
||||
public NotificationException(string message)
|
||||
: base(message) { }
|
||||
|
||||
public NotificationException(string format, params object[] args)
|
||||
: base(string.Format(format, args)) { }
|
||||
|
||||
public NotificationException(string message, Exception innerException)
|
||||
: base(message, innerException) { }
|
||||
|
||||
public NotificationException(string format, Exception innerException, params object[] args)
|
||||
: base(string.Format(format, args), innerException) { }
|
||||
|
||||
protected NotificationException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
}
|
||||
}
|
||||
33
Common/SwaggerFileUploadOperation.cs
Normal file
33
Common/SwaggerFileUploadOperation.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TTSW.Common
|
||||
{
|
||||
public class SwaggerFileUploadOperation : IOperationFilter
|
||||
{
|
||||
// Add options for web api needed upload file controls
|
||||
// http://www.talkingdotnet.com/how-to-upload-file-via-swagger-in-asp-net-core-web-api/
|
||||
|
||||
public void Apply(Operation operation, OperationFilterContext context)
|
||||
{
|
||||
// Map to HttpPost api/Attachment/UploadMultipleFiles
|
||||
if (operation.OperationId.ToLower() == "upload" && operation.Tags[0].ToLower() == "attach_file")
|
||||
{
|
||||
operation.Parameters.Clear();
|
||||
operation.Parameters.Add(new NonBodyParameter
|
||||
{
|
||||
Name = "file",
|
||||
In = "formData",
|
||||
Description = "Upload File",
|
||||
Required = true,
|
||||
Type = "file"
|
||||
});
|
||||
operation.Consumes.Add("multipart/form-data");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user