public IEnumerable <string> Upload([FromForm] FileRequest reques) { var filePath = Path.GetTempFileName(); //Получаем времений путь до файла Invoce invoice = null; //создаем екземпляр инвойса using (var stream = new FileStream(filePath, FileMode.Create)) //открываем файл в потоке { ISheet sheet; ///Экземпляр таблицы string sFileExtension = Path.GetExtension(reques.File.FileName).ToLower(); List <string> name = new List <string>(); reques.File.CopyTo(stream); stream.Position = 0; if (sFileExtension == ".xls") { XSSFWorkbook hssfwb = new XSSFWorkbook(stream); //This will read 2007 Excel format name = this._getAllSheets.getSheets(hssfwb); return(name); } else { XSSFWorkbook hssfwb = new XSSFWorkbook(stream); //This will read 2007 Excel format name = this._getAllSheets.getSheets(hssfwb); //var json = new JavaScriptSerializer().Serialize(obj); return(name); } } }
public void Delete(Invoce entity) { using (var context = _contextFactory.Cretae()) { context.Remove(entity); } }
public ActionResult Invoce([FromForm] InvoceReques reques) { try { Invoce invoce = this._service.createInvoce(reques); this._service.generateWork(invoce); return(File( System.IO.File.ReadAllBytes(this._wordFile.GetReadPath()), "application/vnd.openxmlformats-officedocument.wordprocessingml.document" )); } catch (Exception e) { return(StatusCode((int)HttpStatusCode.BadRequest)); } }
public void Save(Invoce entity) { using (var context = _contextFactory.Cretae()) { var exists = context .Invoces .FirstOrDefault(e => e.Number == entity.Number); if (exists == null) { context.Add(entity); } else { Update(exists, entity); } context.SaveChanges(); } }
static void Main(string[] args) { var config = BuildConfiguration(); var dbSettings = new SupplyDataContextSettings { ConnectionString = config.GetConnectionString("SqlDataConnection") }; var provider = new ServiceCollection() .AddEfSupplyContext(dbSettings).BuildServiceProvider(); var repo = provider.GetService <IInvoceRepository>(); //===== var goods = new[] { GoodNumber.Parse("G4"), GoodNumber.Parse("G2"), GoodNumber.Parse("G6"), GoodNumber.Parse("G6"), GoodNumber.Parse("G6") }; var invoce = new Invoce("34h-334", "AAA-2", goods); var invoceList = new InvoceList( InvoiceBarCode.Parse("CodeBI-1"), FileKey.Parse("FK-1") ); invoce.WhenListBeScan(invoceList); repo.Save(invoce); var invoces = repo.Query(0, 10, null); }
private static void Update(Invoce source, Invoce destination) { throw new NotImplementedException(); }