コード例 #1
0
        public async Task <bool> AddRangeAsync(List <ChemicalForImportExcelDto> model)
        {
            var ingredients = _mapper.Map <List <Chemical> >(model);

            ingredients.ForEach(ingredient => { ingredient.isShow = true; });
            _repoChemical.AddRange(ingredients);
            return(await _repoInk.SaveAll());
        }
コード例 #2
0
ファイル: PartService.cs プロジェクト: sarutobi1245/IRS
        public async Task <object> UpdatePart(PartInkChemicalDto obj)
        {
            try
            {
                var part = _repoPart.FindById(obj.partID);
                part.Name = obj.name;
                _repoPart.Update(part);

                foreach (var item in obj.listAdd)
                {
                    if (item.subname == "Ink")
                    {
                        var ink = _repoInk.FindById(item.ID);
                        ink.percentage = item.percentage;
                        _repoInk.Update(ink);
                        await _repoInk.SaveAll();
                    }
                    else
                    {
                        var chemical = _repoChemical.FindById(item.ID);
                        chemical.Percentage = item.percentage;
                        _repoChemical.Update(chemical);
                        await _repoChemical.SaveAll();
                    }
                }
                // var message = "success";
                return(new {
                    data = await _repoPart.SaveAll(),
                    status = true,
                    message = "success"
                });
            }
            catch (System.Exception ex)
            {
                return(new {
                    status = false,
                    message = "save to error"
                });
            }
        }
コード例 #3
0
ファイル: InkService.cs プロジェクト: sarutobi1245/IRS
        public async Task ImportExcel(List <InkForImportExcelDto> inkDtos)
        {
            try
            {
                var list        = new List <InkForImportExcelDto>();
                var listChuaAdd = new List <InkForImportExcelDto>();
                var result      = inkDtos.DistinctBy(x => new
                {
                    x.Name,
                    x.Process
                }).Where(x => x.Name != "").ToList();

                foreach (var item in result)
                {
                    var supname = await _repoSup.FindAll().FirstOrDefaultAsync(x => x.Name.ToUpper().Equals(item.Supplier.ToUpper()));

                    if (supname != null)
                    {
                        item.SupplierID = supname.ID;
                    }
                    var process = await _repoProcess.FindAll().FirstOrDefaultAsync(x => x.Name.ToUpper().Equals(item.Process.ToUpper()));

                    if (process != null)
                    {
                        item.ProcessID = process.ID;
                    }
                    // var ink = await AddInk(item);
                    list.Add(item);
                }

                var listAdd = new List <Ink>();
                foreach (var ink in list)
                {
                    if (!await CheckExistInk(ink))
                    {
                        var inks = new Ink();
                        inks.SupplierID       = ink.SupplierID;
                        inks.Code             = ink.Code;
                        inks.Name             = ink.Name;
                        inks.ProcessID        = ink.ProcessID;
                        inks.MaterialNO       = ink.MaterialNO;
                        inks.Unit             = ink.Units;
                        inks.CreatedDate      = ink.CreatedDate;
                        inks.CreatedBy        = ink.CreatedBy;
                        inks.DaysToExpiration = ink.DaysToExpiration;
                        inks.isShow           = true;
                        inks.VOC = ink.VOC;
                        _repoInk.Add(inks);
                        await _repoInk.SaveAll();

                        listAdd.Add(inks);
                    }
                    else
                    {
                        listChuaAdd.Add(ink);
                    }
                }
                var result1 = listAdd.Where(x => x.ID > 0).ToList();
                var result2 = listAdd.Where(x => x.ID == 0).ToList();
            }
            catch
            {
                throw;
            }
        }