public KlantDTO CreateKlant(string klantId) { var klant = _repositoryKlant.GetKlantByID(klantId); if (klant != null) { return(null); } var newKlant = _klantMapper.MapToModel(klantId); var createdKlant = _repositoryKlant.CreateKlant(newKlant); try { _repositoryKlant.SaveChanges(); } catch (DbUpdateException) { return(null); } catch (Exception e) { throw new Exception(e.Message); } return(_klantMapper.MapToDTO(createdKlant)); }
public KlantDTO MakeAdminKlant(string adminId) { var admin = _repositoryAdmin.GetAdminByID(adminId); if (admin == null) { return(null); } _repositoryAdmin.DeleteAdmin(adminId); var klant = _repositoryKlant.GetKlantByID(adminId); if (klant != null) { return(null); } var newKlant = _klantMapper.MapToModel(adminId); var createdKlant = _repositoryKlant.CreateKlant(newKlant); try { _repositoryKlant.SaveChanges(); } catch (DbUpdateException) { return(null); } catch (Exception e) { throw new Exception(e.Message); } return(_klantMapper.MapToDTO(createdKlant)); }