/// <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 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 SaveDashboardIndicators(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; // } //} list = bal.SaveDashboardIndicators(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); } bal.UpdateIndicatorsOtherDetail(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)); }
public void CheckActiveInactive() { model.IndicatorNumber = "227"; model.CorporateId = 12; model.FacilityId = 17; model.IsActive = 1; model.SubCategory1 = "0"; model.SubCategory2 = "0"; using (var dashbal = new DashboardIndicatorsBal()) { //dashbal.MakeIndicatorInActive(model); using (var mBal = new ManualDashboardBal()) { IEnumerable <DashboardIndicatorData> mList = mBal.GetIndicatorsDataForIndicatorNumber(Convert.ToInt32(model.CorporateId), Convert.ToInt32(model.FacilityId), "2016", model.IndicatorNumber, "1", "0", "0"); Assert.IsNotNull(mList); dashbal.UpdateIndicatorsOtherDetail(model); IEnumerable <DashboardIndicatorData> mList1 = mBal.GetIndicatorsDataForIndicatorNumber(Convert.ToInt32(model.CorporateId), Convert.ToInt32(model.FacilityId), "2016", model.IndicatorNumber, "1", "0", "0"); DashboardIndicatorData dashboardObj = mList.FirstOrDefault(); if (dashboardObj != null) { Assert.AreEqual(dashboardObj.IsActive, false); } model.IsActive = 0; dashbal.UpdateIndicatorsOtherDetail(model); //if (Convert.ToBoolean(mList.)) // { // model.IsActive = 1; // dashbal.MakeIndicatorInActive(model); // } } } }