public bool DeleteTransporterAgreementVersion(TransporterAgreementVersion transporterAgreementVersion) { if (transporterAgreementVersion == null) return false; _unitOfWork.TransporterAgreementVersionRepository.Delete(transporterAgreementVersion); _unitOfWork.Save(); return true; }
//public ActionResult ShowLetterTemplates([DataSourceRequest] DataSourceRequest request) //{ // //return Json(_letterTemplateService.GetAllLetterTemplates().ToDataSourceResult(request)); //} public void GenerateAgreementTemplate(int transporterID) { // TODO: Make sure to use DI to get the template generator instance var template = new TemplateHelper(_unitofwork); var filePath = template.GenerateTemplate(transporterID, 7, "FrameworkPurchaseContract"); //here you have to send the name of the tempalte and the id of the TransporterID var bidID = new int(); var firstOrDefault = _bidWinnerService.Get(t => t.TransporterID == transporterID && t.Status == 1).FirstOrDefault(); if (firstOrDefault != null) { bidID = firstOrDefault.BidID; } var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); var fileLen = Convert.ToInt32(fs.Length); var data = new byte[fileLen]; fs.Read(data, 0, fileLen); fs.Close(); var allPreviousDocs = _transporterAgreementVersionService.Get(t => t.TransporterID == transporterID); foreach (var agreementVersion in allPreviousDocs) { agreementVersion.Current = false; _transporterAgreementVersionService.EditTransporterAgreementVersion(agreementVersion); } var transporterAgreementVersion = new TransporterAgreementVersion {BidID = bidID, TransporterID = transporterID, AgreementDocxFile = data, IssueDate = DateTime.Now, Current = true}; _transporterAgreementVersionService.AddTransporterAgreementVersion(transporterAgreementVersion); Response.Clear(); Response.ContentType = "application/text"; Response.AddHeader("Content-Disposition", @"filename= FrameworkPurchaseContract.docx"); Response.TransmitFile(filePath); Response.End(); }
public bool EditTransporterAgreementVersion(TransporterAgreementVersion transporterAgreementVersion) { _unitOfWork.TransporterAgreementVersionRepository.Edit(transporterAgreementVersion); _unitOfWork.Save(); return true; }