Skip to content

Commit 56d7d87

Browse files
authored
Merge pull request #134 from Gid733/master
Minor fixes
2 parents 3536340 + d6319b4 commit 56d7d87

File tree

71 files changed

+1591
-1260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1591
-1260
lines changed

eFormAPI/eFormAPI/App_Start/SwaggerConfig.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using System.Web.Http;
45
using System.Web.Http.Description;
@@ -9,15 +10,17 @@ namespace eFormAPI.Web
910
{
1011
public static class SwaggerConfig
1112
{
12-
public static void Register(HttpConfiguration _configuration)
13+
public static void Register(HttpConfiguration configuration)
1314
{
14-
_configuration.EnableSwagger(c =>
15+
configuration.EnableSwagger(c =>
1516
{
1617
c.SingleApiVersion("v1", "Eform API");
1718
c.IncludeXmlComments($@"{System.AppDomain.CurrentDomain.BaseDirectory}\bin\API.docs.xml");
1819
c.DescribeAllEnumsAsStrings();
1920
c.DocumentFilter<AuthTokenOperation>();
2021
c.OperationFilter<AddAuthorizationHeader>();
22+
c.UseFullTypeNameInSchemaIds();
23+
c.SchemaId(x => x.FullName + Guid.NewGuid());
2124
}).EnableSwaggerUi();
2225
}
2326
}

eFormAPI/eFormAPI/Controllers/EntitySearchController.cs

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public OperationDataResult<EntityGroupList> GetEntityGroupList(
3333
}
3434
catch (Exception)
3535
{
36-
return new OperationDataResult<EntityGroupList>(false, LocaleHelper.GetString("SearchableListLoadingFailed"));
36+
return new OperationDataResult<EntityGroupList>(false,
37+
LocaleHelper.GetString("SearchableListLoadingFailed"));
3738
}
3839
}
3940

@@ -51,15 +52,19 @@ public OperationResult CreateEntityGroup(AdvEntitySearchableGroupEditModel editM
5152
var nextItemUid = entityGroup.EntityGroupItemLst.Count;
5253
foreach (var entityItem in editModel.AdvEntitySearchableItemModels)
5354
{
54-
core.EntitySearchItemCreate(entityGroup.Id, entityItem.Name, entityItem.Description, nextItemUid.ToString());
55+
core.EntitySearchItemCreate(entityGroup.Id, entityItem.Name, entityItem.Description,
56+
nextItemUid.ToString());
5557

5658
//entityGroup.EntityGroupItemLst.Add(new EntityItem(entityItem.Name,
5759
// entityItem.Description, nextItemUid.ToString(), Constants.WorkflowStates.Created));
5860
nextItemUid++;
5961
}
62+
6063
//core.EntityGroupUpdate(entityGroup);
6164
}
62-
return new OperationResult(true, LocaleHelper.GetString("ParamCreatedSuccessfully", groupCreate.MicrotingUUID));
65+
66+
return new OperationResult(true,
67+
LocaleHelper.GetString("ParamCreatedSuccessfully", groupCreate.MicrotingUUID));
6368
}
6469
catch (Exception)
6570
{
@@ -76,34 +81,37 @@ public OperationResult UpdateEntityGroup(AdvEntitySearchableGroupEditModel editM
7681
var core = _coreHelper.GetCore();
7782
var entityGroup = core.EntityGroupRead(editModel.GroupUid);
7883

79-
if (editModel.AdvEntitySearchableItemModels.Any())
80-
{
81-
var nextItemUid = entityGroup.EntityGroupItemLst.Count;
82-
List<int> currentIds = new List<int>();
84+
var nextItemUid = entityGroup.EntityGroupItemLst.Count;
85+
List<int> currentIds = new List<int>();
8386

84-
foreach (var entityItem in editModel.AdvEntitySearchableItemModels)
87+
foreach (var entityItem in editModel.AdvEntitySearchableItemModels)
88+
{
89+
if (string.IsNullOrEmpty(entityItem.MicrotingUUID))
8590
{
86-
if (string.IsNullOrEmpty(entityItem.MicrotingUUID))
87-
{
88-
EntityItem et = core.EntitySearchItemCreate(entityGroup.Id, entityItem.Name, entityItem.Description, nextItemUid.ToString());
89-
currentIds.Add(et.Id);
90-
}
91-
else
92-
{
93-
core.EntityItemUpdate(entityItem.Id, entityItem.Name, entityItem.Description, entityItem.EntityItemUId, entityItem.DisplayIndex);
94-
currentIds.Add(entityItem.Id);
95-
}
96-
nextItemUid++;
91+
EntityItem et = core.EntitySearchItemCreate(entityGroup.Id, entityItem.Name,
92+
entityItem.Description, nextItemUid.ToString());
93+
currentIds.Add(et.Id);
9794
}
98-
foreach (EntityItem entityItem in entityGroup.EntityGroupItemLst)
95+
else
9996
{
100-
if (!currentIds.Contains(entityItem.Id))
101-
{
102-
core.EntityItemDelete(entityItem.Id);
103-
}
97+
core.EntityItemUpdate(entityItem.Id, entityItem.Name, entityItem.Description,
98+
entityItem.EntityItemUId, entityItem.DisplayIndex);
99+
currentIds.Add(entityItem.Id);
100+
}
101+
102+
nextItemUid++;
103+
}
104+
105+
foreach (EntityItem entityItem in entityGroup.EntityGroupItemLst)
106+
{
107+
if (!currentIds.Contains(entityItem.Id))
108+
{
109+
core.EntityItemDelete(entityItem.Id);
104110
}
105111
}
106-
return new OperationResult(true, LocaleHelper.GetString("ParamUpdatedSuccessfully", editModel.GroupUid));
112+
113+
return new OperationResult(true,
114+
LocaleHelper.GetString("ParamUpdatedSuccessfully", editModel.GroupUid));
107115
}
108116
catch (Exception)
109117
{
@@ -125,7 +133,8 @@ public OperationDataResult<EntityGroup> GetEntityGroup(string entityGroupUid)
125133
}
126134
catch (Exception)
127135
{
128-
return new OperationDataResult<EntityGroup>(false, LocaleHelper.GetString("ErrorWhenObtainingSearchableList"));
136+
return new OperationDataResult<EntityGroup>(false,
137+
LocaleHelper.GetString("ErrorWhenObtainingSearchableList"));
129138
}
130139
}
131140

eFormAPI/eFormAPI/Infrastructure/Helpers/CaseUpdateHelper.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Linq;
45
using eFormAPI.Web.Infrastructure.Models.Cases.Request;
6+
using OfficeOpenXml.FormulaParsing.Excel.Functions.Database;
57

68
namespace eFormAPI.Web.Infrastructure.Helpers
79
{
@@ -22,6 +24,7 @@ public static List<string> GetStatusByEditRequest(CaseEditRequest editRequest)
2224
list.Add($"{editRequest.Id}|review");
2325
break;
2426
}
27+
2528
return list;
2629
}
2730

@@ -47,6 +50,7 @@ public static List<string> GetFieldValuesByRequestField(CaseEditRequestField edi
4750
string val = $"{checkBoxfirst.FieldId}|{checkBoxfirst.Value.ToString()}";
4851
list.Add(val);
4952
}
53+
5054
break;
5155
case "Comment":
5256
var commentFirst = editRequestField?.FieldValues?.First();
@@ -55,6 +59,7 @@ public static List<string> GetFieldValuesByRequestField(CaseEditRequestField edi
5559
string val = $"{commentFirst.FieldId}|{commentFirst.Value.ToString()}";
5660
list.Add(val);
5761
}
62+
5863
break;
5964
case "Number":
6065
var numberFirst = editRequestField?.FieldValues?.First();
@@ -63,6 +68,7 @@ public static List<string> GetFieldValuesByRequestField(CaseEditRequestField edi
6368
string val = $"{numberFirst.FieldId}|{numberFirst.Value.ToString()}";
6469
list.Add(val);
6570
}
71+
6672
break;
6773
case "Text":
6874
var textFirst = editRequestField?.FieldValues?.First();
@@ -71,25 +77,32 @@ public static List<string> GetFieldValuesByRequestField(CaseEditRequestField edi
7177
string val = $"{textFirst.FieldId}|{textFirst.Value.ToString()}";
7278
list.Add(val);
7379
}
80+
7481
break;
7582
case "Date":
7683
var dateFirst = editRequestField?.FieldValues?.First();
7784
if (dateFirst?.Value != null && dateFirst?.FieldId != null)
7885
{
7986
try
8087
{
81-
DateTime currentDate = (DateTime)dateFirst.Value;
82-
if (currentDate != null)
88+
var dateResult =
89+
DateTime.TryParseExact(dateFirst.Value.ToString(),
90+
"yyyy-MM-dd",
91+
null,
92+
DateTimeStyles.None,
93+
out DateTime date);
94+
if (dateResult)
8395
{
84-
string val = $"{dateFirst.FieldId}|{currentDate:yyyy-MM-dd}";
96+
var val = $"{dateFirst.FieldId}|{date:yyyy-MM-dd}";
8597
list.Add(val);
8698
}
8799
}
88-
catch
100+
catch (Exception e)
89101
{
90-
// ignored
102+
Console.WriteLine(e);
91103
}
92104
}
105+
93106
break;
94107
case "SingleSelect":
95108
var singleSelect = editRequestField?.FieldValues?.First();
@@ -98,6 +111,7 @@ public static List<string> GetFieldValuesByRequestField(CaseEditRequestField edi
98111
string val = $"{singleSelect.FieldId}|{singleSelect.Value.ToString()}";
99112
list.Add(val);
100113
}
114+
101115
break;
102116
case "EntitySearch":
103117
var entitySearch = editRequestField?.FieldValues?.First();
@@ -106,6 +120,7 @@ public static List<string> GetFieldValuesByRequestField(CaseEditRequestField edi
106120
string val = $"{entitySearch.FieldId}|{entitySearch.Value.ToString()}";
107121
list.Add(val);
108122
}
123+
109124
break;
110125
case "EntitySelect":
111126
var entitySelect = editRequestField?.FieldValues?.First();
@@ -114,6 +129,7 @@ public static List<string> GetFieldValuesByRequestField(CaseEditRequestField edi
114129
string val = $"{entitySelect.FieldId}|{entitySelect.Value.ToString()}";
115130
list.Add(val);
116131
}
132+
117133
break;
118134
case "MultiSelect":
119135
var multiFirst = editRequestField?.FieldValues?.First();
@@ -122,6 +138,7 @@ public static List<string> GetFieldValuesByRequestField(CaseEditRequestField edi
122138
string val = $"{multiFirst.FieldId}|{multiFirst.Value.ToString()}";
123139
list.Add(val);
124140
}
141+
125142
break;
126143
case "Audio":
127144
var audioFirst = editRequestField?.FieldValues?.First();
@@ -130,8 +147,10 @@ public static List<string> GetFieldValuesByRequestField(CaseEditRequestField edi
130147
string val = $"{audioFirst.FieldId}|{audioFirst.Value.ToString()}";
131148
list.Add(val);
132149
}
150+
133151
break;
134152
}
153+
135154
return list;
136155
}
137156

eFormAPI/eFormAPI/Infrastructure/Identity/Providers/ApplicationOAuthProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwner
7777
var oAuthIdentity = await user.GenerateUserIdentityAsync(userManager,
7878
OAuthDefaults.AuthenticationType);
7979

80+
var cookiesIdentity = await user.GenerateUserIdentityAsync(userManager,
81+
CookieAuthenticationDefaults.AuthenticationType);
82+
8083
// Add custom claims
8184
if (!user.Locale.IsNullOrEmpty())
8285
{
8386
oAuthIdentity.AddClaim(new Claim("locale", user.Locale));
87+
cookiesIdentity.AddClaim(new Claim("locale", user.Locale));
8488
}
85-
86-
87-
var cookiesIdentity = await user.GenerateUserIdentityAsync(userManager,
88-
CookieAuthenticationDefaults.AuthenticationType);
8989

9090
var properties = CreateProperties(user, role);
9191
var ticket = new AuthenticationTicket(oAuthIdentity, properties);

0 commit comments

Comments
 (0)