/// <summary> /// Gets the document. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public FileContentResult GetDocument(long id) { ContractDoc document = GetApiResponse <ContractDoc>("ContractDoc", "GetContractDocById", id); if (document != null) { if (document.ContractContent == null) { string fileNameWithExtension = Path.GetFileName(document.DocumentId.ToString()); string extentionOnly = Path.GetExtension(document.FileName); string mimeType = MimeAssistant.GetMimeTypeByFileName(fileNameWithExtension + extentionOnly); return (File( System.IO.File.ReadAllBytes(Path.Combine( GlobalConfigVariable.ContractDocumentsPath, fileNameWithExtension + extentionOnly)), mimeType, document.FileName)); } else { byte[] fileContent = document.ContractContent; string mimeType = MimeAssistant.GetMimeTypeByFileName(document.FileName); return(File(fileContent, mimeType, document.FileName)); } } return(null); }
public JsonResult DeleteContractDoc(long id) { ContractDoc contractDocs = new ContractDoc { ContractDocId = id, UserName = GetCurrentUserName(), FacilityId = GetCurrentFacilityId() }; //Get the UserName logged in bool isSuccess = PostApiResponse <bool>("ContractDoc", "DeleteContractDoc", contractDocs); return(Json(new { sucess = isSuccess })); }
public void GetContractDocByIdIfNullTest() { var repository = new Mock <IContractDocumentRepository>(); const long value = 0; repository.Setup(f => f.GetContractDocById(value)); ContractDocumentLogic target = new ContractDocumentLogic(repository.Object); ContractDoc actual = target.GetContractDocById(value); Assert.AreEqual(null, actual); }
public void DeleteContractDocByIdMockTest1() { Mock <IContractDocumentRepository> mockProductRepository = new Mock <IContractDocumentRepository>(); ContractDoc objcontractDocs = new ContractDoc { ContractDocId = 1 }; mockProductRepository.Setup(f => f.DeleteContractDoc(objcontractDocs)).Returns(true); ContractDocumentLogic target = new ContractDocumentLogic(mockProductRepository.Object); bool actual = target.DeleteContractDoc(objcontractDocs); Assert.AreEqual(true, actual); }
public void AddEditContractDocsifNotNull() { Mock <IContractDocumentRepository> mockAddNewPaymentTypeFeeSchedule = new Mock <IContractDocumentRepository>(); var result = new ContractDoc { ContractId = 123, ContractDocId = 24656 }; mockAddNewPaymentTypeFeeSchedule.Setup(f => f.AddEditContractDocs(It.IsAny <ContractDoc>())).Returns(result); var target = new ContractDocumentLogic(mockAddNewPaymentTypeFeeSchedule.Object); ContractDoc actual = target.AddEditContractDocs(result); Assert.AreEqual(result.ContractDocId, actual.ContractDocId); }
public JsonResult SaveContractDoc(long contractId) { //Check if file exists if (Request.Files != null && Request.Files.Count > 0) { //Fetches the uploaded file var httpPostedFileBase = Request.Files[0]; if (httpPostedFileBase != null) { if (httpPostedFileBase.ContentLength > GlobalConfigVariable.ContractDocumentFileSize) { return (Json( new { status = "fail", fileSize = string.Format(Constants.FileMaxSize, GlobalConfigVariable.ContractDocumentFileSize / Convert.ToInt64(Constants.ConvertToMb)) }, "text/plain")); } var fileName = Path.GetFileName(httpPostedFileBase.FileName); //Get the Name of User logged in ContractDoc contractDoc = new ContractDoc { ContractId = contractId, FileName = fileName, UserName = GetCurrentUserName() }; ContractDoc contractDocument = PostApiResponse <ContractDoc>("ContractDoc", "AddEditContractDocs", contractDoc); if (fileName != null) { // Checking whether path is exist or not if (!Directory.Exists(GlobalConfigVariable.ContractDocumentsPath)) { Directory.CreateDirectory(GlobalConfigVariable.ContractDocumentsPath); } //Save file into local folder var filePath = Path.Combine(GlobalConfigVariable.ContractDocumentsPath, contractDocument.DocumentId + Path.GetExtension(httpPostedFileBase.FileName)); httpPostedFileBase.SaveAs(filePath); } return(contractDocument.ContractDocId > 0 ? Json(new { isSuccess = true, id = contractDocument.ContractDocId }, "text/plain") : Json(new { isSuccess = false, id = 0 })); } } return(Json(new { isSuccess = false, id = 0 })); }
public void AddEditContractDocsifNull() { Mock <IContractDocumentRepository> mockProductRepository = new Mock <IContractDocumentRepository>(); var result = new ContractDoc { ContractId = 123, ContractDocId = 24656 }; mockProductRepository.Setup(f => f.AddEditContractDocs(It.IsAny <ContractDoc>())).Returns(result); ContractDocumentLogic target = new ContractDocumentLogic(mockProductRepository.Object); ContractDoc actual = target.AddEditContractDocs(null); Assert.AreEqual(result.ContractDocId, actual.ContractDocId); }
public void GetContractDocByIdMockTest2() { ContractDoc objPaymentTypeStopLoss = new ContractDoc { ContractDocId = 1, FileName = "TestFileName" }; Mock <IContractDocumentRepository> mockProductRepository = new Mock <IContractDocumentRepository>(); mockProductRepository.Setup(f => f.GetContractDocById(It.IsAny <long>())).Returns(objPaymentTypeStopLoss); ContractDocumentLogic target = new ContractDocumentLogic(mockProductRepository.Object); ContractDoc actual = target.GetContractDocById(1); //Assert.IsNotNull(actual); Assert.AreEqual(objPaymentTypeStopLoss.FileName, actual.FileName); }
/// <summary> /// Get Contract Doc ById /// </summary> /// <param name="contractDocId"></param> /// <returns>contractDocs</returns> public ContractDoc GetContractDocById(long contractDocId) { // Initialize the Stored Procedure _databaseCommandObj = _databaseObj.GetStoredProcCommand("GetContractDocById"); // Pass parameters to Stored Procedure(i.e., @ParamName), add values for _databaseObj.AddInParameter(_databaseCommandObj, "@ContractDocByID ", DbType.Int64, contractDocId); // Retrieve the results of the Stored Procedure in Data table DataTable contractDocDataTable = _databaseObj.ExecuteDataSet(_databaseCommandObj).Tables[0]; //Map data table to business objects if (contractDocDataTable != null && contractDocDataTable.Rows != null && contractDocDataTable.Rows.Count > 0) { ContractDoc contractDocs = new ContractDoc { ContractDocId = long.Parse(contractDocDataTable.Rows[0]["ContractDocID"].ToString()), InsertDate = DBNull.Value == contractDocDataTable.Rows[0]["InsertDate"] ? (DateTime?)null : Convert.ToDateTime(contractDocDataTable.Rows[0]["InsertDate"]), UpdateDate = DBNull.Value == contractDocDataTable.Rows[0]["UpdateDate"] ? (DateTime?)null : Convert.ToDateTime(contractDocDataTable.Rows[0]["UpdateDate"]), ContractId = DBNull.Value == contractDocDataTable.Rows[0]["ContractID"] ? (long?)null : long.Parse( contractDocDataTable.Rows[0]["ContractID"].ToString()), ContractContent = DBNull.Value == contractDocDataTable.Rows[0]["ContractContent"] ? null : (byte[])contractDocDataTable.Rows[0]["ContractContent"], FileName = Convert.ToString(contractDocDataTable.Rows[0]["FileName"]), DocumentId = DBNull.Value == contractDocDataTable.Rows[0]["DocumentId"] ? (Guid?)null : (Guid)(contractDocDataTable.Rows[0]["DocumentId"]) }; //returns the response to Business layer return(contractDocs); } return(null); }
/// <summary> /// Delete Contract document By Id /// </summary> /// <param name="contractDocs"></param> /// <returns>returnvalue</returns> public bool DeleteContractDoc(ContractDoc contractDocs) { //Response object to hold the final results bool result = false; // Initialize the Stored Procedure _databaseCommandObj = _databaseObj.GetStoredProcCommand("DeleteContractDocByID"); // Pass parameters to Stored Procedure(i.e., @ParamName), add values for _databaseObj.AddInParameter(_databaseCommandObj, "@ContractDocID ", DbType.Int64, contractDocs.ContractDocId); _databaseObj.AddInParameter(_databaseCommandObj, "@UserName ", DbType.String, contractDocs.UserName); _databaseObj.AddInParameter(_databaseCommandObj, "@FacilityID", DbType.String, contractDocs.FacilityId); // Retrieve the results of the Stored Procedure int updatedRow = _databaseObj.ExecuteNonQuery(_databaseCommandObj); //returns the response to Business layer if (updatedRow > 0) { result = true; } //returns false if any exception occurs return(result); }
/// <summary> /// Add Edit Contract related Documents /// </summary> /// <param name="contractDocs"></param> /// <returns>ResponseObject</returns> public ContractDoc AddEditContractDocs(ContractDoc contractDocs) { ContractDoc contractDoc = new ContractDoc(); //Response object to hold the final results if (contractDocs != null) { // Initialize the Stored Procedure _databaseCommandObj = _databaseObj.GetStoredProcCommand("AddEditContractDocs"); // Pass parameters to Stored Procedure(i.e., @ParamName), add values for _databaseObj.AddInParameter(_databaseCommandObj, "@ContractDocID ", DbType.Int64, contractDocs.ContractDocId); _databaseObj.AddInParameter(_databaseCommandObj, "@ContractID ", DbType.Int64, contractDocs.ContractId); _databaseObj.AddInParameter(_databaseCommandObj, "@ContractContent", DbType.Binary, contractDocs.ContractContent); _databaseObj.AddInParameter(_databaseCommandObj, "@FileName ", DbType.String, contractDocs.FileName.ToTrim()); _databaseObj.AddInParameter(_databaseCommandObj, "@UserName ", DbType.String, contractDocs.UserName.ToTrim()); _databaseObj.AddInParameter(_databaseCommandObj, "@DocumentId", DbType.Guid, Guid.NewGuid()); // Retrieve the results of the Stored Procedure DataTable contractDocDataTable = _databaseObj.ExecuteDataSet(_databaseCommandObj).Tables[0]; if (contractDocDataTable != null && contractDocDataTable.Rows != null && contractDocDataTable.Rows.Count > 0) { contractDoc = new ContractDoc { ContractDocId = long.Parse(contractDocDataTable.Rows[0]["ContractDocID"].ToString()), DocumentId = DBNull.Value == contractDocDataTable.Rows[0]["DocumentId"] ? (Guid?)null : (Guid)(contractDocDataTable.Rows[0]["DocumentId"]) }; //returns the response to Business layer return(contractDoc); } //returns the Contract id to Business layer return(contractDoc); } //returns 0 if any exception occurs return(contractDoc); }
/// <summary> /// Get Contract full details /// </summary> /// <param name="contractDocId"></param> /// <returns></returns> public ContractDoc GetContractDocById(long contractDocId) { ContractDoc contractDoc = _contractDocumentsRepository.GetContractDocById(contractDocId); return(contractDoc); }
/// <summary> /// Delete the ContractDocument /// </summary> /// <param name="contractDocs"></param> /// <returns></returns> public bool DeleteContractDoc(ContractDoc contractDocs) { return(_contractDocumentsRepository.DeleteContractDoc(contractDocs)); }
/// <summary> /// Adds the edit contract docs. /// </summary> /// <param name="contractDocs">The contract docs.</param> /// <returns></returns> public ContractDoc AddEditContractDocs(ContractDoc contractDocs) { return(_contractDocumentsRepository.AddEditContractDocs(contractDocs)); }
/// <summary> /// Gets the contract full information. /// </summary> /// <param name="contractInfo">The contract information.</param> /// <returns></returns> public ContractFullInfo GetContractFullInfo(Contract contractInfo) { //holds the response object ContractFullInfo contractFullInfo = new ContractFullInfo(); // Initialize the Stored Procedure _cmd = _db.GetStoredProcCommand("GetContractFullInfo"); // Pass parameters to Stored Procedure(i.e., @ParamName), add values for _db.AddInParameter(_cmd, "@NodeID", DbType.Int64, contractInfo.ContractId); _db.AddInParameter(_cmd, "@FacilityId", DbType.Int32, contractInfo.FacilityId); _db.AddInParameter(_cmd, "@UserName", DbType.String, contractInfo.UserName); // Retrieve the results of the Stored Procedure in Dataset DataSet contractDataSet = _db.ExecuteDataSet(_cmd); //Check if output result tables exists or not if (contractDataSet != null && contractDataSet.Tables.Count > 0) { //populating ContractBasicInfo data if (contractDataSet.Tables[0].Rows != null && contractDataSet.Tables[0] != null && contractDataSet.Tables[0].Rows.Count > 0) { contractFullInfo.ContractBasicInfo = new Contract { ContractId = Convert.ToInt64( contractDataSet.Tables[0].Rows[0]["ContractId"]), InsertDate = DBNull.Value == contractDataSet.Tables[0].Rows[0]["InsertDate"] ? (DateTime?)null : Convert.ToDateTime( contractDataSet.Tables[0].Rows[0]["InsertDate"]), UpdateDate = DBNull.Value == contractDataSet.Tables[0].Rows[0]["UpdateDate"] ? (DateTime?)null : Convert.ToDateTime( contractDataSet.Tables[0].Rows[0]["UpdateDate"]), ContractName = Convert.ToString( contractDataSet.Tables[0].Rows[0]["ContractName"]), StartDate = Convert.ToDateTime( contractDataSet.Tables[0].Rows[0]["StartDate"]), EndDate = Convert.ToDateTime( contractDataSet.Tables[0].Rows[0]["EndDate"]), FacilityId = Convert.ToInt32( contractDataSet.Tables[0].Rows[0]["FacilityId"]), Status = DBNull.Value != contractDataSet.Tables[0].Rows[0]["Status"] && Convert.ToInt32(contractDataSet.Tables[0].Rows[0]["Status"]) == 1, IsClaimStartDate = DBNull.Value != contractDataSet.Tables[0].Rows[0]["IsClaimStartDate"] && Convert.ToInt32(contractDataSet.Tables[0].Rows[0]["IsClaimStartDate"]) == 1, IsContractServiceTypeFound = DBNull.Value != contractDataSet.Tables[0].Rows[0]["IsContractServiceTypeFound"] && Convert.ToInt32(contractDataSet.Tables[0].Rows[0]["IsContractServiceTypeFound"]) == 1, IsProfessional = DBNull.Value != contractDataSet.Tables[0].Rows[0]["IsProfessionalClaim"] && Convert.ToInt32(contractDataSet.Tables[0].Rows[0]["IsProfessionalClaim"]) == 1, IsInstitutional = DBNull.Value != contractDataSet.Tables[0].Rows[0]["IsInstitutionalClaim"] && Convert.ToInt32(contractDataSet.Tables[0].Rows[0]["IsInstitutionalClaim"]) == 1, NodeId = DBNull.Value == contractDataSet.Tables[0].Rows[0]["NodeId"] ? (long?)null : Convert.ToInt64( contractDataSet.Tables[0].Rows[0]["NodeId"]), IsModified = DBNull.Value == contractDataSet.Tables[0].Rows[0]["IsModified"] ? (int?)null : Convert.ToInt32( contractDataSet.Tables[0].Rows[0]["IsModified"]), ThresholdDaysToExpireAlters = DBNull.Value == contractDataSet.Tables[0].Rows[0]["ThresholdDaysToExpireAlters"] ? (int?)null : Convert.ToInt32( contractDataSet.Tables[0].Rows[0]["ThresholdDaysToExpireAlters"]), PayerCode = Convert.ToString( contractDataSet.Tables[0].Rows[0]["PayerCode"]), CustomField = DBNull.Value == contractDataSet.Tables[0].Rows[0]["CustomField"] ? (int?)null : Convert.ToInt32( contractDataSet.Tables[0].Rows[0]["CustomField"]), }; } //Populating ContractPayer's data if (contractDataSet.Tables[1].Rows != null && contractDataSet.Tables[1] != null && contractDataSet.Tables[1].Rows.Count > 0) { if (contractInfo.ContractId == 0) { contractFullInfo.ContractBasicInfo = new Contract(); } contractFullInfo.ContractBasicInfo.Payers = new List <Payer>(); for (int i = 0; i < contractDataSet.Tables[1].Rows.Count; i++) { Payer payer = new Payer { PayerName = Convert.ToString(contractDataSet.Tables[1].Rows[i]["PayerName"]), IsSelected = Convert.ToBoolean(contractDataSet.Tables[1].Rows[i]["IsSelected"]), }; contractFullInfo.ContractBasicInfo.Payers.Add(payer); } } //populating Contract payer Info ID's data contractFullInfo.ContractContactIds = new List <Int64>(); if (contractDataSet.Tables[2].Rows != null && contractDataSet.Tables[2] != null && contractDataSet.Tables[2].Rows.Count > 0) { for (int i = 0; i < contractDataSet.Tables[2].Rows.Count; i++) { Int64 contractPayerInfoId = Convert.ToInt64(contractDataSet.Tables[2].Rows[i]["ContractPayerInfoId"]); contractFullInfo.ContractContactIds.Add(contractPayerInfoId); } } //populating ContractNotes data if (contractDataSet.Tables[3].Rows != null && contractDataSet.Tables[3] != null && contractDataSet.Tables[3].Rows.Count > 0) { contractFullInfo.ContractNotes = new List <ContractNote>(); for (int i = 0; i < contractDataSet.Tables[3].Rows.Count; i++) { string currentDateTime = Utilities.GetLocalTimeString(contractInfo.CurrentDateTime, Convert.ToDateTime((contractDataSet.Tables[3].Rows[i]["InsertDate"].ToString()))); ContractNote contractNote = new ContractNote { ContractNoteId = Convert.ToInt64( contractDataSet.Tables[3].Rows[i]["ContractNoteID"]), ContractId = DBNull.Value == contractDataSet.Tables[3].Rows[i]["ContractID"] ? (long?)null : Convert.ToInt64( contractDataSet.Tables[3].Rows[i]["ContractID"]), InsertDate = DBNull.Value == contractDataSet.Tables[3].Rows[i]["InsertDate"] ? (DateTime?)null : Convert.ToDateTime( contractDataSet.Tables[3].Rows[i]["InsertDate"]), ShortDateTime = DBNull.Value == contractDataSet.Tables[3].Rows[i]["InsertDate"] ? string.Empty : Convert.ToDateTime( currentDateTime).ToString("MM/dd/yyyy hh:mm:ss"), UpdateDate = DBNull.Value == contractDataSet.Tables[3].Rows[i]["UpdateDate"] ? (DateTime?)null : Convert.ToDateTime( contractDataSet.Tables[3].Rows[i]["UpdateDate"]), NoteText = Convert.ToString(contractDataSet.Tables[3].Rows[i]["NoteText"]), UserName = DBNull.Value == contractDataSet.Tables[3].Rows[i]["UserName"] ? string.Empty : Convert.ToString(contractDataSet.Tables[3].Rows[i]["UserName"]) }; contractFullInfo.ContractNotes.Add(contractNote); } } //populating ContractDocs data if (contractDataSet.Tables[4].Rows != null && contractDataSet.Tables[4] != null && contractDataSet.Tables[4].Rows.Count > 0) { contractFullInfo.ContractDocs = new List <ContractDoc>(); for (int i = 0; i < contractDataSet.Tables[4].Rows.Count; i++) { ContractDoc contractDocs = new ContractDoc { ContractDocId = Convert.ToInt64( contractDataSet.Tables[4].Rows[i]["ContractDocID"]), InsertDate = DBNull.Value == contractDataSet.Tables[4].Rows[i]["InsertDate"] ? (DateTime?)null : Convert.ToDateTime( contractDataSet.Tables[4].Rows[i]["InsertDate"]), UpdateDate = DBNull.Value == contractDataSet.Tables[4].Rows[i]["UpdateDate"] ? (DateTime?)null : Convert.ToDateTime( contractDataSet.Tables[4].Rows[i]["UpdateDate"]), ContractId = DBNull.Value == contractDataSet.Tables[4].Rows[i]["ContractID"] ? (long?)null : Convert.ToInt64( contractDataSet.Tables[4].Rows[i]["ContractID"]), ContractContent = DBNull.Value == contractDataSet.Tables[4].Rows[i]["ContractContent"] ? null : (byte[])contractDataSet.Tables[4].Rows[i]["ContractContent"], FileName = Convert.ToString(contractDataSet.Tables[4].Rows[i]["FileName"]) }; contractFullInfo.ContractDocs.Add(contractDocs); } } } //returns response to Business layer return(contractFullInfo); }
public ContractDoc AddEditContractDocs(ContractDoc contractDocs) { return(_contractLogic.AddEditContractDocs(contractDocs)); }
public bool DeleteContractDoc(ContractDoc contractDocs) { return(_contractLogic.DeleteContractDoc(contractDocs)); }