)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » MaintenanceReportController (Ia.Ftn.Wa.Controllers)

Public general use code classes and xml files that we've compiled and used over the years:

    1: using Microsoft.AspNetCore.Authorization;
    2: using Microsoft.AspNetCore.Identity;
    3: using Microsoft.AspNetCore.Mvc;
    4: using System.Diagnostics;
    5: using System.Net;
    6:  
    7: namespace Ia.Ftn.Wa.Controllers
    8: {
    9:     ////////////////////////////////////////////////////////////////////////////
   10:  
   11:     /// <summary publish="true">
   12:     ///
   13:     /// </summary>
   14:     /// 
   15:     /// <remarks> 
   16:     /// Copyright � 2006-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   17:     ///
   18:     /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
   19:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   20:     ///
   21:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   22:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   23:     /// 
   24:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   25:     /// 
   26:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   27:     /// </remarks> 
   28:     [Authorize]
   29:     public class MaintenanceReportController : Controller
   30:     {
   31:         private readonly UserManager<Ia.Ftn.Cl.Models.StaffIdentityUser> userManager;
   32:  
   33:         /////////////////////////////////////////////////////////////////////////////////
   34:  
   35:         /// <summary>
   36:         ///
   37:         /// </summary>
   38:         public MaintenanceReportController(UserManager<Ia.Ftn.Cl.Models.StaffIdentityUser> _userManager)
   39:         {
   40:             userManager = _userManager;
   41:         }
   42:  
   43:         /////////////////////////////////////////////////////////////////////////////////
   44:         /////////////////////////////////////////////////////////////////////////////////
   45:  
   46:         /// <summary>
   47:         ///
   48:         /// </summary>
   49:         [HttpGet]
   50:         [Route("/maintenance/report")]
   51:         public IActionResult Index()
   52:         {
   53:             var reportViewModel = new Ia.Ftn.Wa.Models.Maintenance.ReportViewModel();
   54:  
   55:             reportViewModel.CurrentStaffIdentityUser = Ia.Ftn.Cl.Models.Data.StaffIdentityUser.CurrentStaffIdentityUser(userManager, User);
   56:  
   57:             Ia.Ftn.Wa.Models.Maintenance.Report.ViewModel(ref reportViewModel);
   58:  
   59:             return View("Index", reportViewModel);
   60:         }
   61:  
   62:         /////////////////////////////////////////////////////////////////////////////////
   63:  
   64:         /// <summary>
   65:         ///
   66:         /// </summary>
   67:         [HttpPost]
   68:         [Route("/maintenance/report")]
   69:         public IActionResult Index(Ia.Ftn.Wa.Models.Maintenance.ReportViewModel reportViewModel, string commandName, string reportId)
   70:         {
   71:             reportViewModel.CurrentStaffIdentityUser = Ia.Ftn.Cl.Models.Data.StaffIdentityUser.CurrentStaffIdentityUser(userManager, User);
   72:  
   73:             Ia.Ftn.Wa.Models.Maintenance.Report.Post(ref reportViewModel, commandName, reportId);
   74:  
   75:             Ia.Ftn.Wa.Models.Maintenance.Report.ViewModel(ref reportViewModel);
   76:  
   77:             return View("Index", reportViewModel);
   78:         }
   79:  
   80:         /////////////////////////////////////////////////////////////////////////////////
   81:         /////////////////////////////////////////////////////////////////////////////////
   82:  
   83:         /// <summary>
   84:         ///
   85:         /// </summary>
   86:         [HttpGet]
   87:         [Route("/maintenance/report/history")]
   88:         public IActionResult History(string reportId)
   89:         {
   90:             var reportViewModel = new Ia.Ftn.Wa.Models.Maintenance.ReportViewModel();
   91:  
   92:             if (!string.IsNullOrEmpty(reportId))
   93:             {
   94:                 reportViewModel.CurrentStaffIdentityUser = Ia.Ftn.Cl.Models.Data.StaffIdentityUser.CurrentStaffIdentityUser(userManager, User);
   95:                 reportViewModel.ReportId = int.TryParse(reportId, out int id) ? id : -1;
   96:  
   97:                 Ia.Ftn.Wa.Models.Maintenance.Report.HistoryViewModel(ref reportViewModel, reportId);
   98:  
   99:                 return View("History", reportViewModel);
  100:             }
  101:             else return RedirectToAction("Index", reportViewModel);
  102:         }
  103:  
  104:         /////////////////////////////////////////////////////////////////////////////////
  105:  
  106:         /// <summary>
  107:         ///
  108:         /// </summary>
  109:         [HttpPost]
  110:         [Route("/maintenance/report/history")]
  111:         public IActionResult History(Ia.Ftn.Wa.Models.Maintenance.ReportViewModel reportViewModel, string commandName, string reportId, string reportHistoryId)
  112:         {
  113:             reportViewModel.CurrentStaffIdentityUser = Ia.Ftn.Cl.Models.Data.StaffIdentityUser.CurrentStaffIdentityUser(userManager, User);
  114:             reportViewModel.ReportId = int.TryParse(reportId, out int id) ? id : -1;
  115:  
  116:             Ia.Ftn.Wa.Models.Maintenance.Report.HistoryPost(ref reportViewModel, commandName, reportHistoryId);
  117:  
  118:             Ia.Ftn.Wa.Models.Maintenance.Report.HistoryViewModel(ref reportViewModel, reportId);
  119:  
  120:             return View("History", reportViewModel);
  121:         }
  122:  
  123:         /////////////////////////////////////////////////////////////////////////////////
  124:         /////////////////////////////////////////////////////////////////////////////////
  125:  
  126:         /// <summary>
  127:         ///
  128:         /// </summary>
  129:         [HttpGet]
  130:         [Route("/maintenance/report/insert")]
  131:         public IActionResult Insert()
  132:         {
  133:             var reportViewModel = new Ia.Ftn.Wa.Models.Maintenance.ReportViewModel();
  134:  
  135:             reportViewModel.CurrentStaffIdentityUser = Ia.Ftn.Cl.Models.Data.StaffIdentityUser.CurrentStaffIdentityUser(userManager, User);
  136:  
  137:             Ia.Ftn.Wa.Models.Maintenance.Report.InsertViewModel(ref reportViewModel);
  138:  
  139:             return View("Insert", reportViewModel);
  140:         }
  141:  
  142:         /////////////////////////////////////////////////////////////////////////////////
  143:  
  144:         /// <summary>
  145:         ///
  146:         /// </summary>
  147:         [HttpPost]
  148:         [Route("/maintenance/report/insert")]
  149:         public IActionResult Insert(Ia.Ftn.Wa.Models.Maintenance.ReportViewModel reportViewModel, string commandName)
  150:         {
  151:             reportViewModel.CurrentStaffIdentityUser = Ia.Ftn.Cl.Models.Data.StaffIdentityUser.CurrentStaffIdentityUser(userManager, User);
  152:  
  153:             Ia.Ftn.Wa.Models.Maintenance.Report.InsertPost(ref reportViewModel, commandName);
  154:  
  155:             Ia.Ftn.Wa.Models.Maintenance.Report.InsertViewModel(ref reportViewModel);
  156:  
  157:             return View("Insert", reportViewModel);
  158:         }
  159:  
  160:         /////////////////////////////////////////////////////////////////////////////////
  161:         /////////////////////////////////////////////////////////////////////////////////
  162:  
  163:         /// <summary>
  164:         ///
  165:         /// </summary>
  166:         [HttpGet]
  167:         [Route("/maintenance/report/field-tnmd-supplier")]
  168:         public IActionResult FieldTnmdSupplier()
  169:         {
  170:             var fieldTnmdSupplierViewModel = new Ia.Ftn.Wa.Models.Maintenance.FieldTnmdSupplierViewModel();
  171:  
  172:             var url = Ia.Ftn.Wa.Models.Maintenance.FieldTnmdSupplier.Post(ref fieldTnmdSupplierViewModel, string.Empty);
  173:  
  174:             Ia.Ftn.Wa.Models.Maintenance.FieldTnmdSupplier.ViewModel(ref fieldTnmdSupplierViewModel);
  175:  
  176:             return View("FieldTnmdSupplier", fieldTnmdSupplierViewModel);
  177:         }
  178:  
  179:         /////////////////////////////////////////////////////////////////////////////////
  180:  
  181:         /// <summary>
  182:         ///
  183:         /// </summary>
  184:         [HttpPost]
  185:         [Route("/maintenance/report/field-tnmd-supplier")]
  186:         public IActionResult FieldTnmdSupplier(Ia.Ftn.Wa.Models.Maintenance.FieldTnmdSupplierViewModel fieldTnmdSupplierViewModel, string commandName)
  187:         {
  188:             var url = Ia.Ftn.Wa.Models.Maintenance.FieldTnmdSupplier.Post(ref fieldTnmdSupplierViewModel, commandName);
  189:  
  190:             if (!string.IsNullOrEmpty(url))
  191:             {
  192:                 return Redirect(WebUtility.UrlDecode(url));
  193:             }
  194:  
  195:             Ia.Ftn.Wa.Models.Maintenance.FieldTnmdSupplier.ViewModel(ref fieldTnmdSupplierViewModel);
  196:  
  197:             return View("FieldTnmdSupplier", fieldTnmdSupplierViewModel);
  198:         }
  199:  
  200:         /////////////////////////////////////////////////////////////////////////////////
  201:         /////////////////////////////////////////////////////////////////////////////////
  202:  
  203:         /// <summary>
  204:         ///
  205:         /// </summary>
  206:         [HttpGet]
  207:         [Route("/maintenance/report/performance")]
  208:         public IActionResult Performance()
  209:         {
  210:             var performanceViewModel = new Ia.Ftn.Wa.Models.Maintenance.PerformanceViewModel();
  211:  
  212:             Ia.Ftn.Wa.Models.Maintenance.Performance.Post(ref performanceViewModel);
  213:  
  214:             Ia.Ftn.Wa.Models.Maintenance.Performance.ViewModel(ref performanceViewModel);
  215:  
  216:             return View("Performance", performanceViewModel);
  217:         }
  218:  
  219:         /////////////////////////////////////////////////////////////////////////////////
  220:  
  221:         /// <summary>
  222:         ///
  223:         /// </summary>
  224:         [HttpPost]
  225:         [Route("/maintenance/report/performance")]
  226:         public IActionResult Performance(Ia.Ftn.Wa.Models.Maintenance.PerformanceViewModel performanceViewModel)
  227:         {
  228:             //var currentStaffIdentityUser = Ia.Ftn.Cl.Models.Data.StaffIdentityUser.CurrentStaffIdentityUser(userManager, User);
  229:  
  230:             Ia.Ftn.Wa.Models.Maintenance.Performance.Post(ref performanceViewModel);
  231:  
  232:             Ia.Ftn.Wa.Models.Maintenance.Performance.ViewModel(ref performanceViewModel);
  233:  
  234:             return View("Performance", performanceViewModel);
  235:         }
  236:  
  237:         /////////////////////////////////////////////////////////////////////////////////
  238:         /////////////////////////////////////////////////////////////////////////////////
  239:  
  240:         /// <summary>
  241:         ///
  242:         /// </summary>
  243:         [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
  244:         public IActionResult Error()
  245:         {
  246:             return View(new Ia.Ftn.Wa.Models.ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
  247:         }
  248:  
  249:         /////////////////////////////////////////////////////////////////////////////////
  250:         /////////////////////////////////////////////////////////////////////////////////
  251:     }
  252:  
  253:     /////////////////////////////////////////////////////////////////////////////////
  254:     /////////////////////////////////////////////////////////////////////////////////
  255: }