Example #1
0
        public async Task <bool> Delete(object id)
        {
            var chemical = _repoChemical.FindById(id);

            _repoChemical.Remove(chemical);
            return(await _repoChemical.SaveAll());

            // throw new NotImplementedException();
        }
Example #2
0
        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"
                });
            }
        }