Beispiel #1
0
        public IActionResult Index(int CategoryType = 0)
        {
            try
            {
                IndexAssetsExpiryViewModel          objIndexAssetsExpiryViewModel = new IndexAssetsExpiryViewModel();
                IEnumerable <AssetsExpiryViewModel> objAssetsExpiryViewModelList  = null;

                string        endpoint        = assetsApiBaseUrl + "ProductExpiry";
                Task <string> HttpGetResponse = CommonFunction.GetWebAPI(endpoint);

                if (HttpGetResponse != null)
                {
                    objAssetsExpiryViewModelList = JsonConvert.DeserializeObject <IEnumerable <AssetsExpiryViewModel> >(HttpGetResponse.Result).ToList();
                }
                else
                {
                    objAssetsExpiryViewModelList = Enumerable.Empty <AssetsExpiryViewModel>().ToList();

                    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                }

                if (CategoryType > 0)
                {
                    objIndexAssetsExpiryViewModel.AssetsExpiryViewModelList = objAssetsExpiryViewModelList.Where(a => a.MasterCategoryType == CategoryType).OrderBy(a => a.ProductTitle).ToList();
                }
                else
                {
                    objIndexAssetsExpiryViewModel.AssetsExpiryViewModelList = objAssetsExpiryViewModelList.OrderBy(a => a.ProductTitle).ToList();
                }

                //############# Profile Maping ###################
                CPanelManager.ViewModels.Account.ValidateAccountViewModel objValidateAccountViewModel = CommonFunction.ActionResultAuthentication(HttpContext, "/MasterProduct/Index");

                if (objValidateAccountViewModel != null)
                {
                    objIndexAssetsExpiryViewModel.IsSelect = objValidateAccountViewModel.IsSelect;
                    objIndexAssetsExpiryViewModel.IsInsert = objValidateAccountViewModel.IsInsert;
                    objIndexAssetsExpiryViewModel.IsUpdate = objValidateAccountViewModel.IsUpdate;
                    objIndexAssetsExpiryViewModel.IsDelete = objValidateAccountViewModel.IsDelete;
                }
                //############# Profile Maping End ###################
                objIndexAssetsExpiryViewModel.MasterCategoryType = CategoryType;
                //Return View doesn't make a new requests, it just renders the view
                return(View("~/Views/Assets/AssetsExpiry/Index.cshtml", objIndexAssetsExpiryViewModel));
            }
            catch (Exception ex)
            {
                string ActionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string ErrorMessage   = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message;

                _logger.LogError(ErrorMessage);
                return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName)));
            }
            return(new EmptyResult());
        }
Beispiel #2
0
        public ActionResult FillNotification(int MasterRegistrationId)
        {
            try
            {
                IndexAssetsExpiryViewModel          objIndexAssetsExpiryViewModel = new IndexAssetsExpiryViewModel();
                IEnumerable <AssetsExpiryViewModel> objAssetsExpiryViewModelList  = null;

                string        endpoint        = assetsApiBaseUrl + "ProductExpiry/0";
                Task <string> HttpGetResponse = CommonFunction.GetWebAPI(endpoint);

                if (HttpGetResponse != null)
                {
                    objAssetsExpiryViewModelList = JsonConvert.DeserializeObject <IEnumerable <AssetsExpiryViewModel> >(HttpGetResponse.Result).ToList();
                }
                else
                {
                    objAssetsExpiryViewModelList = Enumerable.Empty <AssetsExpiryViewModel>().ToList();

                    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                }

                string data = JsonConvert.SerializeObject(objAssetsExpiryViewModelList.Take(10).ToList());

                JsonResult objJsonResult = new JsonResult(data);

                if (objAssetsExpiryViewModelList.Count() > 0)
                {
                    return(objJsonResult);
                }

                //BusinessAccessLayer.LMMessageNotificationBAL objLMMessageNotificationBAL = new LMMessageNotificationBAL();
                //BusinessEntity.LMMessageNotification objLMMessageNotification = new BusinessEntity.LMMessageNotification();
                //objLMMessageNotification.SendTo = MasterRegistrationId;

                //List<BusinessEntity.SP_LMMessageNotification_Result> MessageNotificationList = objLMMessageNotificationBAL.LMMessageNotification_Select(objLMMessageNotification, 0, 10, 51, "").ToList();

                //if (MessageNotificationList.Count() > 0)
                //    return Json(MessageNotificationList, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                string ActionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string ErrorMessage   = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message;

                _logger.LogError(ErrorMessage);
                return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName)));
            }
            return(Json(""));
        }
Beispiel #3
0
        public IActionResult RemiderExpire()
        {
            try
            {
                IndexAssetsExpiryViewModel          objIndexAssetsExpiryViewModel = new IndexAssetsExpiryViewModel();
                IEnumerable <AssetsExpiryViewModel> objAssetsExpiryViewModelList  = null;

                string        endpoint        = assetsApiBaseUrl + "ProductExpiry/0";
                Task <string> HttpGetResponse = CommonFunction.GetWebAPI(endpoint);

                if (HttpGetResponse != null)
                {
                    objAssetsExpiryViewModelList = JsonConvert.DeserializeObject <IEnumerable <AssetsExpiryViewModel> >(HttpGetResponse.Result).ToList();
                }
                else
                {
                    objAssetsExpiryViewModelList = Enumerable.Empty <AssetsExpiryViewModel>().ToList();

                    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                }
                objIndexAssetsExpiryViewModel.AssetsExpiryViewModelList = objAssetsExpiryViewModelList.ToList();

                string HtmlBody = "<div ><b>Dear KR Team</b><br /><br />Following are the list of assets/services will be expire in next 2 days.<br /><br />";

                HtmlBody = HtmlBody + "<table><tr><td>Assets</td><td>Expiry</td><td>Type</td></tr>";
                //.Where(a=>a.WarrantyExpiryDate?.ToString("dd-MM-yyyy")==DateTime.Now.ToString("dd-MM-yyyy") )
                foreach (var Item in objAssetsExpiryViewModelList)
                {
                    HtmlBody = HtmlBody + "<tr><td>" + Item.ProductTitle + " (" + Item.ManufacturerPartNumber + ")</td><td>" + Item.WarrantyExpiryDate?.ToString("dd-MMM-yyyy") + "</td><td>" + (Item.MasterCategoryType == 1 ? "Assets" : "Service") + "</td></tr>";
                }
                HtmlBody = HtmlBody + "</table>";

                //var message = new Message(new string[] { "*****@*****.**", "*****@*****.**","*****@*****.**","*****@*****.**"}, "Assets/Services Expiry Reminder from www.kritms.com", HtmlBody);
                //_emailSender.SendEmail(message);
                return(View(objIndexAssetsExpiryViewModel));
            }
            catch (Exception ex)
            {
                string ActionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string ErrorMessage   = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message;

                _logger.LogError(ErrorMessage);
                return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName)));
            }
            return(new EmptyResult());
        }
Beispiel #4
0
        public IActionResult PrintRenewalReminder(int CategoryType = 0)
        {
            try
            {
                ModelState.Clear();
                IndexAssetsExpiryViewModel          objIndexAssetsExpiryViewModel = new IndexAssetsExpiryViewModel();
                IEnumerable <AssetsExpiryViewModel> objAssetsExpiryViewModelList  = null;

                string        endpoint        = assetsApiBaseUrl + "ProductExpiry";
                Task <string> HttpGetResponse = CommonFunction.GetWebAPI(endpoint);

                if (HttpGetResponse != null)
                {
                    objAssetsExpiryViewModelList = JsonConvert.DeserializeObject <IEnumerable <AssetsExpiryViewModel> >(HttpGetResponse.Result).ToList();
                }
                else
                {
                    objAssetsExpiryViewModelList = Enumerable.Empty <AssetsExpiryViewModel>().ToList();

                    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                }

                if (CategoryType > 0)
                {
                    objIndexAssetsExpiryViewModel.AssetsExpiryViewModelList = objAssetsExpiryViewModelList.Where(a => a.MasterCategoryType == CategoryType).OrderBy(a => a.ProductTitle).ToList();
                }
                else
                {
                    objIndexAssetsExpiryViewModel.AssetsExpiryViewModelList = objAssetsExpiryViewModelList.OrderBy(a => a.ProductTitle).ToList();
                }
                objIndexAssetsExpiryViewModel.MasterCategoryType = CategoryType;

                string             filePath = $"{webHostEnvironment.WebRootPath}\\Reports\\PrintRenewalReminder.pdf";
                System.IO.FileInfo DelFile  = new System.IO.FileInfo(filePath);

                if (DelFile.Exists)
                {
                    DelFile.Delete();
                }

                var report = new ViewAsPdf("~/Views/Assets/AssetsExpiry/PrintRenewalReminder.cshtml", objIndexAssetsExpiryViewModel)
                {
                    MinimumFontSize = 8,
                    PageMargins     = { Left = 10, Bottom = 10, Right = 10, Top = 5 },
                    //FileName =  "PrintRenewalReminder.pdf",
                    PageOrientation = Rotativa.AspNetCore.Options.Orientation.Portrait,
                    //CustomSwitches = "--page-offset 0 --footer-center [page] --footer-font-size 12",
                    CustomSwitches = "--footer-center \"  Created Date: " + DateTime.Now.Date.ToString("dd/MM/yyyy") + "  Page: [page]/[toPage]\"" +
                                     " --footer-line --footer-font-size \"10\" --footer-spacing 1 --footer-font-name \"Segoe UI\"",
                    PageSize = Rotativa.AspNetCore.Options.Size.A4,
                };
                return(report);
            }
            catch (Exception ex)
            {
                string ActionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                string ErrorMessage   = "Controler:" + ControllerName + " , Action:" + ActionName + " , Exception:" + ex.Message;

                _logger.LogError(ErrorMessage);
                return(View("~/Views/Shared/Error.cshtml", CommonFunction.HandleErrorInfo(ex, ActionName, ControllerName)));
            }
            return(new EmptyResult());
        }