There were some bugs.

dotnetflags
C-xC-c 5 years ago
parent dc88b5ccf1
commit f3bc243690

@ -29,11 +29,11 @@ namespace BantFlags.Data
public enum Method public enum Method
{ {
Delete, Add = 0,
Rename, Delete = 1,
Add Rename = 2
} }
public class Flag public class Flag

@ -51,7 +51,6 @@
<br /> <br />
<button type="submit">Remove from staging</button> <button type="submit">Remove from staging</button>
<h3>Deleted Flags</h3> <h3>Deleted Flags</h3>
@* TODO: There has to be a better way to handle this*@
@for (int i = 0; i < Model.StagedFlags.Flags.Count(); i++) @for (int i = 0; i < Model.StagedFlags.Flags.Count(); i++)
{ {
if (Model.StagedFlags.Flags[i].FlagMethod == Method.Delete) if (Model.StagedFlags.Flags[i].FlagMethod == Method.Delete)
@ -61,7 +60,7 @@
<label>@(Model.StagedFlags.Flags[i].Name)</label> <label>@(Model.StagedFlags.Flags[i].Name)</label>
<img src="~/flags/@(Model.StagedFlags.Flags[i].Name).png" /> <img src="~/flags/@(Model.StagedFlags.Flags[i].Name).png" />
<input type="hidden" name="flags[@i].Name" value="@Model.StagedFlags.Flags[i].Name" /> <input type="hidden" name="flags[@i].Name" value="@Model.StagedFlags.Flags[i].Name" />
<input type="hidden" name="flags[@i].FormMethod" value="@Model.StagedFlags.Flags[i].FlagMethod" /> <input type="hidden" name="flags[@i].FlagMethod" value="@Model.StagedFlags.Flags[i].FlagMethod" />
<input type="checkbox" name="flags[@i].IsChecked" value="true" /> <input type="checkbox" name="flags[@i].IsChecked" value="true" />
</div> </div>
} }
@ -77,7 +76,7 @@
<label>@(Model.StagedFlags.Flags[i].Name)</label> <label>@(Model.StagedFlags.Flags[i].Name)</label>
<img src="~/flags/@(Model.StagedFlags.Flags[i].OldName).png" /> <img src="~/flags/@(Model.StagedFlags.Flags[i].OldName).png" />
<input type="hidden" name="flags[@i].Name" value="@Model.StagedFlags.Flags[i].Name" /> <input type="hidden" name="flags[@i].Name" value="@Model.StagedFlags.Flags[i].Name" />
<input type="hidden" name="flags[@i].FormMethod" value="@Model.StagedFlags.Flags[i].FlagMethod" /> <input type="hidden" name="flags[@i].FlagMethod" value="@Model.StagedFlags.Flags[i].FlagMethod" />
<input type="checkbox" name="flags[@i].IsChecked" value="true" /> <input type="checkbox" name="flags[@i].IsChecked" value="true" />
</div> </div>
} }
@ -93,7 +92,7 @@
<label>@(Model.StagedFlags.Flags[i].Name)</label> <label>@(Model.StagedFlags.Flags[i].Name)</label>
<img src="~/flags/staging/@(Model.StagedFlags.Flags[i].Name).png" /> <img src="~/flags/staging/@(Model.StagedFlags.Flags[i].Name).png" />
<input type="hidden" name="flags[@i].Name" value="@Model.StagedFlags.Flags[i].Name" /> <input type="hidden" name="flags[@i].Name" value="@Model.StagedFlags.Flags[i].Name" />
<input type="hidden" name="flags[@i].FormMethod" value="@Model.StagedFlags.Flags[i].FlagMethod" /> <input type="hidden" name="flags[@i].FlagMethod" value="@Model.StagedFlags.Flags[i].FlagMethod" />
<input type="checkbox" name="flags[@i].IsChecked" value="true" /> <input type="checkbox" name="flags[@i].IsChecked" value="true" />
</div> </div>
} }

@ -60,6 +60,7 @@ namespace BantFlags
StagedFlags.Flags.Add(stagingFlag.Value); StagedFlags.Flags.Add(stagingFlag.Value);
StagedFlags.Names.Remove(stagingFlag.Value.OldName); StagedFlags.Names.Remove(stagingFlag.Value.OldName);
StagedFlags.Names.Add(stagingFlag.Value.Name);
Message = $"{stagingFlag.Value.OldName} renamed to {stagingFlag.Value.Name}."; Message = $"{stagingFlag.Value.OldName} renamed to {stagingFlag.Value.Name}.";
return Page(); return Page();
@ -130,6 +131,7 @@ namespace BantFlags
break; break;
case Method.Rename: case Method.Rename:
StagedFlags.Names.Remove(flag.Name);
StagedFlags.Names.Add(flag.OldName); StagedFlags.Names.Add(flag.OldName);
break; break;
@ -163,6 +165,10 @@ namespace BantFlags
case Method.Delete: case Method.Delete:
await Database.DeleteFlagAsync(flag); await Database.DeleteFlagAsync(flag);
if (System.IO.File.Exists(WebRoot + "/flags/dead/" + flagname))
{
System.IO.File.Delete(WebRoot + "/flags/dead/" + flagname);
}
Directory.Move(WebRoot + "/flags/" + flagname, WebRoot + "/flags/dead/" + flagname); Directory.Move(WebRoot + "/flags/" + flagname, WebRoot + "/flags/dead/" + flagname);
break; break;

Loading…
Cancel
Save