/// <summary> /// Delete the current DashboardIndicators based on the DashboardIndicators ID passed in the DashboardIndicatorsModel /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public ActionResult DeleteDashboardIndicators(int id) { using (var bal = new DashboardIndicatorsBal()) { //Get DashboardIndicators model object by current DashboardIndicators ID var model = bal.GetDashboardIndicatorsById(id); var isDeleted = false; var list = new List <DashboardIndicatorsCustomModel>(); //Check If DashboardIndicators model is not null if (model != null) { model.IsActive = 0; //Update Operation of current DashboardIndicators isDeleted = bal.DeleteIndicator(model); //return deleted ID of current DashboardIndicators as Json Result to the Ajax Call. using (var dashboardIndicatorDataBal = new DashboardIndicatorDataBal()) { dashboardIndicatorDataBal.BulkInactiveDashboardIndicatorData(model.IndicatorNumber, Helpers.GetSysAdminCorporateID()); } bal.UpdateIndicatorsOtherDetail(model); } //var orderByExpression = HtmlExtensions.GetOrderByExpression<DashboardIndicatorsCustomModel>("Dashboard"); //list = HtmlExtensions.OrderByDir<DashboardIndicatorsCustomModel>(list, "ASC", orderByExpression); //return PartialView(PartialViews.DashboardIndicatorsList, list); return(Json(isDeleted)); } //Pass the ActionResult with List of DashboardIndicatorsViewModel object to Partial View DashboardIndicatorsList }
/// <summary> /// Add New or Update the DashboardIndicatorData based on if we pass the DashboardIndicatorData ID in the DashboardIndicatorDataViewModel object. /// </summary> /// <param name="model">The model.</param> /// <returns> /// returns the newly added or updated ID of DashboardIndicatorData row /// </returns> public ActionResult SaveDashboardIndicatorData(DashboardIndicatorData model) { var userId = Helpers.GetLoggedInUserId(); var currentDate = Helpers.GetInvariantCultureDateTime(); var list = new List <DashboardIndicatorDataCustomModel>(); //Check if Model is not null if (model != null) { model.CorporateId = Helpers.GetSysAdminCorporateID(); model.IsActive = true; using (var bal = new DashboardIndicatorDataBal()) { if (model.ID == 0) { model.CreatedBy = userId; model.CreatedDate = currentDate; } //Call the AddDashboardIndicatorData Method to Add / Update current DashboardIndicatorData list = bal.SaveDashboardIndicatorData(model); } } //Pass the ActionResult with List of DashboardIndicatorDataViewModel object to Partial View DashboardIndicatorDataList return(PartialView(PartialViews.DashboardIndicatorDataList, list)); }
/// <summary> /// Add New or Update the DashboardIndicators based on if we pass the DashboardIndicators ID in the DashboardIndicatorsViewModel object. /// </summary> /// <param name="model">The model.</param> /// <returns> /// returns the newly added or updated ID of DashboardIndicators row /// </returns> public ActionResult SaveDashboardIndicatorsV1(DashboardIndicators model) { var userId = Helpers.GetLoggedInUserId(); var currentDate = Helpers.GetInvariantCultureDateTime(); var list = new List <DashboardIndicatorsCustomModel>(); //Check if Model is not null if (model != null) { model.CorporateId = Helpers.GetSysAdminCorporateID(); using (var bal = new DashboardIndicatorsBal()) { if (model.IndicatorID == 0) { model.CreatedBy = userId; model.CreatedDate = currentDate; } using (var dashboardIndicatorDataBal = new DashboardIndicatorDataBal()) { switch (model.IsActive) { case 0: dashboardIndicatorDataBal.BulkInactiveDashboardIndicatorData(model.IndicatorNumber, Helpers.GetSysAdminCorporateID()); break; default: dashboardIndicatorDataBal.BulkActiveDashboardIndicatorData(model.IndicatorNumber, Helpers.GetSysAdminCorporateID()); break; } } using (var oDashboardIndicatorDataBal = new DashboardIndicatorDataBal()) { oDashboardIndicatorDataBal.GenerateIndicatorEffects(model); } list = bal.SaveDashboardIndicatorsV1(model); //Add by shashank to check the Special case for the Indicator i.e. is the Target/Budget is static for indicator //.... Should only Call for Dashboard type = Budget (Externalvalue1='1') if (!string.IsNullOrEmpty(model.IndicatorNumber) && model.ExternalValue4.ToLower() == "true") { using (var ibal = new DashboardIndicatorDataBal()) ibal.SetStaticBudgetTargetIndciators(model); } using (var oDashboardIndicatorDataBal = new DashboardIndicatorDataBal()) { oDashboardIndicatorDataBal.GenerateIndicatorEffects(model); oDashboardIndicatorDataBal.UpdateCalculateIndicatorUpdate(model); } //Call the AddDashboardIndicators Method to Add / Update current DashboardIndicators var orderByExpression = HtmlExtensions.GetOrderByExpression <DashboardIndicatorsCustomModel>("Dashboard"); list = HtmlExtensions.OrderByDir <DashboardIndicatorsCustomModel>(list, "ASC", orderByExpression); } } //Pass the ActionResult with List of DashboardIndicatorsViewModel object to Partial View DashboardIndicatorsList return(PartialView(PartialViews.DashboardIndicatorsList, list)); }
/// <summary> /// Binds the indicators by order. /// </summary> /// <param name="sort">The sort.</param> /// <param name="sortdir">The sortdir.</param> /// <returns></returns> public ActionResult BindIndicatorsDataByOrder(string sort, string sortdir) { using (var bal = new DashboardIndicatorDataBal()) { //Get the Entity list var list = bal.GetDashboardIndicatorDataList(Helpers.GetSysAdminCorporateID(), Helpers.GetDefaultFacilityId()); //Intialize the View Model i.e. DashboardIndicatorsView which is binded to Main View Index.cshtml under DashboardIndicators var orderByExpression = HtmlExtensions.GetOrderByExpression <DashboardIndicatorDataCustomModel>(sort); var data = HtmlExtensions.OrderByDir <DashboardIndicatorDataCustomModel>(list, sortdir, orderByExpression); //Pass the View Model in ActionResult to View DashboardIndicators return(PartialView(PartialViews.DashboardIndicatorDataList, data)); } }
/// <summary> /// Get the details of the current DashboardIndicatorData in the view model by ID /// </summary> /// <param name="id">The identifier.</param> /// <param name="type"></param> /// <returns></returns> public JsonResult GetDashboardIndicatorDataDetails(int id, int type) { var model = new DashboardIndicatorData { IsActive = true, ID = 0 }; if (type == 1 && id > 0) { //Call the AddDashboardIndicatorData Method to Add / Update current DashboardIndicatorData using (var bal = new DashboardIndicatorDataBal()) model = bal.GetDashboardIndicatorDataById(id); } //Pass the ActionResult with the current DashboardIndicatorDataViewModel object as model to PartialView DashboardIndicatorDataAddEdit return(Json(model, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Get the details of the DashboardIndicatorData View in the Model DashboardIndicatorData such as DashboardIndicatorDataList, list of countries etc. /// </summary> /// <returns> /// returns the actionresult in the form of current object of the Model DashboardIndicatorData to be passed to View DashboardIndicatorData /// </returns> public ActionResult Index() { //Initialize the DashboardIndicatorData BAL object using (var bal = new DashboardIndicatorDataBal()) { //Get the Entity list var list = bal.GetDashboardIndicatorDataList(Helpers.GetSysAdminCorporateID(), Helpers.GetDefaultFacilityId()); //Intialize the View Model i.e. DashboardIndicatorDataView which is binded to Main View Index.cshtml under DashboardIndicatorData var viewModel = new DashboardIndicatorDataView { DashboardIndicatorDataList = list, CurrentDashboardIndicatorData = new DashboardIndicatorData() }; //Pass the View Model in ActionResult to View DashboardIndicatorData return(View(viewModel)); } }
/// <summary> /// Delete the current DashboardIndicatorData based on the DashboardIndicatorData ID passed in the DashboardIndicatorDataModel /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public ActionResult DeleteDashboardIndicatorData(int id) { using (var bal = new DashboardIndicatorDataBal()) { //Get DashboardIndicatorData model object by current DashboardIndicatorData ID var model = bal.GetDashboardIndicatorDataById(id); //var userId = Helpers.GetLoggedInUserId(); //var currentDate = Helpers.GetInvariantCultureDateTime(); var list = new List <DashboardIndicatorDataCustomModel>(); //Check If DashboardIndicatorData model is not null if (model != null) { model.IsActive = false; //Update Operation of current DashboardIndicatorData list = bal.SaveDashboardIndicatorData(model); //return deleted ID of current DashboardIndicatorData as Json Result to the Ajax Call. } //Pass the ActionResult with List of DashboardIndicatorDataViewModel object to Partial View DashboardIndicatorDataList return(PartialView(PartialViews.DashboardIndicatorDataList, list)); } }
public ActionResult ImportExcelFiles() { if (Request.Files != null && Request.Files.Count > 0) { const string tempFilePath = @"/Content/Temp/"; var uploadedFile = Request.Files[0]; if (uploadedFile != null) { var fi = new FileInfo(uploadedFile.FileName); HttpContextSessionWrapperExtension.ContentLength = null; HttpContextSessionWrapperExtension.ContentType = null; if (Session[SessionEnum.TempFile.ToString()] != null) { Session[SessionEnum.TempFile.ToString()] = null; HttpContextSessionWrapperExtension.ContentStream = null; } Session[SessionEnum.TempFile.ToString()] = uploadedFile; HttpContextSessionWrapperExtension.ContentLength = uploadedFile.ContentLength; HttpContextSessionWrapperExtension.ContentType = uploadedFile.ContentType; var bytesData = new byte[uploadedFile.ContentLength]; uploadedFile.InputStream.Read(bytesData, 0, uploadedFile.ContentLength); var tempFile = new byte[uploadedFile.ContentLength]; uploadedFile.InputStream.Read(tempFile, 0, uploadedFile.ContentLength); var serverPath = Server.MapPath(tempFilePath); if (Directory.Exists(serverPath)) { var getFiles = Directory.GetFiles(serverPath); foreach (var item in getFiles) { System.IO.File.Delete(item); } Directory.Delete(serverPath); } Directory.CreateDirectory(serverPath); var filename = fi.Name; using (var transScope = new TransactionScope()) { var completePath = Path.Combine(serverPath, filename); uploadedFile.SaveAs(completePath); var dtData = Import(completePath); if (dtData != null && dtData.Rows.Count > 0) { for (var i = dtData.Rows.Count - 1; i >= 0; i--) { if (dtData.Rows[i]["IndicatorNumber"] == DBNull.Value) { dtData.Rows[i].Delete(); } } dtData.AcceptChanges(); var list = ConvertIndicatorDataTableToList(dtData); if (list.Count > 0) { var getFiles = Directory.GetFiles(serverPath); foreach (var item in getFiles) { System.IO.File.Delete(item); } using (var bal = new DashboardIndicatorDataBal()) { var result = bal.BulkSaveDashboardIndicatorData(list, Helpers.GetDefaultFacilityId(), Helpers.GetSysAdminCorporateID()); if (result.Count == 0) { ViewBag.ImportStatus = result.Count == 0 ? -1 : 1; Session[SessionEnum.TempFile.ToString()] = null; } } } } transScope.Complete(); } } } return(RedirectToAction("Index")); }