public async Task <bool> AddIcDiv(IcDivView codeview) { string test = codeview.Divisi.ToUpper(); var cekFirst = _context.IcDivs.Where(x => x.Divisi == test).ToList(); if (cekFirst.Count == 0) { IcDiv Division = new IcDiv() { Divisi = codeview.Divisi.ToUpper(), NamaDiv = codeview.NamaDiv }; _context.IcDivs.Add(Division); await _context.SaveChangesAsync(); return(true); } else { return(false); } }
public async Task <bool> EditIcDiv(IcDivView codeview) { try { var ExistingDiv = _context.IcDivs.Where(x => x.IcDivId == codeview.IcDivId).FirstOrDefault(); if (ExistingDiv != null) { ExistingDiv.NamaDiv = codeview.NamaDiv; _context.IcDivs.Update(ExistingDiv); await _context.SaveChangesAsync(); return(true); } } catch (Exception ex) { throw ex; } return(false); }