Repository navigation
Expand file tree
/
Copy pathUpgradeController.cs
More file actions
57 lines (45 loc) · 1.6 KB
/
Copy pathUpgradeController.cs
File metadata and controls
57 lines (45 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Grand.Core;
using Grand.Core.Data;
using Grand.Core.Infrastructure;
using Grand.Services.Installation;
using Grand.Web.Models.Upgrade;
using Microsoft.AspNetCore.Mvc;
namespace Grand.Web.Controllers
{
public partial class UpgradeController : BasePublicController
{
#region Fields
private readonly IUpgradeService _upgradeService;
#endregion
#region Ctor
public UpgradeController(IUpgradeService upgradeService)
{
this._upgradeService = upgradeService;
}
#endregion
public virtual IActionResult Index()
{
if (!DataSettingsHelper.DatabaseIsInstalled())
return RedirectToRoute("Install");
var model = new UpgradeModel();
model.ApplicationVersion = GrandVersion.CurrentVersion;
model.DatabaseVersion = _upgradeService.DatabaseVersion();
return View(model);
}
[HttpPost]
public virtual IActionResult Index(UpgradeModel m, [FromServices] IWebHelper webHelper)
{
var model = new UpgradeModel();
model.ApplicationVersion = GrandVersion.CurrentVersion;
model.DatabaseVersion = _upgradeService.DatabaseVersion();
if (model.ApplicationVersion != model.DatabaseVersion)
{
_upgradeService.UpgradeData(model.DatabaseVersion, model.ApplicationVersion);
}
//restart application
webHelper.RestartAppDomain();
//Redirect to home page
return RedirectToRoute("HomePage");
}
}
}