public bool UpdateTaxType(TaxTypeVM taxTypeVM) { using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction()) { try { tblTaxType taxType = unitOfWork.TblTaxTypeRepository.GetByID(taxTypeVM.TaxTypeID); taxType.TaxTypeCode = taxTypeVM.TaxTypeCode; taxType.Description = taxTypeVM.Description; taxType.Percentage = taxTypeVM.Percentage; taxType.ExpiryDate = !string.IsNullOrEmpty(taxTypeVM.ExpiryDate) ? DateTime.ParseExact(taxTypeVM.ExpiryDate, "MM/dd/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null; taxType.IsActive = taxTypeVM.IsActive; taxType.ModifiedDate = DateTime.Now; taxType.ModifiedBy = taxTypeVM.ModifiedBy; unitOfWork.TblTaxTypeRepository.Update(taxType); unitOfWork.Save(); //Complete the Transaction dbTransaction.Commit(); return(true); } catch (Exception ex) { //Roll back the Transaction dbTransaction.Rollback(); return(false); } } }
public bool DeleteTaxType(int taxTypeID) { using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction()) { try { tblTaxType taxType = unitOfWork.TblTaxTypeRepository.GetByID(taxTypeID); unitOfWork.TblTaxTypeRepository.Delete(taxType); unitOfWork.Save(); //Complete the Transaction dbTransaction.Commit(); return(true); } catch (Exception ex) { //Roll back the Transaction dbTransaction.Rollback(); return(false); } } }