public JsonResult UploadFile(HttpPostedFileBase itemExcelFile) { var data = (new ExcelReader()).ReadExcel(itemExcelFile); var model = new List <WasteUploadItems>(); if (data != null) { foreach (var dataRow in data.DataRows) { if (dataRow[0] == "") { continue; } var item = new WasteUploadItems(); var brand = _brandRegistrationBll.GetByFaCode(dataRow[1], dataRow[2]); var markerStick = dataRow[3] == "" ? 0 : Convert.ToDecimal(dataRow[3]); var parkerStick = dataRow[4] == "" ? 0 : Convert.ToDecimal(dataRow[4]); item.CompanyCode = dataRow[0]; item.PlantWerks = dataRow[1]; item.FaCode = dataRow[2]; item.BrandDescription = brand == null ? string.Empty : brand.BRAND_CE; item.MarkerRejectStickQty = Math.Round(markerStick).ToString(); item.PackerRejectStickQty = Math.Round(parkerStick).ToString(); item.DustWasteGramQty = dataRow[5]; item.FloorWasteGramQty = dataRow[6]; //item.DustWasteStickQty = dataRow[8]; //item.FloorWasteStickQty = dataRow[9]; item.StampWasteQty = dataRow[7]; item.WasteProductionDate = dataRow[8]; item.UseForLack10 = dataRow[9]; { model.Add(item); } } } var input = Mapper.Map <List <WasteUploadItemsInput> >(model); var outputResult = _wasteBll.ValidationWasteUploadDocumentProcess(input); model = Mapper.Map <List <WasteUploadItems> >(outputResult); return(Json(model)); }
public void SaveUpload(WasteUploadItems wasteUpload, string userId) { bool isNewData = false; var dbUpload = Mapper.Map <WASTE>(wasteUpload); var dbResult = _repository.GetByID(dbUpload.COMPANY_CODE, dbUpload.WERKS, dbUpload.FA_CODE, dbUpload.WASTE_PROD_DATE); if (dbResult == null) { isNewData = true; } _repository.InsertOrUpdate(dbUpload); _uow.SaveChanges(); UpdateWasteStockTable(dbUpload, userId, isNewData); _uow.SaveChanges(); }