public async Task <IActionResult> Post([FromBody] GarmentUnitExpenditureNoteViewModel viewModel) { try { identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; if (viewModel.Items != null) { viewModel.Items = viewModel.Items.Where(s => s.IsSave).ToList(); } identityService.TimezoneOffset = int.Parse(Request.Headers["x-timezone-offset"].First()); IValidateService validateService = (IValidateService)serviceProvider.GetService(typeof(IValidateService)); validateService.Validate(viewModel); var Model = mapper.Map <GarmentUnitExpenditureNote>(viewModel); await facade.Create(Model); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE) .Ok(); return(Created(String.Concat(Request.Path, "/", 0), Result)); } catch (ServiceValidationExeption e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE) .Fail(e); return(BadRequest(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public async Task <IActionResult> GetSalesInvoiceExportValasPDF([FromRoute] int Id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf"); int timeoffsset = Convert.ToInt32(Request.Headers["x-timezone-offset"]); SalesInvoiceExportModel model = await Facade.ReadByIdAsync(Id); if (model == null) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, Common.NOT_FOUND_STATUS_CODE, Common.NOT_FOUND_MESSAGE) .Fail(); return(NotFound(Result)); } else { SalesInvoiceExportViewModel viewModel = Mapper.Map <SalesInvoiceExportViewModel>(model); SalesInvoiceExportValasPdfTemplate PdfTemplate = new SalesInvoiceExportValasPdfTemplate(); MemoryStream stream = PdfTemplate.GeneratePdfTemplate(viewModel, timeoffsset); return(new FileStreamResult(stream, "application/pdf") { FileDownloadName = "Faktur_Penjualan_Export_Valas/" + viewModel.SalesInvoiceNo + ".pdf" }); } } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, Common.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(Common.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public async Task <IActionResult> Put([FromRoute] int id, [FromBody] FormDto form) { try { VerifyUser(); var data = await _service.GetById(id); if (data == null) { return(NotFound()); } _validateService.Validate(form); await _service.Update(id, form); return(NoContent()); } catch (ServiceValidationException ex) { var Result = new { error = ResultFormatter.Fail(ex), apiVersion = "1.0.0", statusCode = HttpStatusCode.BadRequest, message = "Data does not pass validation" }; return(new BadRequestObjectResult(Result)); } catch (Exception ex) { var error = new { statusCode = HttpStatusCode.InternalServerError, error = ex.Message }; return(StatusCode((int)HttpStatusCode.InternalServerError, error)); } }
public IActionResult Get(int id) { try { var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf"); var model = facade.ReadById(id); var viewModel = mapper.Map <GarmentCorrectionNoteViewModel>(model); if (viewModel == null) { throw new Exception("Invalid Id"); } if (indexAcceptPdf < 0) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(viewModel); return(Ok(Result)); } else { int clientTimeZoneOffset = int.Parse(Request.Headers["x-timezone-offset"].First()); var stream = GarmentCorrectionNotePricePDFTemplate.Generate(model, serviceProvider, clientTimeZoneOffset); return(new FileStreamResult(stream, "application/pdf") { FileDownloadName = $"{model.CorrectionNo}.pdf" }); } } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public async Task <IActionResult> GetXlsAsync(string SPBStatus, string PaymentStatus, string bankExpenditureNoteNo, DateTime?dateFromPayment = null, DateTime?dateToPayment = null, string filter = "{}", DateTime?dateFrom = null, DateTime?dateTo = null) { try { VerifyUser(); byte[] xlsInBytes; int offSet = Convert.ToInt32(Request.Headers["x-timezone-offset"]); var xls = await Service.GenerateExcelAsync(1, int.MaxValue, "{}", filter, dateFrom, dateTo, dateFromPayment, dateToPayment, bankExpenditureNoteNo, SPBStatus, PaymentStatus, offSet); string fileName = ""; if (dateFrom == null && dateTo == null) { fileName = string.Format("Ekspedisi Disposisi Pembelian"); } else if (dateFrom != null && dateTo == null) { fileName = string.Format("Ekspedisi Disposisi Pembelian {0}", dateFrom.Value.ToString("dd/MM/yyyy")); } else if (dateFrom == null && dateTo != null) { fileName = string.Format("Ekspedisi Disposisi Pembelian {0}", dateTo.GetValueOrDefault().ToString("dd/MM/yyyy")); } else { fileName = string.Format("Ekspedisi Disposisi Pembelian {0} - {1}", dateFrom.GetValueOrDefault().ToString("dd/MM/yyyy"), dateTo.Value.ToString("dd/MM/yyyy")); } xlsInBytes = xls.ToArray(); var file = File(xlsInBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName); return(file); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult GetXls([FromQuery] bool isImport, [FromQuery] int month, [FromQuery] int year, [FromQuery] string supplierName = null, bool isForeignCurrency = false, int divisionId = 0) { try { byte[] xlsInBytes; int offSet = Convert.ToInt32(Request.Headers["x-timezone-offset"]); var xls = Service.GenerateExcel(isImport, supplierName, month, year, offSet, isForeignCurrency, divisionId); string fileName = ""; if (isImport) { fileName = string.Format("Saldo Hutang Impor Periode {0} {1}", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month), year); } else { if (isForeignCurrency) { fileName = string.Format("Saldo Hutang Lokal Valas Periode {0} {1}", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month), year); } else { fileName = string.Format("Saldo Hutang Lokal Periode {0} {1}", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month), year); } } xlsInBytes = xls.ToArray(); var file = File(xlsInBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName); return(file); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult GetXls([FromQuery] DateTimeOffset?dateFrom = null, [FromQuery] DateTimeOffset?dateTo = null) { try { VerifyUser(); byte[] xlsInBytes; int offSet = Convert.ToInt32(Request.Headers["x-timezone-offset"]); var xls = Service.GenerateExcel(dateFrom, dateTo, offSet); string fileName = ""; if (dateFrom == null && dateTo == null) { fileName = string.Format("Jurnal Transaksi"); } else if (dateFrom != null && dateTo == null) { fileName = string.Format("Jurnal Transaksi {0}", dateFrom.Value.ToString("dd/MM/yyyy")); } else if (dateFrom == null && dateTo != null) { fileName = string.Format("Jurnal Transaksi {0}", dateTo.GetValueOrDefault().ToString("dd/MM/yyyy")); } else { fileName = string.Format("Jurnal Transaksi {0} - {1}", dateFrom.GetValueOrDefault().ToString("dd/MM/yyyy"), dateTo.Value.ToString("dd/MM/yyyy")); } xlsInBytes = xls.ToArray(); var file = File(xlsInBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName); return(file); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public override async Task <ActionResult> Post([FromBody] ColorReceiptViewModel viewModel) { try { VerifyUser(); ValidateService.Validate(viewModel); if (viewModel.ChangeTechnician) { var technician = await Facade.CreateTechnician(viewModel.NewTechnician); viewModel.Technician = new TechnicianViewModel() { Id = technician.Id, Name = technician.Name }; } ColorReceiptModel model = Mapper.Map <ColorReceiptModel>(viewModel); await Facade.CreateAsync(model); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE) .Ok(); return(Created(String.Concat(Request.Path, "/", 0), Result)); } catch (ServiceValidationException e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE) .Fail(e); return(BadRequest(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult GetByName(string name) { try { service.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; GarmentProduct Data = service.GetByName(name); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(Data); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public async Task <IActionResult> UpdateHasSalesInvoice([FromRoute] int id, [FromBody] OutputShippingUpdateSalesInvoiceViewModel salesInvoice) { if (!ModelState.IsValid) { var excpetion = new { error = ResultFormatter.FormatErrorMessage(ModelState) }; return(new BadRequestObjectResult(excpetion)); } try { VerifyUser(); var result = await _service.UpdateHasSalesInvoice(id, salesInvoice); return(Ok(result)); } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); } }
public IActionResult GetByIds([Bind(Prefix = "productList[]")] List <string> productList) { try { service.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; List <Product> Data = service.GetByIds(productList); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(Data); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public virtual IActionResult Get(int page = 1, int size = 25, string order = "{}", [Bind(Prefix = "Select[]")] List <string> select = null, string keyword = null, string filter = "{}") { try { VerifyUser(); ReadResponse <VBRealizationDocumentModel> read = _service.Read(page, size, order, select, keyword, filter); //List<TViewModel> dataVM = Mapper.Map<List<TViewModel>>(read.Data); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(null, read.Data, page, size, read.Count, read.Data.Count, read.Order, read.Selected); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public async Task <IActionResult> GetUser([FromQuery] string keyword) { try { VerifyUser(); _identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; var Data = await _service.GetListUsers(keyword); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(Data); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult GetXlsStockAval(DateTime?dateFrom, DateTime?dateTo, int unit, string typeAval) { try { byte[] xlsInBytes; int offset = Convert.ToInt32(Request.Headers["x-timezone-offset"]); var xls = Service.GenerateExcelAval(dateFrom, dateTo, unit, offset, typeAval); string filename = String.Format("Report Stock Gudang Sisa - Aval {0}.xlsx", DateTime.UtcNow.ToString("ddMMyyyy")); xlsInBytes = xls.ToArray(); var file = File(xlsInBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", filename); return(file); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult GetForRODistribute(int page = 1, int size = 25, string order = "{}", [Bind(Prefix = "Select[]")] List <string> select = null, string keyword = null, string filter = "{}") { try { ReadResponse <CostCalculationGarment> read = Facade.ReadForRODistribution(page, size, order, select, keyword, filter); //Tuple<List<TModel>, int, Dictionary<string, string>, List<string>> Data = Facade.Read(page, size, order, select, keyword, filter); List <CostCalculationGarmentViewModel> DataVM = Mapper.Map <List <CostCalculationGarmentViewModel> >(read.Data); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, Common.OK_STATUS_CODE, Common.OK_MESSAGE) .Ok <CostCalculationGarmentViewModel>(Mapper, DataVM, page, size, read.Count, DataVM.Count, read.Order, read.Selected); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, Common.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(Common.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult Get(int id) { try { UnitPaymentCorrectionNote model = _facade.ReadById(id); UnitPaymentCorrectionNoteViewModel viewModel = _mapper.Map <UnitPaymentCorrectionNoteViewModel>(model); return(Ok(new { apiVersion = ApiVersion, statusCode = General.OK_STATUS_CODE, message = General.OK_MESSAGE, data = viewModel, })); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public async Task <IActionResult> Post([FromBody] GarmentDeliveryOrderViewModel ViewModel) { try { identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; foreach (var item in ViewModel.items) { item.fulfillments = item.fulfillments.Where(s => s.isSave).ToList(); } IValidateService validateService = (IValidateService)serviceProvider.GetService(typeof(IValidateService)); validateService.Validate(ViewModel); var model = mapper.Map <GarmentDeliveryOrder>(ViewModel); await facade.Create(model, identityService.Username); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE) .Ok(); return(Created(String.Concat(Request.Path, "/", 0), Result)); } catch (ServiceValidationExeption e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE) .Fail(e); return(BadRequest(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult GetXlsPayment(string inno, string invono, string dono, string npn, string nph, string corrno, string supplier, DateTime?dateNIFrom, DateTime?dateNITo, DateTime?dueDateFrom, DateTime?dueDateTo, string status, int page = 1, int size = 25, string Order = "{}") { try { byte[] xlsInBytes; int offset = Convert.ToInt32(Request.Headers["x-timezone-offset"]); var xls = _facade.GetXLs(inno, invono, dono, npn, nph, corrno, supplier, dateNIFrom, dateNITo, dueDateFrom, dueDateTo, status, offset); string filename = status == "BB" ? String.Format("Laporan Status Bayar Nota Intern Belum Bayar - {0}.xlsx", DateTime.UtcNow.ToString("ddMMyyyy")) : status == "SB" ? String.Format("Laporan Status Bayar Nota Intern Sudah Bayar - {0}.xlsx", DateTime.UtcNow.ToString("ddMMyyyy")) : String.Format("Laporan Status Bayar Nota Intern All - {0}.xlsx", DateTime.UtcNow.ToString("ddMMyyyy")); xlsInBytes = xls.ToArray(); var file = File(xlsInBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", filename); return(file); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult Get([FromQuery] string username, [FromQuery] int supplierId, [FromQuery] DateTimeOffset?dateFrom, [FromQuery] DateTimeOffset?dateTo, [FromQuery] int page, [FromQuery] int size) { try { VerifyUser(); _identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; var Data = _service.GetReport(supplierId, username, dateFrom, dateTo, size, page); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(Data); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public async Task <IActionResult> Get(int page = 1, int size = 25, string order = "{}", string keyword = null, string filter = "{}") { try { VerifyUser(); identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; var Data = await facade.GetAll(keyword, page, size, filter, order); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(Data); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult GetbyROleftover([FromBody] string ro) { try { identityService.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; var data = facade.ReadForLeftOver( ro ); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(data); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult GetReportAllXlsOut(string referenceNo, int accountBankId, string accountBankName, string division, DateTimeOffset?startDate, DateTimeOffset?endDate, int page = 0, int size = 25, string order = "{}", [Bind(Prefix = "Select[]")] List <string> select = null, string keyword = null, string filter = "{}") { try { int clientTimeZoneOffset = int.Parse(Request.Headers["x-timezone-offset"].First()); ReadResponse <DailyBankTransactionModel> Result = Service.GetReportAll(referenceNo, accountBankId, division, startDate, endDate, page, size, order, select, keyword, filter); var filename = "Laporan Bank Harian Keluar"; var xls = AutoDailyBankTransactionExcelGenerator.CreateOut(filename, Result.Data, referenceNo, accountBankId, accountBankName, division, startDate, endDate, clientTimeZoneOffset); var xlsInBytes = xls.ToArray(); var file = File(xlsInBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", filename); return(file); } catch (Exception e) { var result = new ResultFormatter(ApiVersion, Utilities.General.INTERNAL_ERROR_STATUS_CODE, e.Message + "\n" + e.StackTrace); return(StatusCode(Utilities.General.INTERNAL_ERROR_STATUS_CODE, result)); } }
public async Task <IActionResult> GetByProductionOrederNo([FromQuery] string productionOrderNo) { try { service.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; List <ProductViewModel> Data = await service.GetProductByProductionOrderNo(productionOrderNo); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(Data); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult GetWIP(DateTime?date) { int offset = Convert.ToInt32(Request.Headers["x-timezone-offset"]); string accept = Request.Headers["Accept"]; try { var data = wipService.GetWIPReport(date, offset); return(Ok(new { apiVersion = ApiVersion, data = data })); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public async Task <IActionResult> GetPDF([FromRoute] int Id) { if (!ModelState.IsValid) { var exception = new { error = ResultFormatter.FormatErrorMessage(ModelState) }; return(new BadRequestObjectResult(exception)); } try { VerifyUser(); var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf"); int timeoffsset = Convert.ToInt32(Request.Headers["x-timezone-offset"]); var model = await _service.ReadById(Id); if (model == null) { return(StatusCode((int)HttpStatusCode.NotFound, "Not Found")); } else { Buyer buyer = _service.GetBuyer(model.buyer.Id); var PdfTemplate = new GarmentShippingLocalPriceCuttingNotePdfTemplate(); MemoryStream stream = PdfTemplate.GeneratePdfTemplate(model, buyer, timeoffsset); return(new FileStreamResult(stream, "application/pdf") { FileDownloadName = model.cuttingPriceNoteNo + ".pdf" }); } } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); } }
public IActionResult GetHOrder(string Keyword = "", string Filter = "{}") { int offset = Convert.ToInt32(Request.Headers["x-timezone-offset"]); string accept = Request.Headers["Accept"]; try { var data = hOrderService.GetHOrders(Keyword, Filter); return(Ok(new { apiVersion = ApiVersion, data = data })); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public async Task <IActionResult> Post([FromBody] FabricQualityControlViewModel viewModel) { if (!ModelState.IsValid) { var excpetion = new { error = ResultFormatter.FormatErrorMessage(ModelState) }; return(new BadRequestObjectResult(excpetion)); } try { VerifyUser(); var result = await _service.Create(viewModel); return(Created("/", result)); } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); } }
public IActionResult GettraceOutDetail(string ro) { int offset = Convert.ToInt32(Request.Headers["x-timezone-offset"]); string accept = Request.Headers["Accept"]; try { var data2 = traceableOutService.getQueryTraceableOutDetail(ro); return(Ok(new { apiVersion = ApiVersion, data = data2, })); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult GetDistinctProductYarn(string Keyword = "", string Filter = "{}") { try { service.Username = User.Claims.Single(p => p.Type.Equals("username")).Value; IQueryable <GarmentProduct> Data = service.GetDistinctProductYarn(Keyword, Filter); Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(Data); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult DownloadTemplate() { try { byte[] csvInBytes; var csv = Service.DownloadTemplate(); string fileName = "Chart of Account Template.csv"; csvInBytes = csv.ToArray(); var file = File(csvInBytes, "text/csv", fileName); return(file); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }