public IHttpActionResult UpdateInsSubClass([FromBody] JObject data) { try { int insSubClassID = !string.IsNullOrEmpty(data.SelectToken("insSubClassID").Value <string>()) ? Convert.ToInt32(data.SelectToken("insSubClassID").Value <string>()) : 0; int insClassID = !string.IsNullOrEmpty(data.SelectToken("insClassID").Value <string>()) ? Convert.ToInt32(data.SelectToken("insClassID").Value <string>()) : 0; string description = !string.IsNullOrEmpty(data.SelectToken("description").Value <string>()) ? data.SelectToken("description").Value <string>() : string.Empty; bool isActive = !string.IsNullOrEmpty(data.SelectToken("isActive").Value <string>()) ? Convert.ToBoolean(data.SelectToken("isActive").Value <string>()) : false; int userID = !string.IsNullOrEmpty(data.SelectToken("userID").Value <string>()) ? Convert.ToInt32(data.SelectToken("userID").Value <string>()) : 0; InsuranceSubClassVM insuranceSubClassVM = new InsuranceSubClassVM(); insuranceSubClassVM.InsuranceSubClassID = insSubClassID; insuranceSubClassVM.InsuranceClassID = insClassID; insuranceSubClassVM.Description = description; insuranceSubClassVM.IsActive = isActive; insuranceSubClassVM.ModifiedBy = userID; bool status = manageInsuranceClass.UpdateInsuranceSubClass(insuranceSubClassVM); if (status) { return(Json(new { status = true, message = "Successfully updated" })); } else { return(Json(new { status = false, message = "Update Failed" })); } } catch (Exception ex) { return(Json(new { status = false, message = "Unknown error occurred" })); } }
public InsuranceSubClassVM GetInsuranceSubClassByID(int insuranceSubClassID) { try { var insuranceSubClassData = unitOfWork.TblInsSubClassRepository.GetByID(insuranceSubClassID); InsuranceSubClassVM insuranceSubClassVM = new InsuranceSubClassVM(); insuranceSubClassVM.InsuranceSubClassID = insuranceSubClassData.InsSubClassID; insuranceSubClassVM.InsuranceClassID = insuranceSubClassData.InsClassID != null?Convert.ToInt32(insuranceSubClassData.InsClassID) : 0; if (insuranceSubClassVM.InsuranceClassID > 0) { insuranceSubClassVM.InsuranceClassCode = insuranceSubClassData.tblInsClass.Code; } insuranceSubClassVM.Description = insuranceSubClassData.Description; insuranceSubClassVM.IsActive = insuranceSubClassData.IsActive; insuranceSubClassVM.CreatedDate = insuranceSubClassData.CreatedDate != null?insuranceSubClassData.CreatedDate.ToString() : string.Empty; insuranceSubClassVM.ModifiedDate = insuranceSubClassData.ModifiedDate != null?insuranceSubClassData.ModifiedDate.ToString() : string.Empty; insuranceSubClassVM.CreatedBy = insuranceSubClassData.CreatedBy != null?Convert.ToInt32(insuranceSubClassData.CreatedBy) : 0; insuranceSubClassVM.ModifiedBy = insuranceSubClassData.ModifiedBy != null?Convert.ToInt32(insuranceSubClassData.ModifiedBy) : 0; return(insuranceSubClassVM); } catch (Exception ex) { throw; } }
public bool UpdateInsuranceSubClass(InsuranceSubClassVM insuranceSubClassVM) { using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction()) { try { tblInsSubClass insSubClass = unitOfWork.TblInsSubClassRepository.GetByID(insuranceSubClassVM.InsuranceSubClassID); insSubClass.InsClassID = insuranceSubClassVM.InsuranceClassID; insSubClass.Description = insuranceSubClassVM.Description; insSubClass.IsActive = insuranceSubClassVM.IsActive; insSubClass.ModifiedDate = DateTime.Now; insSubClass.ModifiedBy = insuranceSubClassVM.ModifiedBy; unitOfWork.TblInsSubClassRepository.Update(insSubClass); unitOfWork.Save(); //Complete the Transaction dbTransaction.Commit(); return(true); } catch (Exception ex) { //Roll back the Transaction dbTransaction.Rollback(); return(false); } } }
public List <InsuranceSubClassVM> GetAllInsuranceSubClassesByBusinessUnit(int businessUnitID) { try { var insuranceSubClassData = unitOfWork.TblInsSubClassRepository.Get(x => x.tblInsClass.BUID == businessUnitID).ToList(); List <InsuranceSubClassVM> insuranceSubClassList = new List <InsuranceSubClassVM>(); foreach (var insuranceSubClass in insuranceSubClassData) { InsuranceSubClassVM insuranceSubClassVM = new InsuranceSubClassVM(); insuranceSubClassVM.InsuranceSubClassID = insuranceSubClass.InsSubClassID; insuranceSubClassVM.InsuranceClassID = insuranceSubClass.InsClassID != null?Convert.ToInt32(insuranceSubClass.InsClassID) : 0; if (insuranceSubClassVM.InsuranceClassID > 0) { insuranceSubClassVM.InsuranceClassCode = insuranceSubClass.tblInsClass.Code; } insuranceSubClassVM.Description = insuranceSubClass.Description; insuranceSubClassVM.IsActive = insuranceSubClass.IsActive; insuranceSubClassVM.CreatedDate = insuranceSubClass.CreatedDate != null?insuranceSubClass.CreatedDate.ToString() : string.Empty; insuranceSubClassVM.ModifiedDate = insuranceSubClass.ModifiedDate != null?insuranceSubClass.ModifiedDate.ToString() : string.Empty; insuranceSubClassVM.CreatedBy = insuranceSubClass.CreatedBy != null?Convert.ToInt32(insuranceSubClass.CreatedBy) : 0; insuranceSubClassVM.ModifiedBy = insuranceSubClass.ModifiedBy != null?Convert.ToInt32(insuranceSubClass.ModifiedBy) : 0; insuranceSubClassList.Add(insuranceSubClassVM); } return(insuranceSubClassList); } catch (Exception ex) { throw; } }