public ActionResult Index(QRCModel ObjQRCModel) { DARModel objDAR; long Totalrecords = 0; eTracLoginModel ObjLoginModel = new eTracLoginModel(); LocationMasterModel objLocationMasterModel = null; try { //if (ModelState.IsValid) if (true) { #region login model //// if (Session["eTrac"] != null) { ObjLoginModel = (eTracLoginModel)(Session["eTrac"]); // ObjQRCModel.UserModel.ProjectID = (ObjLoginModel != null && ObjLoginModel.LocationID > 0) ? (ObjLoginModel.LocationID) : 0; } else { return(RedirectToAction("Index", "Login")); } /// #endregion login model long _qRCId = 0; Result _fnResult, result; PrintQRCModel ObjPrintQRCModel; CommonHelper ObjCommonHelper = new CommonHelper(); string QRCImageName = string.Empty; //string msg; if (Session["ImageName"] != null) { ObjQRCModel.UserModel.myProfileImage = Convert.ToString(Session["ImageName"]); } if (ObjQRCModel.WarrantyDocument != null) { ObjQRCModel.WarrantyDoc = DateTime.Now.Ticks + "_" + ObjQRCModel.WarrantyDocument.FileName.Replace(" ", ""); } if (ObjQRCModel.LOCPicture != null) { ObjQRCModel.LocationPicture = DateTime.Now.Ticks + "_" + ObjQRCModel.LOCPicture.FileName.Replace(" ", ""); } if (ObjQRCModel.AssetPictureUrl != null) { ObjQRCModel.AssetPicture = DateTime.Now.Ticks + "_" + ObjQRCModel.AssetPictureUrl.FileName.Replace(" ", ""); } ObjQRCModel.CreatedBy = ObjLoginModel.UserId; ObjQRCModel.LocationId = ObjLoginModel.LocationID; objDAR = new DARModel(); objDAR.LocationId = ObjLoginModel.LocationID; objDAR.UserId = ObjLoginModel.UserId; objDAR.CreatedBy = ObjLoginModel.UserId; objDAR.CreatedOn = DateTime.UtcNow; //Added by Bhushan on 26/Oct/2016 for client has changed request for If QRC is vehicle then directly set vehicle type is Motor Vehicle and for Shuttle Bus set vehicle type is Shuttle Bus if (ObjQRCModel.QRCTYPE == Convert.ToInt64(QrcType.Vehicle)) { ObjQRCModel.VehicleType = Convert.ToInt64(VEHICLETYPE.MotorVehicle); } if (ObjQRCModel.QRCTYPE == Convert.ToInt64(QrcType.ShuttleBus)) { ObjQRCModel.VehicleType = Convert.ToInt64(VEHICLETYPE.ShuttleBus); } if (_IQRCSetup.ProcessQRCSetup(ObjQRCModel, out _qRCId, out _fnResult, out ObjPrintQRCModel)) { path = Server.MapPath(path); if (ObjQRCModel.WarrantyDocument != null) { ObjCommonHelper.UploadImage(ObjQRCModel.WarrantyDocument, path, ObjQRCModel.WarrantyDoc); } if (ObjQRCModel.LOCPicture != null) { ObjCommonHelper.UploadImage(ObjQRCModel.LOCPicture, path, ObjQRCModel.LocationPicture); } if (ObjQRCModel.AssetPictureUrl != null) { ObjCommonHelper.UploadImage(ObjQRCModel.AssetPictureUrl, path, ObjQRCModel.AssetPicture); } if (_fnResult == Result.Completed) { // Code for to get path of root directory and attach path of directory to store image string RootDirectory = ConfigurationManager.AppSettings["QRCImage"]; RootDirectory = Server.MapPath(RootDirectory); if (ObjQRCModel.QRCImageBase64 != null) { ObjQRCModel.QRCImageBase64 = ObjQRCModel.QRCImageBase64.Split(',')[1]; ObjCommonHelper.UploadQRCImage(ObjQRCModel.QRCImageBase64, RootDirectory, ObjQRCModel.QRCImage); } objDAR.ActivityDetails = DarMessage.SaveQRC(ObjPrintQRCModel.QRCName, ObjLoginModel.Location); objDAR.TaskType = (long)TaskTypeCategory.QRCCreation; ViewBag.Message = CommonMessage.SaveSuccessMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Success; ModelState.Clear(); ObjQRCModel = QRCInIt(); } else if (_fnResult == Result.UpdatedSuccessfully) { objDAR.ActivityDetails = DarMessage.UpdateQRC(ObjPrintQRCModel.QRCName, ObjLoginModel.Location); objDAR.TaskType = (long)TaskTypeCategory.QRCUpdate; ViewBag.Message = CommonMessage.UpdateSuccessMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Success; ModelState.Clear(); ObjQRCModel = QRCInIt(); } else if (_fnResult == Result.Failed) { ViewBag.Message = CommonMessage.FailureMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger; // store the failure message in tempdata to display in view. } #region Save DAR result = _ICommonMethod.SaveDAR(objDAR); #endregion Save DAR } else { ViewBag.Message = CommonMessage.DuplicateRecordMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Info; // store the failure message in tempdata to display in view. } //ViewBag.EncryptQRC = Cryptography.GetEncryptedData(QRCDetail.QRCId.ToString(), true); //ViewBag.EncryptQRC = Cryptography.GetEncryptedData(_qRCId.ToString(), true); ViewBag.QRCName = ObjQRCModel.QRCName; ViewBag.SpecialNote = ObjQRCModel.SpecialNotes; //ViewBag.QRCSize = QRCDetail.DefaultSize; /* * ObjPrintQRCModel = new PrintQRCModel(); * * * /// pull details from ObjQRCModel and plug into ObjPrintQRCModel * ObjPrintQRCModel.QRCId = ObjQRCModel.QRCId; * * ObjPrintQRCModel.QRCName = ObjQRCModel.QRCName; * ObjPrintQRCModel.SpecialNotes = ObjQRCModel.SpecialNotes; * ObjPrintQRCModel.QRCTYPE = ObjQRCModel.QRCTYPECaption; * ObjPrintQRCModel.VehicleType = ObjQRCModel.VehicleTypeCaption; * ObjPrintQRCModel.MotorType = ObjQRCModel.MotorTypeCaption; */ /// pull details from ObjQRCModel and plug into ObjPrintQRCModel End ObjPrintQRCModel.QRCSize = _ICommonMethod.GetGlobalCodeData("QRCSIZE"); ObjPrintQRCModel.EncryptQRC = Cryptography.GetEncryptedData(ObjPrintQRCModel.QRCId.ToString(), true); ObjPrintQRCModel.CompanyLogo = (ObjLoginModel != null && !string.IsNullOrEmpty(ObjLoginModel.LocationLogo)) ? (ObjLoginModel.LocationLogo) : "/"; ObjPrintQRCModel.CompanyImage = (ObjLoginModel != null && !string.IsNullOrEmpty(ObjLoginModel.LocationImage)) ? (ObjLoginModel.LocationImage) : "/"; ObjPrintQRCModel.CompanyName = (ObjLoginModel != null && !string.IsNullOrEmpty(ObjLoginModel.Location)) ? (ObjLoginModel.Location) : "/"; objLocationMasterModel = _IGlobalAdmin.GetLocationById(ObjPrintQRCModel.LocationId); ObjPrintQRCModel.Location = objLocationMasterModel.LocationName; //ViewBag.EncryptQRC = ObjPrintQRCModel.EncryptQRC; ViewBag.EncryptQRC = ObjPrintQRCModel.QRCIDCode; ViewBag.LastEncryptQRC = ObjPrintQRCModel.QRCIDCode;// + ',' + ObjPrintQRCModel.QRCTYPEID;//This field added by Bhushan Dod //After comma we don't need type of QRC.We need to comment . ViewBag.QRCSize = ObjPrintQRCModel.QRCSize; //PrintQRCModel ObjPrintQRCModel; ViewBag.QRCModel = ObjPrintQRCModel; } else { var errors = ModelState.Values.SelectMany(v => v.Errors); string _message = ""; foreach (var items in errors) { _message = _message + items.ErrorMessage; } ViewBag.Message = _message; ObjQRCModel = _IQRCSetup.GetGlobalCodeForCategories(); } } catch (Exception ex) { WorkOrderEMS.BusinessLogic.Exception_B.Exception_B.exceptionHandel_Runtime(ex, "Exception For File Upload", path.ToString(), null); ViewBag.Message = ex.Message; ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger; ObjQRCModel = _IQRCSetup.GetGlobalCodeForCategories(); ViewBag.Country = _ICommonMethod.GetAllcountries(); ViewBag.PurchType = _ICommonMethod.GetGlobalCodeDataList("PURCHASETYPE"); return(View(ObjQRCModel)); } ObjQRCModel = _IQRCSetup.GetGlobalCodeForCategories(); ViewBag.Country = _ICommonMethod.GetAllcountries(); // ViewBag.PurchType = _ICommonMethod.GetGlobalCodeDataList("PURCHASETYPE"); ViewBag.PurchType = _ICommonMethod.GetGlobalCodeDataList("PURCHASETYPE"); ViewBag.RefreshMode = true; //ViewBag.EncryptLastQRC = data.EncryptLastQRC; //ViewBag.EncryptLastQRC = ObjQRCModel.EncryptLastQRC + "," + (string.IsNullOrEmpty(objLocationMasterModel.Address2) ? ObjLoginModel.Location.ToString().Substring(0, 3).ToUpper() : objLocationMasterModel.Address2.ToString().Substring(0, 3).ToUpper()); //ViewBag.ItemAbberivationList = Convert.ToString(ConfigurationManager.AppSettings["ItemAbberivationList"]); //if (ObjLoginModel != null && (ObjLoginModel.UserRoleId == Convert.ToInt64(UserType.GlobalAdmin) || ObjLoginModel.UserRoleId == Convert.ToInt64(UserType.ITAdministrator))) //{ // //ViewBag.ManagerList = _IGlobalAdmin.GetAllITAdministratorList(0, 1, 1000, "UserEmail", "asc", "", Convert.ToInt64(UserType.Manager), out Totalrecords); // ViewBag.LocationList = _IGlobalAdmin.GetAllLocationNew(); // ViewBag.AdministratorList = _IGlobalAdmin.GetAllITAdministratorList(0, 0, 1, 1000, "UserEmail", "asc", "", Convert.ToInt64(UserType.Administrator), out Totalrecords); //} //else if (ObjLoginModel != null && (ObjLoginModel.UserRoleId == Convert.ToInt64(UserType.Administrator))) //{ // ViewBag.LocationList = _IGlobalAdmin.GetAllLocationNew(); // //ViewBag.AdministratorList = _IGlobalAdmin.GetAllITAdministratorList(0, 1, 1000, "UserEmail", "asc", "", Convert.ToInt64(UserType.Manager), out Totalrecords); // ViewBag.AdministratorList = _ICommonMethod.GetManagersBYLocationId(ObjLoginModel.LocationID); //} return(View(ObjQRCModel)); // return RedirectToAction("Index","QRCSetup"); }