/// <summary> /// Delete the current Corporate based on the Corporate ID passed in the CorporateModel /// </summary> /// <param name="corporateModel">The corporate model.</param> /// <returns></returns> public ActionResult DeleteCorporate(Model.Corporate corporateModel) { using (var corporateBal = new CorporateBal()) { //Get Corporate model object by current Corporate ID var currentCorporate = corporateBal.GetCorporateById(Convert.ToInt32(corporateModel.CorporateID)); //Check If Corporate model is not null if (currentCorporate != null) { currentCorporate.IsDeleted = true; currentCorporate.DeletedBy = Helpers.GetLoggedInUserId(); currentCorporate.DeletedDate = Helpers.GetInvariantCultureDateTime(); //Update Operation of current Corporate var result = corporateBal.AddUptdateCorporate(currentCorporate); //return deleted ID of current Corporate as Json Result to the Ajax Call. return(Json(result)); } } using (var corporateBal = new CorporateBal()) { var value = corporateBal.DeleteCorporateData(Convert.ToString(corporateModel.CorporateID)); return(Json(value)); } //Return the Json result as Action Result back JSON Call Success }
/// <summary> /// Add New or Update the Corporate based on if we pass the Corporate ID in the CorporateViewModel object. /// </summary> /// <param name="corporateModel">pass the details of Corporate in the view model</param> /// <returns> /// returns the newly added or updated ID of Corporate row /// </returns> public ActionResult SaveCorporate(Corporate corporateModel) { //Initialize the newId variable var newId = -1; var isNew = corporateModel.CorporateID == 0; //Check if CorporateViewModel if (corporateModel != null) { using (var corporateBal = new CorporateBal()) { var isExist = corporateBal.CheckDuplicateCorporateNumber(corporateModel.CorporateNumber, corporateModel.CorporateID); if (isExist) { return(Json("1")); } if (corporateModel.CorporateID > 0) { corporateModel.ModifiedBy = Helpers.GetLoggedInUserId(); corporateModel.ModifiedDate = Helpers.GetInvariantCultureDateTime(); } else { corporateModel.CreatedBy = Helpers.GetLoggedInUserId(); corporateModel.CreatedDate = Helpers.GetInvariantCultureDateTime(); } //Call the AddCorporate Method to Add / Update current Corporate newId = corporateBal.AddUptdateCorporate(corporateModel); if (isNew && newId > 0) { BackgroundJob.Enqueue(() => CreateDefaultCorporateItems(corporateModel.CorporateID, corporateModel.CorporateName)); } } } return(Json(newId)); }
public void CreateCorporate() { using (var corporateBal = new CorporateBal()) { this.model.CorporateName = this.GetRandomString(10); this.model.CorporateNumber = this.GetRandomStringNumber(4); this.model.CountryID = "45"; this.model.StateID = "3"; this.model.CityID = "3"; this.model.CreatedBy = 9999; this.model.CreatedDate = DateTime.Now; this.model.DefaultCPTTableNumber = "4010"; this.model.BillEditRuleTableNumber = "100"; corporateBal.AddUptdateCorporate(this.model); // ... Create new corporate int corporateId = this.model.CorporateID; IEnumerable <Facility> facilitylistObj = new FacilityBal().GetFacilitiesByCorpoarteId(corporateId); // .... Get the facilities for the newly created Corporate Assert.IsNotNull(facilitylistObj); // .... check if the cororate facility created on not Assert.IsTrue(facilitylistObj.Any()); // .... check if there is any oject in the list if (facilitylistObj.Any()) { Facility facilityobj = facilitylistObj.FirstOrDefault(); // .... Assertion below Assert.AreEqual(facilityobj.CorporateID, this.model.CorporateID); Assert.IsTrue(facilityobj.FacilityName.Contains(this.model.CorporateName.Substring(0, 3))); SuppliesDotComParametersBal balBSP = new SuppliesDotComParametersBal(); var facilityparmaters = balBSP.GetDetailsByCorporateAndFacility( corporateId, facilityobj.FacilityNumber); Assert.IsTrue(facilityparmaters != null); Assert.IsTrue(facilityparmaters.CPTTableNumber == this.model.DefaultCPTTableNumber); Assert.IsTrue(facilityparmaters.BillEditRuleTableNumber == this.model.BillEditRuleTableNumber); // ... Facilitystructure Checks List <FacilityStructureCustomModel> facilityStructureList = new FacilityStructureBal().GetFacilityStructure(facilityobj.FacilityId.ToString()); Assert.IsTrue(facilityStructureList.Any()); // ... UBed Master Checks IEnumerable <BedMasterCustomModel> ubedMasterobjList = new BedMasterBal().GetBedMasterListByRole(facilityobj.FacilityId, this.model.CorporateID); Assert.IsTrue(ubedMasterobjList.Any()); // ... Role Creation Checks List <Role> rolesList = new RoleBal().GetRolesByCorporateIdFacilityId( this.model.CorporateID, facilityobj.FacilityId); Assert.IsTrue(rolesList.Any()); // ... Facility Roles Creation Checks List <FacilityRoleCustomModel> facilityRoleList = new FacilityRoleBal().GetFacilityRoleListByFacility( this.model.CorporateID, facilityobj.FacilityId, 0); Assert.IsTrue(facilityRoleList.Any()); // ... users Creation Checks List <UsersCustomModel> usersList = new UsersBal().GetUsersByCorporateIdFacilityId(this.model.CorporateID, facilityobj.FacilityId); Assert.IsTrue(usersList.Any()); // ... UserRole Creation Checks // var userRoleList = new UserRoleBal().GetUserRolesByCorporateFacilityAndUserId( // model.CorporateID, // facilityobj.FacilityId); // Assert.IsTrue(usersList.Any()); // ... ModuleAccess Creation Checks List <ModuleAccess> moduleAccessList = new ModuleAccessBal().GetModulesAccessList(this.model.CorporateID, facilityobj.FacilityId); Assert.IsTrue(moduleAccessList.Any()); // ... DashboardIndicator Creation Checks // var dashBoardIndicatorsList = new DashboardIndicatorDataBal().GetDashboardIndicatorDataList( // model.CorporateID, // facilityobj.FacilityId); // Assert.IsTrue(dashBoardIndicatorsList.Any()); } corporateBal.DeleteCorporateData(this.model.CorporateID.ToString()); // ...clean Data after Test Corporate corporateAftertest = corporateBal.GetCorporateById(this.model.CorporateID); Assert.IsNull(corporateAftertest); } }