public async Task <ServiceResponse <GetJenisDto> > AddJenis(string nama_jenis) { ServiceResponse <GetJenisDto> response = new ServiceResponse <GetJenisDto>(); var data = new Jenis(); var akses = new Akses(); if (nama_jenis == null || await JenisExists(nama_jenis)) { response.Status = false; response.Message = (nama_jenis == null ? "Inputan tidak boleh kosong" : "Nama Jenis/Akses Sudah Ada"); return(response); } akses.Akses_name = nama_jenis; akses.Akses_status = "1"; akses.Sistem_created_time = DateTime.Now; akses.Sistem_updated_time = Convert.ToDateTime("1900-01-01"); akses.Sistem_ip_create = ip; try { var cek_akses = await _context.Tb_akses.FirstOrDefaultAsync(x => x.Akses_name.ToLower() == nama_jenis.ToLower()); if (cek_akses == null) { await _context.Tb_akses.AddAsync(akses); await _context.SaveChangesAsync(); data.Akses = akses; } else { data.Akses = cek_akses; } data.nama_jenis = nama_jenis; data.Sistem_created_time = DateTime.Now; data.Sistem_updated_time = Convert.ToDateTime("1900-01-01"); } catch (Exception ex) { response.Status = false; response.Message = ex.Message; return(response); } try { await _context.Tb_jenis_pekerjaan.AddAsync(data); await _context.SaveChangesAsync(); response.Data = _mapper.Map <GetJenisDto>(data); response.Message = "Berhasil Tambah Data Jenis"; } catch (Exception ex) { response.Status = false; response.Message = ex.Message; } return(response); }
public async Task <ServiceResponse <GetAksesDto> > AddAkses(string akses_name) { ServiceResponse <GetAksesDto> response = new ServiceResponse <GetAksesDto>(); if (akses_name == null || await CheckAksesExists(akses_name)) { response.Status = false; response.Message = (akses_name == null ? "Harap masukan nama akses" : "Akses Sudah Ada"); return(response); } Akses data = new Akses(); data.Akses_name = akses_name; data.Akses_status = "1"; data.Sistem_created_time = DateTime.Now; data.Sistem_updated_time = Convert.ToDateTime("1900-01-01"); data.Sistem_ip_create = ip; try { await _context.Tb_akses.AddAsync(data); await _context.SaveChangesAsync(); response.Data = _mapper.Map <GetAksesDto>(data); response.Message = "Tambah Akses Berhasil"; } catch (Exception ex) { response.Status = false; response.Message = ex.Message; } return(response); }