public IActionResult Gets(string CustomerId) { var ViewModel = new List <GetLicenseViewModels>(); var Customer = DB.Customers; var LicensePlate = DB.Licenses_Plant; foreach (var Get in DB.Licenses.Where(w => w.CustomerId == CustomerId)) { var Model = new GetLicenseViewModels(); Model.Customername = Customer.Where(w => w.CustomerId == Get.CustomerId).Select(s => s.CompanyName).FirstOrDefault(); Model.ClientsLimit = Get.ClientsLimit; Model.ConsoleLimit = Get.ConsoleLimit; Model.LicenseId = Get.LicenseId; Model.LicensePlan = LicensePlate.Where(w => w.LicensePlantNumber == Get.LicensePlan).Select(s => s.LicensePlantName).FirstOrDefault(); Model.Amount = Math.Round(Math.Abs((Get.ExpireDate - DateTime.Now).TotalDays)); Model.StartDate = Helper.getShortDate(Get.StartDate); Model.ExpireDate = Helper.getShortDate(Get.ExpireDate); ViewModel.Add(Model); } return(PartialView("Gets", ViewModel)); }
public IActionResult LogsView() { var User = DB.Users; var ViewModels = new List <LogsViewModes>(); var Gets = DB.Logs.Take(5).OrderByDescending(o => o.LogId).ToList(); foreach (var Get in Gets) { var Model = new LogsViewModes(); Model.UserId = User.Where(w => w.Id == Get.UserId).Select(s => s.FirstName + " " + s.LastName).FirstOrDefault(); Model.Img = User.Where(w => w.Id == Get.UserId).Select(s => s.PictureFile).FirstOrDefault(); Model.Controller = Get.Controllers; Model.Action = Get.Action; Model.ActionDate = Helper.getShortDate(Get.ActionDate); Model.TimeAgo = Helper.TimeAgo(Get.ActionDate); ViewModels.Add(Model); } return(PartialView("LogsView", ViewModels)); }