11using System . Linq ;
22using Microsoft . AspNetCore . Mvc ;
33using System . Collections . Generic ;
4+ using System . Threading . Tasks ;
45using SimplCommerce . Infrastructure . Data ;
6+ using SimplCommerce . Module . Core . Extensions ;
57using SimplCommerce . Module . Contacts . Models ;
68using SimplCommerce . Module . Contacts . ViewModels ;
79
@@ -11,21 +13,32 @@ public class ContactController : Controller
1113 {
1214 private readonly IRepository < Contact > _contactRepository ;
1315 private readonly IRepository < ContactArea > _contactAreaRepository ;
16+ private readonly IWorkContext _workContext ;
1417
15- public ContactController ( IRepository < Contact > contactRepository , IRepository < ContactArea > contactAreaRepository )
18+ public ContactController ( IRepository < Contact > contactRepository , IRepository < ContactArea > contactAreaRepository , IWorkContext workContext )
1619 {
1720 _contactRepository = contactRepository ;
1821 _contactAreaRepository = contactAreaRepository ;
22+ _workContext = workContext ;
1923 }
2024
2125 [ Route ( "contact" ) ]
22- public IActionResult Index ( )
26+ public async Task < IActionResult > Index ( )
2327 {
2428 var model = new ContactVm ( )
2529 {
2630 ContactAreas = GetContactArea ( )
2731 } ;
2832
33+ if ( User . Identity . IsAuthenticated )
34+ {
35+ var currentUser = await _workContext . GetCurrentUser ( ) ;
36+
37+ model . FullName = currentUser . FullName ;
38+ model . EmailAddress = currentUser . Email ;
39+ model . PhoneNumber = currentUser . PhoneNumber ;
40+ }
41+
2942 return View ( model ) ;
3043 }
3144
0 commit comments