Esempio n. 1
0
        public async Task <bool> EditDist(ApDistView codeview)
        {
            try
            {
                var ExistingDist = _context.ApDists.Where(x => x.ApDistId == codeview.ApDistId).FirstOrDefault();
                if (ExistingDist != null)
                {
                    ExistingDist.Description = codeview.Description;
                    ExistingDist.Dist1       = codeview.Dist1;

                    _context.ApDists.Update(ExistingDist);
                    await _context.SaveChangesAsync();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(false);
        }
Esempio n. 2
0
        public async Task <bool> AddDist(ApDistView codeview)
        {
            string test     = codeview.DistCode.ToUpper();
            var    cekFirst = _context.ApDists.Where(x => x.DistCode == test).ToList();

            if (cekFirst.Count == 0)
            {
                ApDist AcctCode = new ApDist()
                {
                    DistCode    = codeview.DistCode.ToUpper(),
                    Description = codeview.Description,
                    Dist1       = codeview.Dist1
                };
                _context.ApDists.Add(AcctCode);
                await _context.SaveChangesAsync();

                return(true);
            }
            else
            {
                return(false);
            }
        }