Example #1
0
        private async Task <ChemicalDto> AddInk(ChemicalForImportExcelDto chemicalDto)
        {
            var result = new ChemicalDto();

            using (var scope = new TransactionScope(TransactionScopeOption.Required,
                                                    new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            }, TransactionScopeAsyncFlowOption.Enabled))
            {
                var supname = await _repoSup.FindAll().FirstOrDefaultAsync(x => x.Name.ToUpper().Equals(chemicalDto.Supplier.ToUpper()));

                if (supname != null)
                {
                    result.SupplierID = supname.ID;
                }
                else
                {
                }

                var process = await _repoProcess.FindAll().FirstOrDefaultAsync(x => x.Name.ToUpper().Equals(chemicalDto.Process.ToUpper()));

                if (process != null)
                {
                    result.ProcessID = process.ID;
                }
                else
                {
                }

                // result.CreatedBy = inkDto.CreatedBy;
                scope.Complete();
                return(result);
            }
        }
Example #2
0
        public async Task <bool> Add(ChemicalDto model)
        {
            var ink = _mapper.Map <Chemical>(model);

            ink.isShow = true;
            _repoChemical.Add(ink);
            return(await _repoInk.SaveAll());
        }
Example #3
0
        public async Task <bool> Add(ChemicalDto model)
        {
            var chemical = _mapper.Map <Chemical>(model);

            if (model.Modify == false)
            {
                chemical.Percentage = 100;
            }
            chemical.isShow      = true;
            chemical.CreatedDate = DateTime.Now;
            _repoChemical.Add(chemical);
            return(await _repoChemical.SaveAll());
        }
Example #4
0
        public async Task <IActionResult> Create(ChemicalDto entity)
        {
            return(Ok(await _chemicalService.Add(entity)));
            // if (await _ingredientService.CheckExists(entity.ID))
            //     return BadRequest("Ingredient ID already exists!");
            // if (await _ingredientService.CheckBarCodeExists(entity.Code))
            //     return BadRequest("Ingredient Barcode already exists!");
            // if (await _ingredientService.CheckExistsName(entity.Name))
            //     return BadRequest("Ingredient Name already exists!");
            // entity.CreatedDate = DateTime.Now.ToString("MMMM dd, yyyy HH:mm:ss tt");
            // if (await _ingredientService.Add1(entity))
            // {
            //     return NoContent();
            // }

            // throw new Exception("Creating the brand failed on save");
        }
Example #5
0
 public Task <bool> Update(ChemicalDto model)
 {
     throw new NotImplementedException();
 }